r9959 jmb - in /branches/jmb/new-cache: content/content.c content/content.h content/content_protected.h desktop/netsurf.c

netsurf at semichrome.net netsurf at semichrome.net
Sun Feb 7 11:58:35 GMT 2010


Author: jmb
Date: Sun Feb  7 05:58:35 2010
New Revision: 9959

URL: http://source.netsurf-browser.org?rev=9959&view=rev
Log:
Content is no longer responsible for managing the cache.

Modified:
    branches/jmb/new-cache/content/content.c
    branches/jmb/new-cache/content/content.h
    branches/jmb/new-cache/content/content_protected.h
    branches/jmb/new-cache/desktop/netsurf.c

Modified: branches/jmb/new-cache/content/content.c
URL: http://source.netsurf-browser.org/branches/jmb/new-cache/content/content.c?rev=9959&r1=9958&r2=9959&view=diff
==============================================================================
--- branches/jmb/new-cache/content/content.c (original)
+++ branches/jmb/new-cache/content/content.c Sun Feb  7 05:58:35 2010
@@ -82,10 +82,6 @@
 #include "utils/talloc.h"
 #include "utils/utils.h"
 
-
-/** Linked list of all content structures. May include more than one content
- *  per URL. Doubly-linked. */
-struct content *content_list = 0;
 
 /** An entry in mime_map. */
 struct mime_entry {
@@ -361,7 +357,6 @@
 
 static void content_update_status(struct content *c);
 static void content_destroy(struct content *c);
-static void content_stop_check(struct content *c);
 
 
 /**
@@ -437,111 +432,7 @@
 
 	content_set_status(c, messages_get("Loading"));
 
-	c->prev = 0;
-	c->next = content_list;
-	if (content_list)
-		content_list->prev = c;
-	content_list = c;
-
 	return c;
-}
-
-
-/**
- * Get a content from the memory cache.
- *
- * \param  url  URL of content
- * \return  content if found, or 0
- *
- * Searches the list of contents for one corresponding to the given url, and
- * which is fresh and shareable.
- */
-
-struct content * content_get(const char *url)
-{
-	struct content *c;
-
-	for (c = content_list; c; c = c->next) {
-		if (!c->fresh)
-			/* not fresh */
-			continue;
-		if (c->status == CONTENT_STATUS_ERROR)
-			/* error state */
-			continue;
-		/** \todo We need to reconsider the entire caching strategy in
-		 * the light of data being shared between specific contents.
-		 *
-		 * For example, string dictionaries are owned by the document, 
-		 * and all stylesheets used by the document share the same 
-		 * dictionary. 
-		 *
-		 * The CSS content handler retrieves the dictionary from its 
-		 * parent content. This relies upon there being a 1:1 mapping 
-		 * between documents and stylesheets.
-		 *
-		 * The type of a content is only known once we've received the
-		 * headers from the fetch layer (and potentially some of the
-		 * content data, too, if we ever sniff for the type). There
-		 * is thus a problem with returning contents of unknown type
-		 * here -- when we subsequently discover that they must only
-		 * have one user, we clone them. By that point, however, we've
-		 * no idea what the parent content is, which means that they
-		 * end up with the wrong parent (and thus wrong dictionary).
-		 *
-		 * Of course, the problem with ignoring unknown content types
-		 * here is that, for all the content types which may be shared,
-		 * we end up duplicating them and wasting memory. Hence the
-		 * need to reconsider everything.
-		 */
-		if (c->type == CONTENT_UNKNOWN)
-			continue;
-		if (c->type != CONTENT_UNKNOWN &&
-				handler_map[c->type].no_share &&
-				c->user_list->next)
-			/* not shareable, and has a user already */
-			continue;
-		if (strcmp(llcache_handle_get_url(c->llcache), url))
-			continue;
-		return c;
-	}
-
-	return 0;
-}
-
-
-/**
- * Get a READY or DONE content from the memory cache.
- *
- * \param url URL of content
- * \return content if found, or 0
- *
- * Searches the list of contents for one corresponding to the given url, and
- * which is fresh, shareable and either READY or DONE.
- */
-
-struct content * content_get_ready(const char *url)
-{
-	struct content *c;
-
-	for (c = content_list; c; c = c->next) {
-		if (!c->fresh)
-			/* not fresh */
-			continue;
-		if (c->status != CONTENT_STATUS_READY &&
-				c->status != CONTENT_STATUS_DONE)
-			/* not ready or done */
-			continue;
-		if (c->type != CONTENT_UNKNOWN &&
-				handler_map[c->type].no_share &&
-				c->user_list->next)
-			/* not shareable, and has a user already */
-			continue;
-		if (strcmp(llcache_handle_get_url(c->llcache), url))
-			continue;
-		return c;
-	}
-
-	return 0;
 }
 
 
@@ -823,65 +714,6 @@
 
 
 /**
- * Clean unused contents from the content_list.
- *
- * Destroys any contents in the content_list with no users or in
- * CONTENT_STATUS_ERROR. Fresh contents in CONTENT_STATUS_DONE may be kept even
- * with no users.
- *
- * Each content is also checked for stop requests.
- */
-
-void content_clean(void)
-{
-	unsigned int size;
-	struct content *c, *next, *prev;
-
-	/* destroy unused stale contents and contents with errors */
-	for (c = content_list; c; c = next) {
-		next = c->next;
-
-		/* this function must not be called from a content function */
-		assert(!c->locked);
-
-		if (c->user_list->next && c->status != CONTENT_STATUS_ERROR)
-			/* content has users */
-			continue;
-
-		if (c->fresh && c->status == CONTENT_STATUS_DONE)
-			/* content is fresh */
-			continue;
-
-		/* content can be destroyed */
-		content_destroy(c);
-	}
-
-	/* check for pending stops */
-	for (c = content_list; c; c = c->next) {
-		if (c->status == CONTENT_STATUS_READY)
-			content_stop_check(c);
-	}
-
-	/* attempt to shrink the memory cache (unused fresh contents) */
-	size = 0;
-	next = 0;
-	for (c = content_list; c; c = c->next) {
-		next = c;
-		c->talloc_size = talloc_total_size(c);
-		size += c->size + c->talloc_size;
-	}
-	for (c = next; c && (unsigned int) option_memory_cache_size < size;
-			c = prev) {
-		prev = c->prev;
-		if (c->user_list->next)
-			continue;
-		size -= c->size + c->talloc_size;
-		content_destroy(c);
-	}
-}
-
-
-/**
  * Destroy and free a content.
  *
  * Calls the destroy function for the content, and frees the structure.
@@ -892,13 +724,6 @@
 	assert(c);
 	LOG(("content %p %s", c, llcache_handle_get_url(c->llcache)));
 	assert(!c->locked);
-
-	if (c->next)
-		c->next->prev = c->prev;
-	if (c->prev)
-		c->prev->next = c->next;
-	else
-		content_list = c->next;
 
 	if (c->type < HANDLER_MAP_COUNT && handler_map[c->type].destroy)
 		handler_map[c->type].destroy(c);
@@ -929,38 +754,6 @@
 	c->refresh = 0;
 	talloc_free(c->title);
 	c->title = 0;
-}
-
-
-/**
- * Free all contents in the content_list.
- */
-
-void content_quit(void)
-{
-	bool progress = true;
-	struct content *c, *next;
-
-	while (content_list && progress) {
-		progress = false;
-		for (c = content_list; c; c = next) {
-		  	assert(c->next != c);
-			next = c->next;
-
-			if (c->user_list->next &&
-					c->status != CONTENT_STATUS_ERROR)
-				/* content has users */
-				continue;
-
-			/* content can be destroyed */
-			content_destroy(c);
-			progress = true;
-		}
-	}
-
-	if (content_list) {
-		LOG(("bug: some contents could not be destroyed"));
-	}
 }
 
 
@@ -1214,34 +1007,6 @@
 
 
 /**
- * Check if all users have requested a stop, and do it if so.
- */
-
-void content_stop_check(struct content *c)
-{
-	struct content_user *user;
-	union content_msg_data data;
-
-	assert(c->status == CONTENT_STATUS_READY);
-
-	/* user_list starts with a sentinel */
-	for (user = c->user_list->next; user; user = user->next)
-		if (!user->stop)
-			return;
-
-	LOG(("%p %s", c, llcache_handle_get_url(c->llcache)));
-
-	/* all users have requested stop */
-	assert(handler_map[c->type].stop);
-	handler_map[c->type].stop(c);
-	assert(c->status == CONTENT_STATUS_DONE);
-
-	content_set_status(c, messages_get("Stopped"));
-	content_broadcast(c, CONTENT_MSG_DONE, data);
-}
-
-
-/**
  * A window containing the content has been opened.
  *
  * \param  c	   content that has been opened

Modified: branches/jmb/new-cache/content/content.h
URL: http://source.netsurf-browser.org/branches/jmb/new-cache/content/content.h?rev=9959&r1=9958&r2=9959&view=diff
==============================================================================
--- branches/jmb/new-cache/content/content.h (original)
+++ branches/jmb/new-cache/content/content.h Sun Feb  7 05:58:35 2010
@@ -96,8 +96,6 @@
 
 content_type content_lookup(const char *mime_type);
 struct content * content_create(const char *url);
-struct content * content_get(const char *url);
-struct content * content_get_ready(const char *url);
 bool content_can_reformat(struct content *c);
 bool content_set_type(struct content *c, content_type type,
 		const char *mime_type, const char *params[],
@@ -108,9 +106,7 @@
 void content_convert(struct content *c, int width, int height);
 void content_set_done(struct content *c);
 void content_reformat(struct content *c, int width, int height);
-void content_clean(void);
 void content_reset(struct content *c);
-void content_quit(void);
 bool content_redraw(struct content *c, int x, int y,
 		int width, int height,
 		int clip_x0, int clip_y0, int clip_x1, int clip_y1,

Modified: branches/jmb/new-cache/content/content_protected.h
URL: http://source.netsurf-browser.org/branches/jmb/new-cache/content/content_protected.h?rev=9959&r1=9958&r2=9959&view=diff
==============================================================================
--- branches/jmb/new-cache/content/content_protected.h (original)
+++ branches/jmb/new-cache/content/content_protected.h Sun Feb  7 05:58:35 2010
@@ -192,9 +192,6 @@
 		unsigned int line;	/**< Line no, 0 if not applicable. */
 	} error_list[40];
 	unsigned int error_count;	/**< Number of valid error entries. */
