From cb7412181ffed3e22d77b9c4889bd25afec7c4a0 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Sun, 28 Mar 2010 16:00:54 +0000 Subject: Replace fetch_poll with llcache_poll throughout. Allow CONTENT_OTHER to complete properly. svn path=/trunk/netsurf/; revision=10187 --- content/content.c | 46 +++++++++++----------- content/llcache.c | 114 +++++++++++++++++++++++++++--------------------------- css/css.c | 2 +- desktop/netsurf.c | 1 - render/html.c | 2 +- 5 files changed, 82 insertions(+), 83 deletions(-) diff --git a/content/content.c b/content/content.c index fd61979ae..621f15cb1 100644 --- a/content/content.c +++ b/content/content.c @@ -9,7 +9,7 @@ * * NetSurf is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License @@ -299,12 +299,12 @@ static const struct handler_entry handler_map[] = { #ifdef WITH_PNG {nspng_create, nspng_process_data, nspng_convert, 0, nspng_destroy, 0, nspng_redraw, nspng_redraw_tiled, - 0, 0, false}, + 0, 0, false}, #else #ifdef WITH_MNG {nsmng_create, nsmng_process_data, nsmng_convert, 0, nsmng_destroy, 0, nsmng_redraw, nsmng_redraw_tiled, - 0, 0, false}, + 0, 0, false}, #endif #endif #ifdef WITH_MNG @@ -385,7 +385,7 @@ content_type content_lookup(const char *mime_type) /** * Create a new content structure. * - * \param url URL of content, copied + * \param url URL of content, copied * \return the new content structure, or 0 on memory exhaustion * * The type is initialised to CONTENT_UNKNOWN, and the status to @@ -414,11 +414,6 @@ struct content * content_create(llcache_handle *llcache, return NULL; type = content_lookup(mime_type); - if (type == CONTENT_OTHER) { - http_parameter_list_destroy(params); - free(mime_type); - return NULL; - } c = talloc_zero(0, struct content); if (c == NULL) { @@ -506,8 +501,8 @@ struct content * content_create(llcache_handle *llcache, * Handler for low-level cache events * * \param llcache Low-level cache handle - * \param event Event details - * \param pw Pointer to our context + * \param event Event details + * \param pw Pointer to our context * \return NSERROR_OK on success, appropriate error otherwise */ nserror content_llcache_callback(llcache_handle *llcache, @@ -647,7 +642,10 @@ void content_convert(struct content *c, int width, int height) assert(c); assert(c->type < HANDLER_MAP_COUNT); assert(c->status == CONTENT_STATUS_LOADING); - assert(!c->locked); + + if (c->locked == true) + return; + LOG(("content %s (%p)", llcache_handle_get_url(c->llcache), c)); c->locked = true; @@ -735,10 +733,10 @@ void content_destroy(struct content *c) /** * Request a redraw of an area of a content * - * \param h Content handle - * \param x x co-ord of left edge - * \param y y co-ord of top edge - * \param width Width of rectangle + * \param h Content handle + * \param x x co-ord of left edge + * \param y y co-ord of top edge + * \param width Width of rectangle * \param height Height of rectangle */ void content_request_redraw(struct hlcache_handle *h, @@ -838,7 +836,7 @@ bool content_redraw_tiled(hlcache_handle *h, int x, int y, clip_x0, clip_y0, clip_x1, clip_y1, scale, background_colour, repeat_x, repeat_y); } else { - /* ensure we have a redrawable content */ + /* ensure we have a redrawable content */ if ((!handler_map[c->type].redraw) || (width == 0) || (height == 0)) return true; @@ -850,15 +848,15 @@ bool content_redraw_tiled(hlcache_handle *h, int x, int y, /* find the redraw boundaries to loop within*/ x0 = x; if (repeat_x) { - for (; x0 > clip_x0; x0 -= width); - x1 = clip_x1; + for (; x0 > clip_x0; x0 -= width); + x1 = clip_x1; } else { x1 = x + 1; } y0 = y; if (repeat_y) { - for (; y0 > clip_y0; y0 -= height); - y1 = clip_y1; + for (; y0 > clip_y0; y0 -= height); + y1 = clip_y1; } else { y1 = y + 1; } @@ -881,7 +879,7 @@ bool content_redraw_tiled(hlcache_handle *h, int x, int y, * * \param c the content to register * \param callback the callback function - * \param pw callback private data + * \param pw callback private data * \return true on success, false otherwise on memory exhaustion * * The callback will be called when content_broadcast() is @@ -1197,8 +1195,8 @@ int content__get_available_width(struct content *c) /** * Retrieve source of content * - * \param c Content to retrieve source of - * \param size Pointer to location to receive byte size of source + * \param c Content to retrieve source of + * \param size Pointer to location to receive byte size of source * \return Pointer to source data */ const char *content_get_source_data(hlcache_handle *h, unsigned long *size) diff --git a/content/llcache.c b/content/llcache.c index 4d2a7f0b5..8b6e65513 100644 --- a/content/llcache.c +++ b/content/llcache.c @@ -9,7 +9,7 @@ * * NetSurf is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License @@ -195,7 +195,7 @@ static nserror llcache_fetch_cert_error(llcache_object *object, /****************************************************************************** - * Public API * + * Public API * ******************************************************************************/ /** @@ -222,6 +222,8 @@ nserror llcache_poll(void) { llcache_object *object; + fetch_poll(); + /* Catch new users up with state of objects */ for (object = llcache_cached_objects; object != NULL; object = object->next) { @@ -242,12 +244,12 @@ nserror llcache_poll(void) /** * Retrieve a handle for a low-level cache object * - * \param url URL of the object to fetch - * \param flags Object retrieval flags + * \param url URL of the object to fetch + * \param flags Object retrieval flags * \param referer Referring URL, or NULL if none - * \param post POST data, or NULL for a GET request - * \param cb Client callback for events - * \param pw Pointer to client-specific data + * \param post POST data, or NULL for a GET request + * \param cb Client callback for events + * \param pw Pointer to client-specific data * \param result Pointer to location to recieve cache handle * \return NSERROR_OK on success, appropriate error otherwise */ @@ -289,8 +291,8 @@ nserror llcache_handle_retrieve(const char *url, uint32_t flags, * Change the callback associated with a low-level cache handle * * \param handle Handle to change callback of - * \param cb New callback - * \param pw Client data for new callback + * \param cb New callback + * \param pw Client data for new callback * \return NSERROR_OK on success, appropriate error otherwise */ nserror llcache_handle_change_callback(llcache_handle *handle, @@ -342,7 +344,7 @@ const char *llcache_handle_get_url(const llcache_handle *handle) * Retrieve source data of a low-level cache object * * \param handle Handle to retrieve source data from - * \param size Pointer to location to receive byte length of data + * \param size Pointer to location to receive byte length of data * \return Pointer to source data */ const uint8_t *llcache_handle_get_source_data(const llcache_handle *handle, @@ -357,13 +359,13 @@ const uint8_t *llcache_handle_get_source_data(const llcache_handle *handle, * Retrieve a header value associated with a low-level cache object * * \param handle Handle to retrieve header from - * \param key Header name + * \param key Header name * \return Header value, or NULL if header does not exist * * \todo Make the key an enumeration, to avoid needless string comparisons * \todo Forcing the client to parse the header value seems wrong. - * Better would be to return the actual value part and an array of - * key-value pairs for any additional parameters. + * Better would be to return the actual value part and an array of + * key-value pairs for any additional parameters. */ const char *llcache_handle_get_header(const llcache_handle *handle, const char *key) @@ -397,15 +399,15 @@ bool llcache_handle_references_same_object(const llcache_handle *a, } /****************************************************************************** - * Low-level cache internals * + * Low-level cache internals * ******************************************************************************/ /** * Create a new object user * - * \param cb Callback routine - * \param pw Private data for callback - * \param user Pointer to location to receive result + * \param cb Callback routine + * \param pw Private data for callback + * \param user Pointer to location to receive result * \return NSERROR_OK on success, appropriate error otherwise */ nserror llcache_object_user_new(llcache_handle_callback cb, void *pw, @@ -426,7 +428,7 @@ nserror llcache_object_user_new(llcache_handle_callback cb, void *pw, /** * Destroy an object user * - * \param user User to destroy + * \param user User to destroy * \return NSERROR_OK on success, appropriate error otherwise * * \pre User is not attached to an object @@ -441,10 +443,10 @@ nserror llcache_object_user_destroy(llcache_object_user *user) /** * Retrieve an object from the cache, fetching it if necessary. * - * \param url URL of object to retrieve - * \param flags Fetch flags + * \param url URL of object to retrieve + * \param flags Fetch flags * \param referer Referring URL, or NULL if none - * \param post POST data, or NULL for a GET request + * \param post POST data, or NULL for a GET request * \param result Pointer to location to recieve retrieved object * \return NSERROR_OK on success, appropriate error otherwise */ @@ -509,10 +511,10 @@ nserror llcache_object_retrieve(const char *url, uint32_t flags, /** * Retrieve a potentially cached object * - * \param url URL of object to retrieve - * \param flags Fetch flags + * \param url URL of object to retrieve + * \param flags Fetch flags * \param referer Referring URL, or NULL if none - * \param post POST data, or NULL for a GET request + * \param post POST data, or NULL for a GET request * \param result Pointer to location to recieve retrieved object * \return NSERROR_OK on success, appropriate error otherwise */ @@ -642,7 +644,7 @@ nserror llcache_object_cache_update(llcache_object *object) * * \param source Source object containing cache data to clone * \param destination Destination object to clone cache data into - * \param deep Whether to deep-copy the data or not + * \param deep Whether to deep-copy the data or not * \return NSERROR_OK on success, appropriate error otherwise */ nserror llcache_object_clone_cache_data(const llcache_object *source, @@ -693,14 +695,14 @@ nserror llcache_object_clone_cache_data(const llcache_object *source, * Kick-off a fetch for an object * * \param object Object to fetch - * \param flags Fetch flags + * \param flags Fetch flags * \param referer Referring URL, or NULL for none - * \param post POST data, or NULL for GET + * \param post POST data, or NULL for GET * \return NSERROR_OK on success, appropriate error otherwise * * \pre object::url must contain the URL to fetch * \pre If there is a freshness validation candidate, - * object::candidate and object::cache must be filled in + * object::candidate and object::cache must be filled in * \pre There must not be a fetch in progress for \a object */ nserror llcache_object_fetch(llcache_object *object, uint32_t flags, @@ -830,7 +832,7 @@ nserror llcache_object_refetch(llcache_object *object) /** * Create a new low-level cache object * - * \param url URL of object to create + * \param url URL of object to create * \param result Pointer to location to receive result * \return NSERROR_OK on success, appropriate error otherwise */ @@ -903,7 +905,7 @@ nserror llcache_object_destroy(llcache_object *object) * Add a user to a low-level cache object * * \param object Object to add user to - * \param user User to add + * \param user User to add * \return NSERROR_OK. */ nserror llcache_object_add_user(llcache_object *object, @@ -925,7 +927,7 @@ nserror llcache_object_add_user(llcache_object *object, * Remove a user from a low-level cache object * * \param object Object to remove user from - * \param user User to remove + * \param user User to remove * \return NSERROR_OK. */ nserror llcache_object_remove_user(llcache_object *object, @@ -946,7 +948,7 @@ nserror llcache_object_remove_user(llcache_object *object, * Add a low-level cache object to a cache list * * \param object Object to add - * \param list List to add to + * \param list List to add to * \return NSERROR_OK */ nserror llcache_object_add_to_list(llcache_object *object, @@ -966,7 +968,7 @@ nserror llcache_object_add_to_list(llcache_object *object, * Remove a low-level cache object from a cache list * * \param object Object to remove - * \param list List to remove from + * \param list List to remove from * \return NSERROR_OK */ nserror llcache_object_remove_from_list(llcache_object *object, @@ -1015,7 +1017,7 @@ nserror llcache_object_notify_users(llcache_object *object) * * HAD_HEADERS: on transition from HEADERS -> DATA state * HAD_DATA : in DATA state, whenever there's new source data - * DONE : on transition from DATA -> COMPLETE state + * DONE : on transition from DATA -> COMPLETE state */ for (user = object->users; user != NULL; user = next_user) { @@ -1160,8 +1162,8 @@ nserror llcache_clean(void) /** * Clone a POST data object * - * \param orig Object to clone - * \param clone Pointer to location to receive clone + * \param orig Object to clone + * \param clone Pointer to location to receive clone * \return NSERROR_OK on success, appropriate error otherwise */ nserror llcache_post_data_clone(const llcache_post_data *orig, @@ -1202,7 +1204,7 @@ nserror llcache_post_data_clone(const llcache_post_data *orig, * Handle a query response * * \param proceed Whether to proceed with fetch - * \param cbpw Our context for query + * \param cbpw Our context for query * \return NSERROR_OK on success, appropriate error otherwise */ nserror llcache_query_handle_response(bool proceed, void *cbpw) @@ -1233,10 +1235,10 @@ nserror llcache_query_handle_response(bool proceed, void *cbpw) /** * Handler for fetch events * - * \param msg Type of fetch event - * \param p Our private data - * \param data Event data - * \param size Length of data in bytes + * \param msg Type of fetch event + * \param p Our private data + * \param data Event data + * \param size Length of data in bytes * \param errorcode Reason for fetch error */ void llcache_fetch_callback(fetch_msg msg, void *p, const void *data, @@ -1473,10 +1475,10 @@ nserror llcache_fetch_notmodified(llcache_object *object, /** * Split a fetch header into name and value * - * \param data Header string - * \param len Byte length of header - * \param name Pointer to location to receive header name - * \param value Pointer to location to receive header value + * \param data Header string + * \param len Byte length of header + * \param name Pointer to location to receive header name + * \param value Pointer to location to receive header value * \return NSERROR_OK on success, appropriate error otherwise */ nserror llcache_fetch_split_header(const char *data, size_t len, char **name, @@ -1553,10 +1555,10 @@ nserror llcache_fetch_split_header(const char *data, size_t len, char **name, * Parse a fetch header * * \param object Object to parse header for - * \param data Header string - * \param len Byte length of header - * \param name Pointer to location to receive header name - * \param value Pointer to location to receive header value + * \param data Header string + * \param len Byte length of header + * \param name Pointer to location to receive header name + * \param value Pointer to location to receive header value * \return NSERROR_OK on success, appropriate error otherwise */ nserror llcache_fetch_parse_header(llcache_object *object, const char *data, @@ -1647,8 +1649,8 @@ nserror llcache_fetch_parse_header(llcache_object *object, const char *data, * Process a fetch header * * \param object Object being fetched - * \param data Header string - * \param len Byte length of header + * \param data Header string + * \param len Byte length of header * \return NSERROR_OK on success, appropriate error otherwise */ nserror llcache_fetch_process_header(llcache_object *object, const char *data, @@ -1685,8 +1687,8 @@ nserror llcache_fetch_process_header(llcache_object *object, const char *data, * Process a chunk of fetched data * * \param object Object being fetched - * \param data Data to process - * \param len Byte length of data + * \param data Data to process + * \param len Byte length of data * \return NSERROR_OK on success, appropriate error otherwise. */ nserror llcache_fetch_process_data(llcache_object *object, const uint8_t *data, @@ -1714,7 +1716,7 @@ nserror llcache_fetch_process_data(llcache_object *object, const uint8_t *data, * Handle an authentication request * * \param object Object being fetched - * \param realm Authentication realm + * \param realm Authentication realm * \return NSERROR_OK on success, appropriate error otherwise. */ nserror llcache_fetch_auth(llcache_object *object, const char *realm) @@ -1769,8 +1771,8 @@ nserror llcache_fetch_auth(llcache_object *object, const char *realm) * Handle a TLS certificate verification failure * * \param object Object being fetched - * \param certs Certificate chain - * \param num Number of certificates in chain + * \param certs Certificate chain + * \param num Number of certificates in chain * \return NSERROR_OK on success, appropriate error otherwise */ nserror llcache_fetch_cert_error(llcache_object *object, diff --git a/css/css.c b/css/css.c index 473ea488a..6882e7fa8 100644 --- a/css/css.c +++ b/css/css.c @@ -266,7 +266,7 @@ css_error nscss_convert_css_data(struct content_css_data *c, int w, int h) while (c->imports[i].c != NULL && content_get_status(c->imports[i].c) != CONTENT_STATUS_DONE) { - fetch_poll(); + llcache_poll(); gui_multitask(); } diff --git a/desktop/netsurf.c b/desktop/netsurf.c index 1f771933d..6b3b860ea 100644 --- a/desktop/netsurf.c +++ b/desktop/netsurf.c @@ -118,7 +118,6 @@ int netsurf_main_loop(void) { while (!netsurf_quit) { gui_poll(fetch_active); - fetch_poll(); llcache_poll(); } diff --git a/render/html.c b/render/html.c index dc03d4b5e..37630c65f 100644 --- a/render/html.c +++ b/render/html.c @@ -995,7 +995,7 @@ bool html_find_stylesheets(struct content *c, xmlNode *html) content_broadcast(c, CONTENT_MSG_STATUS, msg_data); last_active = c->active; } - fetch_poll(); + llcache_poll(); gui_multitask(); } -- cgit v1.2.3