NetSurf
|
Low-level resource cache (interface) More...
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "utils/errors.h"
#include "utils/nsurl.h"
Go to the source code of this file.
Data Structures | |
struct | llcache_post_data |
POST data object for low-level cache requests. More... | |
struct | llcache_event |
Low-level cache events. More... | |
struct | llcache_store_parameters |
Parameters to configure the low level cache backing store. More... | |
struct | llcache_parameters |
Parameters to configure the low level cache. More... | |
Typedefs | |
typedef struct llcache_handle | llcache_handle |
Handle for low-level cache object. More... | |
typedef struct llcache_post_data | llcache_post_data |
POST data object for low-level cache requests. More... | |
typedef nserror(* | llcache_handle_callback) (llcache_handle *handle, const llcache_event *event, void *pw) |
Client callback for low-level cache events. More... | |
Enumerations | |
enum | llcache_retrieve_flag { LLCACHE_RETRIEVE_FORCE_FETCH = (1 << 0) , LLCACHE_RETRIEVE_VERIFIABLE = (1 << 1) , LLCACHE_RETRIEVE_NO_ERROR_PAGES = (1 << 2) , LLCACHE_RETRIEVE_STREAM_DATA = (1 << 3) } |
Flags for low-level cache object retrieval. More... | |
enum | llcache_event_type { LLCACHE_EVENT_GOT_CERTS , LLCACHE_EVENT_HAD_HEADERS , LLCACHE_EVENT_HAD_DATA , LLCACHE_EVENT_DONE , LLCACHE_EVENT_ERROR , LLCACHE_EVENT_PROGRESS , LLCACHE_EVENT_REDIRECT } |
Low-level cache event types. More... | |
Functions | |
nserror | llcache_initialise (const struct llcache_parameters *parameters) |
Initialise the low-level cache. More... | |
void | llcache_finalise (void) |
Finalise the low-level cache. More... | |
void | llcache_clean (bool purge) |
Cause the low-level cache to attempt to perform cleanup. More... | |
nserror | llcache_handle_retrieve (nsurl *url, uint32_t flags, nsurl *referer, const llcache_post_data *post, llcache_handle_callback cb, void *pw, llcache_handle **result) |
Retrieve a handle for a low-level cache object. More... | |
nserror | llcache_handle_change_callback (llcache_handle *handle, llcache_handle_callback cb, void *pw) |
Change the callback associated with a low-level cache handle. More... | |
nserror | llcache_handle_release (llcache_handle *handle) |
Release a low-level cache handle. More... | |
nserror | llcache_handle_clone (llcache_handle *handle, llcache_handle **result) |
Clone a low-level cache handle, producing a new handle to the same fetch/content. More... | |
nserror | llcache_handle_abort (llcache_handle *handle) |
Abort a low-level fetch, informing all users of this action. More... | |
nserror | llcache_handle_force_stream (llcache_handle *handle) |
Force a low-level cache handle into streaming mode. More... | |
nserror | llcache_handle_invalidate_cache_data (llcache_handle *handle) |
Invalidate cache data for a low-level cache object. More... | |
nsurl * | llcache_handle_get_url (const llcache_handle *handle) |
Retrieve the post-redirect URL of a low-level cache object. More... | |
const uint8_t * | llcache_handle_get_source_data (const llcache_handle *handle, size_t *size) |
Retrieve source data of a low-level cache object. More... | |
const char * | llcache_handle_get_header (const llcache_handle *handle, const char *key) |
Retrieve a header value associated with a low-level cache object. More... | |
bool | llcache_handle_references_same_object (const llcache_handle *a, const llcache_handle *b) |
Determine if the same underlying object is referenced by the given handles. More... | |
Low-level resource cache (interface)
Definition in file llcache.h.
typedef struct llcache_handle llcache_handle |
typedef nserror(* llcache_handle_callback) (llcache_handle *handle, const llcache_event *event, void *pw) |
typedef struct llcache_post_data llcache_post_data |
POST data object for low-level cache requests.
enum llcache_event_type |
Low-level cache event types.
void llcache_clean | ( | bool | purge | ) |
Cause the low-level cache to attempt to perform cleanup.
No guarantees are made as to whether or not cleanups will take place and what, if any, space savings will be made.
purge | Any objects held in the cache that are safely removable will be freed regardless of the configured size limits. |
Definition at line 3725 of file llcache.c.
References BACKING_STORE_NONE, llcache_object::cache, llcache_s::cached_objects, llcache_object::candidate_count, llcache_fetch_ctx::fetch, llcache_object::fetch, guit, gui_llcache_table::invalidate, llcache_object::last_used, llcache_s::limit, llcache, netsurf_table::llcache, llcache_object_destroy(), llcache_object_remove_from_list(), llcache_object_rfc2616_remaining_lifetime(), llcache_persist(), LLCACHE_STATE_DISC, LLCACHE_STATE_RAM, llcache_object::next, NSLOG, nsurl_access(), PRIsizet, gui_llcache_table::release, llcache_object::source_data, llcache_object::source_len, llcache_object::store_state, total_object_size(), llcache_s::uncached_objects, llcache_object::url, and llcache_object::users.
Referenced by ami_memory_low_mem_handler(), hlcache_clean(), and llcache_fetch_callback().
void llcache_finalise | ( | void | ) |
Finalise the low-level cache.
Definition at line 3916 of file llcache.c.
References llcache_s::cached_objects, gui_llcache_table::finalise, guit, llcache_object_user::handle, llcache, netsurf_table::llcache, llcache_object_destroy(), llcache_persist(), netsurf_table::misc, llcache_object_user::next, llcache_object::next, NSLOG, PRIu64, gui_misc_table::schedule, llcache_s::total_elapsed, llcache_s::total_written, llcache_s::uncached_objects, and llcache_object::users.
Referenced by hlcache_finalise().
nserror llcache_handle_abort | ( | llcache_handle * | handle | ) |
Abort a low-level fetch, informing all users of this action.
handle | Handle to abort |
Definition at line 4098 of file llcache.c.
References llcache_fetch_ctx::fetch, llcache_object::fetch, fetch_abort(), llcache_object_user::handle, llcache_object_user::iterator_target, llcache, LLCACHE_FETCH_COMPLETE, llcache_invalidate_cache_control_data(), llcache_object_add_to_list(), llcache_object_add_user(), llcache_object_destroy(), llcache_object_find_user(), llcache_object_remove_user(), llcache_object_snapshot(), llcache_object_user::next, NSERROR_NOMEM, NSERROR_OK, llcache_handle::object, llcache_object_user::prev, llcache_object_user::queued_for_delete, and llcache_s::uncached_objects.
Referenced by browser_window_convert_to_download(), browser_window_download(), content_abort(), content_llcache_callback(), download_callback(), download_context_abort(), hlcache_handle_abort(), hlcache_handle_release(), and hlcache_migrate_ctx().
nserror llcache_handle_change_callback | ( | llcache_handle * | handle, |
llcache_handle_callback | cb, | ||
void * | pw | ||
) |
Change the callback associated with a low-level cache handle.
handle | Handle to change callback of |
cb | New callback |
pw | Client data for new callback |
Definition at line 4047 of file llcache.c.
References llcache_handle::cb, NSERROR_OK, and llcache_handle::pw.
Referenced by content__clone(), content__init(), and download_context_create().
nserror llcache_handle_clone | ( | llcache_handle * | handle, |
llcache_handle ** | result | ||
) |
Clone a low-level cache handle, producing a new handle to the same fetch/content.
handle | Handle to clone |
result | Pointer to location to receive cloned handle |
Definition at line 4082 of file llcache.c.
References llcache_handle::cb, llcache_object_user::handle, llcache_object_add_user(), llcache_object_user_new(), NSERROR_OK, llcache_handle::object, llcache_handle::pw, result, and llcache_handle::state.
Referenced by content__clone().
nserror llcache_handle_force_stream | ( | llcache_handle * | handle | ) |
Force a low-level cache handle into streaming mode.
handle | Handle to stream |
Definition at line 4160 of file llcache.c.
References llcache_s::cached_objects, llcache, llcache_object_add_to_list(), llcache_object_find_user(), llcache_object_in_list(), llcache_object_remove_from_list(), LLCACHE_RETRIEVE_STREAM_DATA, llcache_object_user::next, NSERROR_OK, llcache_handle::object, llcache_object_user::prev, and llcache_s::uncached_objects.
Referenced by hlcache_migrate_ctx(), and nsvideo_create().
const char * llcache_handle_get_header | ( | const llcache_handle * | handle, |
const char * | key | ||
) |
Retrieve a header value associated with a low-level cache object.
handle | Handle to retrieve header from |
key | Header name |
Make the key an enumeration, to avoid needless string comparisons
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.
Deal with multiple headers of the same key (e.g. Set-Cookie)
Definition at line 4210 of file llcache.c.
References llcache_object::headers, llcache_header::name, llcache_handle::object, and llcache_header::value.
Referenced by content_factory_create_content(), download_context_process_headers(), hlcache_llcache_callback(), and nscss_create().
const uint8_t * llcache_handle_get_source_data | ( | const llcache_handle * | handle, |
size_t * | size | ||
) |
Retrieve source data of a low-level cache object.
handle | Handle to retrieve source data from |
size | Pointer to location to receive byte length of data |
Definition at line 4201 of file llcache.c.
References llcache_handle::object, llcache_object::source_data, and llcache_object::source_len.
Referenced by content__get_source_data(), and content_llcache_callback().
nsurl * llcache_handle_get_url | ( | const llcache_handle * | handle | ) |
Retrieve the post-redirect URL of a low-level cache object.
handle | Handle to retrieve URL from |
Definition at line 4195 of file llcache.c.
References llcache_handle::object, and llcache_object::url.
Referenced by content__get_title(), content__init(), content_add_user(), content_close(), content_convert(), content_destroy(), content_get_url(), content_open(), content_remove_user(), download_context_get_url(), download_context_process_headers(), gif_convert(), hlcache_handle_get_url(), image_cache_snentryf(), nsbmp_convert(), nsico_convert(), nsjpeg_convert(), nsjpegxl_convert(), nspng_convert(), and nssprite_convert().
nserror llcache_handle_invalidate_cache_data | ( | llcache_handle * | handle | ) |
Invalidate cache data for a low-level cache object.
handle | Handle to invalidate |
Definition at line 4182 of file llcache.c.
References llcache_object::cache, llcache_fetch_ctx::fetch, llcache_object::fetch, LLCACHE_VALIDATE_FRESH, LLCACHE_VALIDATE_ONCE, llcache_cache_control::no_cache, NSERROR_OK, and llcache_handle::object.
Referenced by content__invalidate_reuse_data().
bool llcache_handle_references_same_object | ( | const llcache_handle * | a, |
const llcache_handle * | b | ||
) |
Determine if the same underlying object is referenced by the given handles.
a | First handle |
b | Second handle |
Definition at line 4229 of file llcache.c.
References llcache_handle::object.
Referenced by hlcache_find_content().
nserror llcache_handle_release | ( | llcache_handle * | handle | ) |
Release a low-level cache handle.
handle | Handle to release |
Definition at line 4058 of file llcache.c.
References llcache_object_user::iterator_target, llcache_object_find_user(), llcache_object_remove_user(), llcache_object_user_destroy(), NSERROR_OK, llcache_handle::object, and llcache_object_user::queued_for_delete.
Referenced by browser_window_convert_to_download(), browser_window_download(), content_destroy(), download_context_destroy(), hlcache_finalise(), hlcache_find_content(), hlcache_handle_abort(), hlcache_handle_release(), and hlcache_migrate_ctx().
nserror llcache_handle_retrieve | ( | nsurl * | url, |
uint32_t | flags, | ||
nsurl * | referer, | ||
const llcache_post_data * | post, | ||
llcache_handle_callback | cb, | ||
void * | pw, | ||
llcache_handle ** | result | ||
) |
Retrieve a handle for a low-level cache object.
url | URL of the object to fetch |
flags | Object retrieval flags |
referer | Referring URL, or NULL if none |
post | POST data, or NULL for a GET request |
cb | Client callback for events |
pw | Pointer to client-specific data |
result | Pointer to location to recieve cache handle |
Definition at line 3990 of file llcache.c.
References fetch_can_fetch(), llcache_object_user::handle, llcache_hsts_transform_url(), llcache_object_add_user(), llcache_object_retrieve(), llcache_object_user_destroy(), llcache_object_user_new(), llcache_users_not_caught_up(), NSERROR_NO_FETCH_HANDLER, NSERROR_OK, nsurl_unref(), result, and llcache_object::url.
Referenced by browser_window_download(), and hlcache_handle_retrieve().
nserror llcache_initialise | ( | const struct llcache_parameters * | parameters | ) |
Initialise the low-level cache.
parameters | cache configuration parameters. |
Definition at line 3891 of file llcache.c.
References llcache_s::all_caught_up, llcache_s::fetch_attempts, llcache_parameters::fetch_attempts, guit, gui_llcache_table::initialise, llcache_s::limit, llcache_parameters::limit, llcache, netsurf_table::llcache, llcache_s::maximum_bandwidth, llcache_parameters::maximum_bandwidth, llcache_s::minimum_bandwidth, llcache_parameters::minimum_bandwidth, llcache_s::minimum_lifetime, llcache_parameters::minimum_lifetime, NSERROR_NOMEM, NSLOG, llcache_parameters::store, llcache_s::time_quantum, and llcache_parameters::time_quantum.
Referenced by hlcache_initialise().