-
-	struct content *prev;		/**< Previous in global content list. */
-	struct content *next;		/**< Next in global content list. */
 };
 
 extern const char * const content_type_name[];

Modified: branches/jmb/new-cache/desktop/netsurf.c
URL: http://source.netsurf-browser.org/branches/jmb/new-cache/desktop/netsurf.c?rev=9959&r1=9958&r2=9959&view=diff
==============================================================================
--- branches/jmb/new-cache/desktop/netsurf.c (original)
+++ branches/jmb/new-cache/desktop/netsurf.c Sun Feb  7 05:58:35 2010
@@ -141,16 +141,6 @@
 
 void netsurf_poll(void)
 {
-	static unsigned int last_clean = 0;
-	unsigned int current_time = wallclock();
-
-	/* avoid calling content_clean() more often than once every 5
-	 * seconds.
-	 */
-	if (last_clean + 500 < current_time) {
-		last_clean = current_time;
-		content_clean();
-	}
 	gui_poll(fetch_active);
 	fetch_poll();
 }
@@ -164,8 +154,6 @@
 {
 	LOG(("Closing GUI"));
 	gui_quit();
-	LOG(("Closing content"));
-	content_quit();
 	LOG(("Closing fetches"));
 	fetch_quit();
 	LOG(("Closing utf8"));




More information about the netsurf-commits mailing list