From f2993e6ed037023e28837c7c666627380235bd14 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sun, 4 Dec 2011 14:55:23 +0000 Subject: content_get_url -> hlcache_handle_get_url, content__get_url -> content_get_url svn path=/trunk/netsurf/; revision=13236 --- content/content.c | 7 +------ content/content.h | 2 +- content/content_protected.h | 1 - content/hlcache.c | 29 ++++++++++++++++++++++++++++- content/hlcache.h | 9 +++++++++ 5 files changed, 39 insertions(+), 9 deletions(-) (limited to 'content') diff --git a/content/content.c b/content/content.c index 3df71b83f..f3345db77 100644 --- a/content/content.c +++ b/content/content.c @@ -910,12 +910,7 @@ lwc_string *content__get_mime_type(struct content *c) * \param c Content to retrieve URL from * \return Pointer to URL, or NULL if not found. */ -nsurl *content_get_url(hlcache_handle *h) -{ - return content__get_url(hlcache_handle_get_content(h)); -} - -nsurl *content__get_url(struct content *c) +nsurl *content_get_url(struct content *c) { if (c == NULL) return NULL; diff --git a/content/content.h b/content/content.h index 730988b2a..580b2dacb 100644 --- a/content/content.h +++ b/content/content.h @@ -151,6 +151,7 @@ bool content_is_shareable(struct content *c); content_status content__get_status(struct content *c); const struct llcache_handle *content_get_llcache_handle(struct content *c); +nsurl *content_get_url(struct content *c); struct content *content_clone(struct content *c); @@ -185,7 +186,6 @@ struct content_rfc5988_link *content_find_rfc5988_link(struct hlcache_handle *c, /* Member accessors */ content_type content_get_type(struct hlcache_handle *c); lwc_string *content_get_mime_type(struct hlcache_handle *c); -nsurl *content_get_url(struct hlcache_handle *c); const char *content_get_title(struct hlcache_handle *c); content_status content_get_status(struct hlcache_handle *c); const char *content_get_status_message(struct hlcache_handle *c); diff --git a/content/content_protected.h b/content/content_protected.h index 34773016f..ad0b0afa6 100644 --- a/content/content_protected.h +++ b/content/content_protected.h @@ -179,7 +179,6 @@ void content__request_redraw(struct content *c, bool content__set_title(struct content *c, const char *title); lwc_string *content__get_mime_type(struct content *c); -nsurl *content__get_url(struct content *c); const char *content__get_title(struct content *c); const char *content__get_status_message(struct content *c); int content__get_width(struct content *c); diff --git a/content/hlcache.c b/content/hlcache.c index 954f9a63d..88c88dfc9 100644 --- a/content/hlcache.c +++ b/content/hlcache.c @@ -176,7 +176,7 @@ void hlcache_finalise(void) if (entry->content != NULL) { LOG((" %p : %s (%d users)", entry, - nsurl_access(content_get_url(&entry_handle)), content_count_users(entry->content))); + nsurl_access(hlcache_handle_get_url(&entry_handle)), content_count_users(entry->content))); } else { LOG((" %p", entry)); } @@ -416,6 +416,33 @@ nserror hlcache_handle_clone(hlcache_handle *handle, hlcache_handle **result) return NSERROR_CLONE_FAILED; } +/* See hlcache.h for documentation */ +nsurl *hlcache_handle_get_url(const hlcache_handle *handle) +{ + nsurl *result = NULL; + + assert(handle != NULL); + + if (handle->entry != NULL) { + result = content_get_url(handle->entry->content); + } else { + RING_ITERATE_START(struct hlcache_retrieval_ctx, + hlcache->retrieval_ctx_ring, + ictx) { + if (ictx->handle == handle) { + /* This is the nascent context for us */ + result = llcache_handle_get_url(ictx->llcache); + + /* And stop */ + RING_ITERATE_STOP(hlcache->retrieval_ctx_ring, + ictx); + } + } RING_ITERATE_END(hlcache->retrieval_ctx_ring, ictx); + } + + return result; +} + /****************************************************************************** * High-level cache internals * ******************************************************************************/ diff --git a/content/hlcache.h b/content/hlcache.h index a817b0fbd..41f1ed6f4 100644 --- a/content/hlcache.h +++ b/content/hlcache.h @@ -26,6 +26,7 @@ #include "content/content.h" #include "content/llcache.h" #include "utils/errors.h" +#include "utils/nsurl.h" /** High-level cache handle */ typedef struct hlcache_handle hlcache_handle; @@ -189,4 +190,12 @@ struct content *hlcache_handle_get_content(const hlcache_handle *handle); */ nserror hlcache_handle_clone(hlcache_handle *handle, hlcache_handle **result); +/** + * Retrieve the URL associated with a high level cache handle + * + * \param handle The handle to inspect + * \return Pointer to URL. + */ +nsurl *hlcache_handle_get_url(const hlcache_handle *handle); + #endif -- cgit v1.2.3