|
NetSurf
|
High-level resource cache implementation. More...
#include <assert.h>#include <stdlib.h>#include <string.h>#include "utils/http.h"#include "utils/log.h"#include "utils/messages.h"#include "utils/ring.h"#include "utils/utils.h"#include "netsurf/inttypes.h"#include "netsurf/misc.h"#include "netsurf/content.h"#include "desktop/gui_internal.h"#include "content/mimesniff.h"#include "content/hlcache.h"#include "content/content_protected.h"#include "content/content_factory.h"Go to the source code of this file.
Data Structures | |
| struct | hlcache_retrieval_ctx |
| High-level cache retrieval context. More... | |
| struct | hlcache_handle |
| High-level cache handle. More... | |
| struct | hlcache_entry |
| Entry in high-level cache. More... | |
| struct | hlcache_s |
| Current state of the cache. More... | |
Typedefs | |
| typedef struct hlcache_entry | hlcache_entry |
| typedef struct hlcache_retrieval_ctx | hlcache_retrieval_ctx |
Functions | |
| static void | hlcache_clean (void *force_clean_flag) |
| Attempt to clean the cache. More... | |
| static bool | hlcache_type_is_acceptable (lwc_string *mime_type, content_type accepted_types, content_type *computed_type) |
| Determine if the specified MIME type is acceptable. More... | |
| static void | hlcache_content_callback (struct content *c, content_msg msg, const union content_msg_data *data, void *pw) |
| Veneer between content callback API and hlcache callback API. More... | |
| static nserror | hlcache_find_content (hlcache_retrieval_ctx *ctx, lwc_string *effective_type) |
| Find a content for the high-level cache handle. More... | |
| static nserror | hlcache_migrate_ctx (hlcache_retrieval_ctx *ctx, lwc_string *effective_type) |
| Migrate a retrieval context into its final destination content. More... | |
| static nserror | hlcache_llcache_callback (llcache_handle *handle, const llcache_event *event, void *pw) |
| Handler for low-level cache events. More... | |
| nserror | hlcache_initialise (const struct hlcache_parameters *hlcache_parameters) |
| Initialise the high-level cache, preparing the llcache also. More... | |
| void | hlcache_stop (void) |
| Stop the high-level cache periodic functionality so that the exit sequence can run. More... | |
| void | hlcache_finalise (void) |
| Finalise the high-level cache, destroying any remaining contents. More... | |
| nserror | hlcache_handle_retrieve (nsurl *url, uint32_t flags, nsurl *referer, llcache_post_data *post, hlcache_handle_callback cb, void *pw, hlcache_child_context *child, content_type accepted_types, hlcache_handle **result) |
| Retrieve a high-level cache handle for an object. More... | |
| nserror | hlcache_handle_release (hlcache_handle *handle) |
| Release a high-level cache handle. More... | |
| struct content * | hlcache_handle_get_content (const hlcache_handle *handle) |
| Retrieve a content object from a cache handle. More... | |
| nserror | hlcache_handle_abort (hlcache_handle *handle) |
| Abort a high-level cache fetch. More... | |
| nserror | hlcache_handle_replace_callback (hlcache_handle *handle, hlcache_handle_callback cb, void *pw) |
| Replace a high-level cache handle's callback. More... | |
| nserror | hlcache_handle_clone (hlcache_handle *handle, hlcache_handle **result) |
| Clone a high level cache handle. More... | |
| nsurl * | hlcache_handle_get_url (const hlcache_handle *handle) |
Variables | |
| static struct hlcache_s * | hlcache = NULL |
| high level cache state More... | |
High-level resource cache implementation.
Definition in file hlcache.c.
| typedef struct hlcache_entry hlcache_entry |
| typedef struct hlcache_retrieval_ctx hlcache_retrieval_ctx |
|
static |
Attempt to clean the cache.
Definition at line 111 of file hlcache.c.
References hlcache_parameters::bg_clean_time, hlcache_entry::content, content__get_status(), content_abort(), content_count_users(), content_destroy(), hlcache_s::content_list, content_set_error(), CONTENT_STATUS_LOADING, guit, hlcache, hlcache_clean(), llcache_clean(), netsurf_table::misc, hlcache_entry::next, NSLOG, hlcache_s::params, hlcache_entry::prev, and gui_misc_table::schedule.
Referenced by hlcache_clean(), hlcache_finalise(), hlcache_initialise(), and hlcache_stop().
|
static |
Veneer between content callback API and hlcache callback API.
| c | Content to emit message for |
| msg | Message to emit |
| data | Data for message |
| pw | Pointer to private data (hlcache_handle) |
Definition at line 191 of file hlcache.c.
References hlcache_handle::cb, NSERROR_OK, NSLOG, hlcache_handle::pw, and hlcache_event::type.
Referenced by hlcache_find_content(), hlcache_handle_abort(), and hlcache_handle_release().
| void hlcache_finalise | ( | void | ) |
Finalise the high-level cache, destroying any remaining contents.
Definition at line 580 of file hlcache.c.
References hlcache_child_context::charset, hlcache_retrieval_ctx::child, hlcache_entry::content, content_count_users(), hlcache_s::content_list, guit, hlcache_retrieval_ctx::handle, hlcache_s::hit_count, hlcache, hlcache_clean(), hlcache_handle_get_url(), hlcache_retrieval_ctx::llcache, llcache_finalise(), llcache_handle_release(), netsurf_table::misc, hlcache_s::miss_count, hlcache_entry::next, NSLOG, nsurl_access(), hlcache_retrieval_ctx::r_next, hlcache_s::retrieval_ctx_ring, and gui_misc_table::schedule.
Referenced by netsurf_exit().
|
static |
Find a content for the high-level cache handle.
| ctx | High-level cache retrieval context |
| effective_type | Effective MIME type of content |
Definition at line 225 of file hlcache.c.
References hlcache_handle::cb, hlcache_child_context::charset, hlcache_retrieval_ctx::child, hlcache_entry::content, content_add_user(), content_factory_create_content(), content_get_llcache_handle(), content_get_status(), content_is_shareable(), hlcache_s::content_list, content_matches_quirks(), CONTENT_MSG_DONE, CONTENT_MSG_LOADING, CONTENT_MSG_READY, CONTENT_STATUS_DONE, CONTENT_STATUS_ERROR, CONTENT_STATUS_LOADING, CONTENT_STATUS_READY, hlcache_handle::entry, hlcache_retrieval_ctx::handle, hlcache_s::hit_count, hlcache, hlcache_content_callback(), hlcache_retrieval_ctx::llcache, llcache_handle_references_same_object(), llcache_handle_release(), hlcache_s::miss_count, hlcache_entry::next, NSERROR_NEED_DATA, NSERROR_NOMEM, NSERROR_OK, hlcache_entry::prev, hlcache_handle::pw, and hlcache_child_context::quirks.
Referenced by hlcache_migrate_ctx().
| nserror hlcache_handle_abort | ( | hlcache_handle * | handle | ) |
Abort a high-level cache fetch.
| handle | Handle to abort |
Definition at line 782 of file hlcache.c.
References hlcache_entry::content, content_abort(), content_add_user(), content_clone(), content_count_users(), content_destroy(), hlcache_s::content_list, content_remove_user(), hlcache_handle::entry, hlcache, hlcache_content_callback(), llcache_handle_abort(), llcache_handle_release(), hlcache_entry::next, NSERROR_NOMEM, NSERROR_OK, hlcache_entry::prev, hlcache_s::retrieval_ctx_ring, RING_ITERATE_END, RING_ITERATE_START, RING_ITERATE_STOP, and RING_REMOVE.
Referenced by browser_window_destroy_internal(), browser_window_stop(), html_css_process_modified_style(), and html_object_abort_objects().
| nserror hlcache_handle_clone | ( | hlcache_handle * | handle, |
| hlcache_handle ** | result | ||
| ) |
Clone a high level cache handle.
| handle | The handle to clone. |
| result | The cloned handle. |
Definition at line 865 of file hlcache.c.
References NSERROR_CLONE_FAILED, and result.
Referenced by print_init().
| struct content * hlcache_handle_get_content | ( | const hlcache_handle * | handle | ) |
Retrieve a content object from a cache handle.
| handle | Cache handle to dereference |
Definition at line 772 of file hlcache.c.
References hlcache_entry::content, and hlcache_handle::entry.
Referenced by browser_window_callback(), content_can_reformat(), content_clear_selection(), content_close(), content_debug(), content_debug_dump(), content_drop_file_at_point(), content_exec(), content_find_rfc5988_link(), content_get_available_width(), content_get_bitmap(), content_get_contextual_content(), content_get_encoding(), content_get_height(), content_get_mime_type(), content_get_opaque(), content_get_quirks(), content_get_refresh_url(), content_get_selection(), content_get_source_data(), content_get_status(), content_get_status_message(), content_get_title(), content_get_type(), content_get_width(), content_invalidate_reuse_data(), content_is_locked(), content_keypress(), content_mouse_action(), content_mouse_track(), content_open(), content_redraw(), content_reformat(), content_request_redraw(), content_saw_insecure_objects(), content_scaled_redraw(), content_scroll_at_point(), content_textsearch(), content_textsearch_clear(), html_get_base_target(), html_get_base_url(), html_get_box_tree(), html_get_document(), html_get_frameset(), html_get_iframe(), html_get_objects(), html_get_stylesheets(), html_set_file_gadget_filename(), nscss_content_done(), nscss_get_imports(), nscss_get_stylesheet(), nscss_register_import(), and save_complete_ctx_has_content().
| nsurl * hlcache_handle_get_url | ( | const hlcache_handle * | handle | ) |
Definition at line 872 of file hlcache.c.
References hlcache_entry::content, content_get_url(), hlcache_handle::entry, hlcache, llcache_handle_get_url(), result, hlcache_s::retrieval_ctx_ring, RING_ITERATE_END, RING_ITERATE_START, and RING_ITERATE_STOP.
Referenced by hlcache_finalise().
| nserror hlcache_handle_release | ( | hlcache_handle * | handle | ) |
Release a high-level cache handle.
| handle | Handle to release |
Definition at line 736 of file hlcache.c.
References hlcache_handle::cb, hlcache_entry::content, content_remove_user(), hlcache_handle::entry, hlcache, hlcache_content_callback(), llcache_handle_abort(), llcache_handle_release(), NSERROR_OK, hlcache_handle::pw, hlcache_s::retrieval_ctx_ring, RING_ITERATE_END, RING_ITERATE_START, RING_ITERATE_STOP, and RING_REMOVE.
Referenced by browser_window__handle_error(), browser_window_content_ready(), browser_window_convert_to_download(), browser_window_destroy_internal(), browser_window_favicon_callback(), browser_window_stop(), convert_script_async_cb(), convert_script_defer_cb(), convert_script_sync_cb(), default_ico_callback(), html_convert_css_callback(), html_css_free_stylesheets(), html_css_process_modified_style(), html_object_abort_objects(), html_object_callback(), html_object_free_objects(), html_object_nobox_callback(), html_replace_object(), html_script_free(), nscss_destroy_css_data(), nscss_import(), print_cleanup(), ro_gui_url_bar_fini(), search_web_finalise(), search_web_ico_callback(), theme_install_close(), and treeview_fini().
| nserror hlcache_handle_replace_callback | ( | hlcache_handle * | handle, |
| hlcache_handle_callback | cb, | ||
| void * | pw | ||
| ) |
Replace a high-level cache handle's callback.
| handle | Handle to replace callback of |
| cb | New callback routine |
| pw | Private data for callback |
Definition at line 856 of file hlcache.c.
References hlcache_handle::cb, NSERROR_OK, and hlcache_handle::pw.
Referenced by theme_install_start().
| nserror hlcache_handle_retrieve | ( | nsurl * | url, |
| uint32_t | flags, | ||
| nsurl * | referer, | ||
| llcache_post_data * | post, | ||
| hlcache_handle_callback | cb, | ||
| void * | pw, | ||
| hlcache_child_context * | child, | ||
| content_type | accepted_types, | ||
| hlcache_handle ** | result | ||
| ) |
Retrieve a high-level cache handle for an object.
| url | URL of the object to retrieve handle for |
| flags | Object retrieval flags |
| referer | Referring URL, or NULL if none |
| post | POST data, or NULL for a GET request |
| cb | Callback to handle object events |
| pw | Pointer to client-specific data for callback |
| child | Child retrieval context, or NULL for top-level content |
| accepted_types | Bitmap of acceptable content types |
| result | Pointer to location to recieve cache handle |
Child contents are keyed on the tuple < URL, quirks >. The quirks field is ignored for child contents whose behaviour is not affected by quirks mode.
Definition at line 675 of file hlcache.c.
References hlcache_retrieval_ctx::accepted_types, hlcache_handle::cb, hlcache_child_context::charset, hlcache_retrieval_ctx::child, hlcache_retrieval_ctx::flags, hlcache_retrieval_ctx::handle, hlcache, hlcache_llcache_callback(), hlcache_retrieval_ctx::llcache, llcache_handle_retrieve(), NSERROR_NOMEM, NSERROR_OK, hlcache_handle::pw, hlcache_child_context::quirks, result, hlcache_s::retrieval_ctx_ring, and RING_INSERT.
Referenced by browser_window_favicon_callback(), browser_window_update_favicon(), exec_src_script(), html_css_new_stylesheets(), html_css_process_link(), html_css_quirks_stylesheets(), html_fetch_object(), html_replace_object(), html_stylesheet_from_domnode(), navigate_internal_real(), nscss_handle_import(), ro_gui_url_bar_init(), search_web_init(), search_web_select_provider(), and treeview_init_resources().
| nserror hlcache_initialise | ( | const struct hlcache_parameters * | hlcache_parameters | ) |
Initialise the high-level cache, preparing the llcache also.
| hlcache_parameters | Settings to initialise cache with |
Definition at line 548 of file hlcache.c.
References hlcache_parameters::bg_clean_time, guit, hlcache, hlcache_clean(), hlcache_parameters::llcache, llcache_initialise(), netsurf_table::misc, NSERROR_NOMEM, NSERROR_OK, hlcache_s::params, and gui_misc_table::schedule.
Referenced by netsurf_init().
|
static |
Handler for low-level cache events.
| handle | Handle for which event is issued |
| event | Event data |
| pw | Pointer to client-specific data |
Definition at line 429 of file hlcache.c.
References hlcache_retrieval_ctx::accepted_types, llcache_event::buf, hlcache_handle::cb, content_msg_data::chain, CONTENT_IMAGE, CONTENT_MSG_ERROR, CONTENT_MSG_REDIRECT, CONTENT_MSG_SSL_CERTS, hlcache_event::data, llcache_event::data, content_msg_data::errorcode, content_msg_data::errordata, content_msg_data::errormsg, hlcache_retrieval_ctx::flags, content_msg_data::from, hlcache_retrieval_ctx::handle, hlcache_migrate_ctx(), HLCACHE_RETRIEVE_SNIFF_TYPE, llcache_event::len, hlcache_retrieval_ctx::llcache, LLCACHE_EVENT_DONE, LLCACHE_EVENT_ERROR, LLCACHE_EVENT_GOT_CERTS, LLCACHE_EVENT_HAD_DATA, LLCACHE_EVENT_HAD_HEADERS, LLCACHE_EVENT_PROGRESS, LLCACHE_EVENT_REDIRECT, llcache_handle_get_header(), mimesniff_compute_effective_type(), NSERROR_NEED_DATA, NSERROR_NOT_FOUND, NSERROR_OK, hlcache_handle::pw, content_msg_data::redirect, content_msg_data::to, hlcache_event::type, and llcache_event::type.
Referenced by hlcache_handle_retrieve().
|
static |
Migrate a retrieval context into its final destination content.
| ctx | Context to migrate |
| effective_type | The effective MIME type of the content, or NULL |
Definition at line 348 of file hlcache.c.
References hlcache_retrieval_ctx::accepted_types, hlcache_handle::cb, hlcache_child_context::charset, hlcache_retrieval_ctx::child, CONTENT_MSG_DOWNLOAD, CONTENT_MSG_ERROR, CONTENT_NONE, hlcache_event::data, content_msg_data::download, content_msg_data::errorcode, content_msg_data::errordata, content_msg_data::errormsg, hlcache_retrieval_ctx::flags, hlcache_retrieval_ctx::handle, hlcache, hlcache_find_content(), HLCACHE_RETRIEVE_MAY_DOWNLOAD, hlcache_type_is_acceptable(), hlcache_retrieval_ctx::llcache, llcache_handle_abort(), llcache_handle_force_stream(), llcache_handle_release(), messages_get(), hlcache_retrieval_ctx::migrate_target, NSERROR_NEED_DATA, NSERROR_OK, NSERROR_UNKNOWN, hlcache_handle::pw, hlcache_s::retrieval_ctx_ring, RING_REMOVE, hlcache_event::type, and type.
Referenced by hlcache_llcache_callback().
| void hlcache_stop | ( | void | ) |
Stop the high-level cache periodic functionality so that the exit sequence can run.
Definition at line 573 of file hlcache.c.
References guit, hlcache_clean(), netsurf_table::misc, and gui_misc_table::schedule.
Referenced by netsurf_exit().
|
static |
Determine if the specified MIME type is acceptable.
| mime_type | MIME type to consider |
| accepted_types | Array of acceptable types, or NULL for any |
| computed_type | Pointer to location to receive computed type of object |
Definition at line 171 of file hlcache.c.
References content_factory_type_from_mime_type(), and type.
Referenced by hlcache_migrate_ctx().
|
static |
high level cache state
Definition at line 100 of file hlcache.c.
Referenced by hlcache_clean(), hlcache_finalise(), hlcache_find_content(), hlcache_handle_abort(), hlcache_handle_get_url(), hlcache_handle_release(), hlcache_handle_retrieve(), hlcache_initialise(), and hlcache_migrate_ctx().