NetSurf
|
Low-level resource cache implementation. More...
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <strings.h>
#include <nsutils/time.h>
#include <nsutils/base64.h>
#include "netsurf/inttypes.h"
#include "utils/config.h"
#include "utils/corestrings.h"
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/nsurl.h"
#include "utils/utils.h"
#include "utils/time.h"
#include "utils/http.h"
#include "utils/nsoption.h"
#include "netsurf/misc.h"
#include "desktop/gui_internal.h"
#include "content/fetch.h"
#include "content/backing_store.h"
#include "content/urldb.h"
Go to the source code of this file.
Data Structures | |
struct | llcache_handle |
Handle to low-level cache object. More... | |
struct | llcache_object_user |
Low-level cache object user record. More... | |
struct | llcache_fetch_ctx |
Low-level cache object fetch context. More... | |
struct | llcache_cache_control |
Cache control data. More... | |
struct | llcache_header |
Representation of a fetch header. More... | |
struct | llcache_object |
Low-level cache object. More... | |
struct | llcache_s |
Core llcache control context. More... | |
Macros | |
#define | INVALID_AGE -1 |
Cache control value for invalid age. More... | |
#define | REDIRECT_LIMIT 10 |
#define | MAX_PERSIST_PER_RUN 128 |
Typedefs | |
typedef struct llcache_object | llcache_object |
Type of low-level cache object. More... | |
typedef struct llcache_object_user | llcache_object_user |
Low-level cache object user record. More... | |
Enumerations | |
enum | llcache_fetch_state { LLCACHE_FETCH_INIT , LLCACHE_FETCH_HEADERS , LLCACHE_FETCH_DATA , LLCACHE_FETCH_COMPLETE } |
State of a low-level cache object fetch. More... | |
enum | llcache_validate { LLCACHE_VALIDATE_FRESH , LLCACHE_VALIDATE_ALWAYS , LLCACHE_VALIDATE_ONCE } |
Validation control. More... | |
enum | llcache_store_state { LLCACHE_STATE_RAM = 0 , LLCACHE_STATE_DISC } |
Current status of an object's data. More... | |
Functions | |
static void | llcache_fetch_callback (const fetch_msg *msg, void *p) |
Handler for fetch events. More... | |
static void | llcache_users_not_caught_up (void) |
Ask for llcache_catch_up_all_users to be scheduled ASAP to pump the user state machines. More... | |
static nserror | llcache_object_user_new (llcache_handle_callback cb, void *pw, llcache_object_user **user) |
Create a new object user. More... | |
static nserror | llcache_object_user_destroy (llcache_object_user *user) |
Destroy an object user. More... | |
static nserror | llcache_object_remove_user (llcache_object *object, llcache_object_user *user) |
Remove a user from a low-level cache object. More... | |
static nserror | llcache_send_event_to_users (llcache_object *object, llcache_event *event) |
Iterate the users of an object, calling their callbacks. More... | |
static nserror | llcache_object_new (nsurl *url, llcache_object **result) |
Create a new low-level cache object. More... | |
static nserror | llcache_post_data_clone (const llcache_post_data *orig, llcache_post_data **clone) |
Clone a POST data object. More... | |
static nserror | llcache_fetch_split_header (const uint8_t *data, size_t len, char **name, char **value) |
Split a fetch header into name and value. More... | |
static nserror | llcache_fetch_parse_cache_control (llcache_object *object, char *value) |
parse cache control header value More... | |
static nserror | llcache_fetch_header_cache_control (llcache_object *object, char *name, char *value) |
Update cache control from appropriate header. More... | |
static void | llcache_destroy_headers (llcache_object *object) |
Destroy headers. More... | |
static void | llcache_invalidate_cache_control_data (llcache_object *object) |
Invalidate cache control data. More... | |
static nserror | llcache_fetch_process_header (llcache_object *object, const uint8_t *data, size_t len) |
Process a fetch header. More... | |
static nserror | get_referer_header (nsurl *url, nsurl *referer, char **header_out) |
construct a Referer header appropriate for the request More... | |
static nserror | llcache_object_refetch (llcache_object *object) |
(Re)fetch an object More... | |
static nserror | llcache_object_fetch (llcache_object *object, uint32_t flags, nsurl *referer, const llcache_post_data *post, uint32_t redirect_count, bool hsts_in_use) |
Kick-off a fetch for an object. More... | |
static nserror | llcache_object_destroy (llcache_object *object) |
Destroy a low-level cache object. More... | |
static nserror | llcache_object_add_to_list (llcache_object *object, llcache_object **list) |
Add a low-level cache object to a cache list. More... | |
static int | llcache_object_rfc2616_remaining_lifetime (const llcache_cache_control *cd) |
Determine the remaining lifetime of a cache object using the. More... | |
static bool | llcache_object_is_fresh (const llcache_object *object) |
Determine if an object is still fresh. More... | |
static nserror | llcache_object_clone_cache_data (llcache_object *source, llcache_object *destination, bool deep) |
Clone an object's cache data. More... | |
static nserror | llcache_object_remove_from_list (llcache_object *object, llcache_object **list) |
Remove a low-level cache object from a cache list. More... | |
static nserror | llcache_retrieve_persisted_data (llcache_object *object) |
Retrieve source data for an object from persistent store if necessary. More... | |
static nserror | llcache_serialise_metadata (llcache_object *object, uint8_t **data_out, size_t *datasize_out) |
Generate a serialised version of an object's metadata. More... | |
static nserror | llcache_process_metadata (llcache_object *object) |
Deserialisation of an object's metadata. More... | |
static bool | llcache__scheme_is_persistable (const nsurl *url) |
Check whether a scheme is persistable. More... | |
static bool | llcache__scheme_is_cachable (const nsurl *url) |
Check whether a scheme is cachable. More... | |
static nserror | llcache_object_fetch_persistent (llcache_object *object, uint32_t flags, nsurl *referer, const llcache_post_data *post, uint32_t redirect_count) |
Attempt to retrieve an object from persistent storage. More... | |
static nserror | llcache_object_retrieve_from_cache (nsurl *url, uint32_t flags, nsurl *referer, const llcache_post_data *post, uint32_t redirect_count, bool hsts_in_use, llcache_object **result) |
Retrieve a potentially cached object. More... | |
static nserror | llcache_object_retrieve (nsurl *url, uint32_t flags, nsurl *referer, const llcache_post_data *post, uint32_t redirect_count, bool hsts_in_use, llcache_object **result) |
Retrieve an object from the cache, fetching it if necessary. More... | |
static nserror | llcache_object_add_user (llcache_object *object, llcache_object_user *user) |
Add a user to a low-level cache object. More... | |
static nserror | llcache_hsts_transform_url (nsurl *url, nsurl **result, bool *hsts_in_use) |
Transform a request-URI based on HSTS policy. More... | |
static nserror | llcache_hsts_update_policy (llcache_object *object) |
Update HSTS policy for target domain. More... | |
static nserror | llcache_fetch_redirect (llcache_object *object, const char *target, llcache_object **replacement) |
Handle FETCH_REDIRECT event. More... | |
static nserror | llcache_object_cache_update (llcache_object *object) |
Update an object's cache state. More... | |
static nserror | llcache_fetch_notmodified (llcache_object *object, llcache_object **replacement) |
Handle FETCH_NOTMODIFIED event. More... | |
static nserror | llcache_fetch_process_data (llcache_object *object, const uint8_t *data, size_t len) |
Process a chunk of fetched data. More... | |
static nserror | llcache_fetch_auth (llcache_object *object, const char *realm) |
Handle an authentication request. More... | |
static nserror | llcache_fetch_cert_error (llcache_object *object) |
Handle a TLS certificate verification failure. More... | |
static nserror | llcache_fetch_ssl_error (llcache_object *object) |
Handle a TLS connection setup failure. More... | |
static nserror | llcache_fetch_timeout (llcache_object *object) |
handle time out while trying to fetch. More... | |
static nserror | build_candidate_list (struct llcache_object ***lst_out, int *lst_len_out) |
Construct a sorted list of objects available for writeout operation. More... | |
static nserror | write_backing_store (struct llcache_object *object, size_t *written_out, unsigned long *elapsed) |
Write an object to the backing store. More... | |
static void | llcache_persist_slowcheck (void *p) |
Check for overall write performance. More... | |
static void | llcache_persist (void *p) |
Possibly write objects data to backing store. More... | |
static llcache_object_user * | llcache_object_find_user (const llcache_handle *handle) |
Find a user of a low-level cache object. More... | |
static bool | llcache_object_in_list (const llcache_object *object, const llcache_object *list) |
Determine if a low-level cache object resides in a given list. More... | |
static nserror | llcache_object_notify_users (llcache_object *object) |
Notify users of an object's current state. More... | |
static nserror | llcache_object_snapshot (llcache_object *object, llcache_object **snapshot) |
Make a snapshot of the current state of an llcache_object. More... | |
static uint32_t | total_object_size (llcache_object *object) |
total ram usage of object More... | |
static void | llcache_catch_up_all_users (void *ignored) |
Catch up the cache users with state changes from fetchers. More... | |
void | llcache_clean (bool purge) |
Cause the low-level cache to attempt to perform cleanup. More... | |
nserror | llcache_initialise (const struct llcache_parameters *prm) |
Initialise the low-level cache. More... | |
void | llcache_finalise (void) |
Finalise the low-level cache. 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... | |
Variables | |
static struct llcache_s * | llcache = NULL |
low level cache state More... | |
Low-level resource cache implementation.
This is the implementation of the low level cache. This cache stores source objects in memory and may use a persistent backing store to extend their lifetime.
Definition in file llcache.c.
#define INVALID_AGE -1 |
#define MAX_PERSIST_PER_RUN 128 |
#define REDIRECT_LIMIT 10 |
typedef struct llcache_object llcache_object |
typedef struct llcache_object_user llcache_object_user |
Low-level cache object user record.
enum llcache_fetch_state |
enum llcache_store_state |
enum llcache_validate |
|
static |
Construct a sorted list of objects available for writeout operation.
The list contains fresh cacheable objects held in RAM with no pending fetches. Any objects with a remaining lifetime less than the configured minimum lifetime are simply not considered, they will become stale before pushing to backing store is worth the cost.
[out] | lst_out | list of candidate objects. |
[out] | lst_len_out | Number of candidate objects in result. |
Definition at line 2775 of file llcache.c.
References llcache_object::cache, llcache_s::cached_objects, llcache_object::candidate_count, llcache_fetch_ctx::fetch, llcache_object::fetch, llcache, llcache__scheme_is_persistable(), llcache_object_rfc2616_remaining_lifetime(), LLCACHE_STATE_RAM, MAX_PERSIST_PER_RUN, llcache_s::minimum_lifetime, llcache_object::next, NSERROR_NOMEM, NSERROR_NOT_FOUND, NSERROR_OK, llcache_object::store_state, and llcache_object::url.
Referenced by llcache_persist().
construct a Referer header appropriate for the request
url | The url being navigated to |
referer | The referring url |
header_out | A pointer to receive the header. The buffer must be freed by the caller. |
Definition at line 819 of file llcache.c.
References NSERROR_BAD_URL, NSERROR_INVALID, NSERROR_NOMEM, NSERROR_OK, nsoption_bool, nsurl_access(), nsurl_get_component(), nsurl_length(), NSURL_SCHEME, and SLEN.
Referenced by llcache_object_refetch().
|
inlinestatic |
Check whether a scheme is cachable.
url | URL to check. |
Definition at line 1810 of file llcache.c.
References nsurl_get_component(), and NSURL_SCHEME.
Referenced by llcache_object_retrieve().
|
inlinestatic |
Check whether a scheme is persistable.
url | URL to check. |
Definition at line 1782 of file llcache.c.
References nsurl_get_component(), and NSURL_SCHEME.
Referenced by build_candidate_list(), and llcache_object_fetch_persistent().
|
static |
Catch up the cache users with state changes from fetchers.
ignored | We ignore this because all our state comes from llcache. |
Definition at line 3679 of file llcache.c.
References llcache_s::all_caught_up, llcache_s::cached_objects, llcache, llcache_object_notify_users(), llcache_object::next, and llcache_s::uncached_objects.
Referenced by llcache_users_not_caught_up().
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().
|
inlinestatic |
Destroy headers.
object | The object to destroy headers within. |
Definition at line 700 of file llcache.c.
References llcache_object::headers, llcache_header::name, llcache_object::num_headers, and llcache_header::value.
Referenced by llcache_fetch_auth(), and llcache_fetch_process_header().
|
static |
Handle an authentication request.
object | Object being fetched |
realm | Authentication realm |
Definition at line 2574 of file llcache.c.
References llcache_fetch_ctx::fetch, llcache_object::fetch, fetch_abort(), llcache_destroy_headers(), LLCACHE_EVENT_ERROR, LLCACHE_FETCH_COMPLETE, llcache_invalidate_cache_control_data(), llcache_object_refetch(), llcache_send_event_to_users(), NSERROR_BAD_AUTH, NSERROR_OK, nsurl_access(), llcache_fetch_ctx::tried_with_auth, llcache_object::url, and urldb_get_auth_details().
Referenced by llcache_fetch_callback().
|
static |
Handler for fetch events.
msg | Fetch event |
p | Our private data |
Definition at line 3058 of file llcache.c.
References fetch_msg::auth, fetch_msg::buf, llcache_object::candidate, cert_chain_dup(), cert_chain_free(), fetch_msg::chain, llcache_object::chain, fetch_msg::data, fetch_msg::error, llcache_fetch_ctx::fetch, llcache_object::fetch, fetch_abort(), FETCH_AUTH, FETCH_CERT_ERR, FETCH_CERTS, FETCH_DATA, FETCH_ERROR, FETCH_FINISHED, FETCH_HEADER, FETCH_NOTMODIFIED, FETCH_PROGRESS, FETCH_REDIRECT, FETCH_SSL_ERR, FETCH_TIMEDOUT, guit, fetch_msg::header_or_data, fetch_msg::len, llcache, llcache_clean(), LLCACHE_EVENT_ERROR, LLCACHE_EVENT_GOT_CERTS, LLCACHE_EVENT_PROGRESS, llcache_fetch_auth(), llcache_fetch_cert_error(), LLCACHE_FETCH_COMPLETE, LLCACHE_FETCH_HEADERS, llcache_fetch_notmodified(), llcache_fetch_process_data(), llcache_fetch_process_header(), llcache_fetch_redirect(), llcache_fetch_ssl_error(), llcache_fetch_timeout(), llcache_hsts_update_policy(), llcache_invalidate_cache_control_data(), llcache_object_cache_update(), llcache_persist(), llcache_send_event_to_users(), llcache_users_not_caught_up(), messages_get_errorcode(), netsurf_table::misc, NSERROR_NOMEM, NSERROR_OK, NSERROR_UNKNOWN, NSLOG, fetch_msg::progress, fetch_msg::realm, fetch_msg::redirect, gui_misc_table::schedule, llcache_object::source_data, llcache_object::source_len, and fetch_msg::type.
Referenced by llcache_object_refetch().
|
static |
Handle a TLS certificate verification failure.
object | Object being fetched |
Definition at line 2627 of file llcache.c.
References llcache_object::fetch, llcache_fetch_ctx::hsts_in_use, LLCACHE_EVENT_ERROR, LLCACHE_FETCH_COMPLETE, llcache_invalidate_cache_control_data(), llcache_send_event_to_users(), messages_get(), NSERROR_BAD_CERTS, NSERROR_OK, and NSERROR_UNKNOWN.
Referenced by llcache_fetch_callback().
|
static |
Update cache control from appropriate header.
object | Object to parse header for |
name | header name |
value | header value |
Definition at line 620 of file llcache.c.
References llcache_object::cache, llcache_cache_control::date, llcache_cache_control::etag, llcache_cache_control::expires, llcache_cache_control::last_modified, llcache, llcache_fetch_parse_cache_control(), nsc_strntimet(), NSERROR_NOMEM, NSERROR_OK, and NSLOG.
Referenced by llcache_fetch_process_header().
|
static |
Handle FETCH_NOTMODIFIED event.
object | Object to process |
replacement | Pointer to location to receive replacement object |
Definition at line 2442 of file llcache.c.
References llcache_object::cache, llcache_object::candidate, llcache_fetch_ctx::fetch, llcache_object::fetch, fetch_abort(), LLCACHE_FETCH_COMPLETE, llcache_hsts_update_policy(), llcache_invalidate_cache_control_data(), llcache_object_add_user(), llcache_object_cache_update(), llcache_object_clone_cache_data(), llcache_object_remove_user(), LLCACHE_VALIDATE_FRESH, LLCACHE_VALIDATE_ONCE, llcache_object_user::next, llcache_cache_control::no_cache, NSERROR_OK, and llcache_object::users.
Referenced by llcache_fetch_callback().
|
static |
parse cache control header value
object | Object to parse header for |
value | header value |
Definition at line 582 of file llcache.c.
References http_cache_control_destroy(), http_cache_control_has_max_age(), http_cache_control_max_age(), http_cache_control_no_cache(), http_cache_control_no_store(), http_parse_cache_control(), LLCACHE_VALIDATE_ALWAYS, and NSERROR_OK.
Referenced by llcache_fetch_header_cache_control().
|
static |
Process a chunk of fetched data.
object | Object being fetched |
data | Data to process |
len | Byte length of data |
There are two cases in which we want to suppress cacheing of an object:
1) The HTTP response code is not 200 or 203 2) The request URI had a query string and the response headers did not provide an explicit object expiration time.
Definition at line 2510 of file llcache.c.
References llcache_object::cache, llcache_object::candidate, llcache_cache_control::expires, llcache_fetch_ctx::fetch, llcache_object::fetch, fetch_http_code(), INVALID_AGE, LLCACHE_FETCH_DATA, llcache_invalidate_cache_control_data(), llcache_cache_control::max_age, NSERROR_NOMEM, NSERROR_OK, nsurl_has_component(), NSURL_QUERY, llcache_object::source_alloc, llcache_object::source_data, llcache_object::source_len, llcache_fetch_ctx::state, and llcache_object::url.
Referenced by llcache_fetch_callback().
|
static |
Process a fetch header.
object | Object being fetched |
data | Header string |
len | Byte length of header |
Therefore, if the header is an HTTP response start marker, then we must discard any headers we've read so far, reset the cache data that we might have computed, and start again.
Definition at line 734 of file llcache.c.
References llcache_object::cache, llcache_object::headers, llcache_destroy_headers(), llcache_fetch_header_cache_control(), llcache_fetch_split_header(), llcache_invalidate_cache_control_data(), llcache_header::name, NSERROR_NOMEM, NSERROR_OK, llcache_object::num_headers, llcache_cache_control::res_time, and SLEN.
Referenced by llcache_fetch_callback(), and llcache_process_metadata().
|
static |
Handle FETCH_REDIRECT event.
object | Object being redirected |
target | Target of redirect (may be relative) |
replacement | Pointer to location to receive replacement object |
Definition at line 2287 of file llcache.c.
References llcache_fetch_ctx::fetch, llcache_object::fetch, fetch_abort(), fetch_can_fetch(), fetch_http_code(), llcache_fetch_ctx::flags, llcache, LLCACHE_EVENT_ERROR, LLCACHE_EVENT_REDIRECT, LLCACHE_FETCH_COMPLETE, llcache_hsts_transform_url(), llcache_hsts_update_policy(), llcache_invalidate_cache_control_data(), llcache_object_add_user(), llcache_object_remove_user(), llcache_object_retrieve(), llcache_send_event_to_users(), messages_get(), llcache_object_user::next, NSERROR_BAD_REDIRECT, NSERROR_OK, NSLOG, nsurl_get_component(), nsurl_join(), NSURL_SCHEME, nsurl_unref(), llcache_fetch_ctx::redirect_count, REDIRECT_LIMIT, llcache_fetch_ctx::referer, llcache_object::url, and llcache_object::users.
Referenced by llcache_fetch_callback().
|
static |
Split a fetch header into name and value.
HTTP header splitting according to grammar defined in RFC7230 section 3.2 https://tools.ietf.org/html/rfc7230#section-3.2
This implementation is non conformant in that it:
data | Header string |
len | Byte length of header |
name | Pointer to location to receive header name |
value | Pointer to location to receive header value |
Definition at line 496 of file llcache.c.
References NSERROR_NOMEM, NSERROR_OK, and strndup().
Referenced by llcache_fetch_process_header().
|
static |
Handle a TLS connection setup failure.
object | Object being fetched |
Definition at line 2679 of file llcache.c.
References llcache_object::fetch, llcache_fetch_ctx::hsts_in_use, LLCACHE_EVENT_ERROR, LLCACHE_FETCH_COMPLETE, llcache_invalidate_cache_control_data(), llcache_object_refetch(), llcache_send_event_to_users(), messages_get(), NSERROR_OK, NSERROR_UNKNOWN, and llcache_fetch_ctx::tried_with_tls_downgrade.
Referenced by llcache_fetch_callback().
|
static |
handle time out while trying to fetch.
object | Object being fetched |
Definition at line 2726 of file llcache.c.
References llcache_object::candidate, llcache_object::fetch, LLCACHE_EVENT_ERROR, LLCACHE_FETCH_COMPLETE, llcache_invalidate_cache_control_data(), llcache_object_refetch(), llcache_send_event_to_users(), NSERROR_TIMEOUT, and llcache_fetch_ctx::retries_remaining.
Referenced by 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().
|
static |
Transform a request-URI based on HSTS policy.
url | URL to transform |
result | Pointer to location to receive transformed URL |
hsts_in_use | Pointer to location to receive HSTS in-use flag |
Definition at line 2200 of file llcache.c.
References NSERROR_OK, nsurl_get_component(), nsurl_ref(), nsurl_replace_scheme(), NSURL_SCHEME, result, and urldb_get_hsts_enabled().
Referenced by llcache_fetch_redirect(), and llcache_handle_retrieve().
|
static |
Update HSTS policy for target domain.
object | Newly-fetched cache object |
Definition at line 2246 of file llcache.c.
References llcache_object::fetch, llcache_object::headers, llcache_header::name, NSERROR_OK, nsurl_get_component(), NSURL_SCHEME, llcache_fetch_ctx::tainted_tls, llcache_object::url, urldb_set_hsts_policy(), and llcache_header::value.
Referenced by llcache_fetch_callback(), llcache_fetch_notmodified(), and llcache_fetch_redirect().
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().
|
inlinestatic |
Invalidate cache control data.
object | The object to invalidate cache control for. |
Definition at line 717 of file llcache.c.
References llcache_object::cache, llcache_cache_control::etag, and INVALID_AGE.
Referenced by llcache_fetch_auth(), llcache_fetch_callback(), llcache_fetch_cert_error(), llcache_fetch_notmodified(), llcache_fetch_process_data(), llcache_fetch_process_header(), llcache_fetch_redirect(), llcache_fetch_ssl_error(), llcache_fetch_timeout(), llcache_handle_abort(), and llcache_object_refetch().
|
static |
Add a low-level cache object to a cache list.
object | Object to add |
list | List to add to |
Definition at line 1116 of file llcache.c.
References NSERROR_OK, and llcache_object::prev.
Referenced by llcache_handle_abort(), llcache_handle_force_stream(), llcache_object_retrieve(), and llcache_object_retrieve_from_cache().
|
static |
Add a user to a low-level cache object.
object | Object to add user to |
user | User to add |
Definition at line 2171 of file llcache.c.
References llcache_object_user::handle, llcache, llcache_object_user::next, NSERROR_OK, NSLOG, llcache_handle::object, llcache_object_user::prev, and llcache_object::users.
Referenced by llcache_fetch_notmodified(), llcache_fetch_redirect(), llcache_handle_abort(), llcache_handle_clone(), and llcache_handle_retrieve().
|
static |
Update an object's cache state.
object | Object to update cache for |
Definition at line 2427 of file llcache.c.
References llcache_object::cache, llcache_cache_control::date, and NSERROR_OK.
Referenced by llcache_fetch_callback(), and llcache_fetch_notmodified().
|
static |
Clone an object's cache data.
source | Source object containing cache data to clone |
destination | Destination object to clone cache data into |
deep | Whether to deep-copy the data or not |
Definition at line 1211 of file llcache.c.
References llcache_cache_control::age, llcache_object::cache, llcache_cache_control::date, llcache_cache_control::etag, llcache_cache_control::expires, llcache_cache_control::fin_time, INVALID_AGE, llcache_cache_control::last_modified, LLCACHE_VALIDATE_FRESH, llcache_cache_control::max_age, llcache_cache_control::no_cache, NSERROR_NOMEM, NSERROR_OK, llcache_cache_control::req_time, and llcache_cache_control::res_time.
Referenced by llcache_fetch_notmodified(), and llcache_object_retrieve_from_cache().
|
static |
Destroy a low-level cache object.
object | Object to destroy |
Definition at line 1058 of file llcache.c.
References BACKING_STORE_NONE, llcache_object::cache, cert_chain_free(), llcache_object::chain, llcache_post_data::data, llcache_cache_control::etag, llcache_fetch_ctx::fetch, llcache_object::fetch, fetch_abort(), fetch_multipart_data_destroy(), guit, llcache_object::headers, llcache, netsurf_table::llcache, LLCACHE_STATE_DISC, llcache_post_data::multipart, llcache_header::name, NSERROR_OK, NSLOG, nsurl_access(), nsurl_unref(), llcache_fetch_ctx::post, llcache_fetch_ctx::referer, gui_llcache_table::release, llcache_object::source_data, llcache_object::store_state, llcache_post_data::type, llcache_object::url, llcache_post_data::urlenc, and llcache_header::value.
Referenced by llcache_clean(), llcache_finalise(), llcache_handle_abort(), llcache_object_retrieve(), llcache_object_retrieve_from_cache(), and llcache_object_snapshot().
|
static |
Kick-off a fetch for an object.
object | Object to fetch |
flags | Fetch flags |
referer | Referring URL, or NULL for none |
post | POST data, or NULL for GET |
redirect_count | Number of redirects followed so far |
hsts_in_use | Whether HSTS applies to this fetch |
Definition at line 1019 of file llcache.c.
References llcache_s::fetch_attempts, llcache, llcache_object_refetch(), llcache_post_data_clone(), NSERROR_OK, NSLOG, and nsurl_ref().
Referenced by llcache_object_retrieve(), and llcache_object_retrieve_from_cache().
|
static |
Attempt to retrieve an object from persistent storage.
object | The object to populate from persistent store. |
flags | Fetch flags. |
referer | The referring url. |
post | Post data for fetch. |
redirect_count | how many times this fetch has been redirected. |
Definition at line 1853 of file llcache.c.
References llcache__scheme_is_persistable(), LLCACHE_FETCH_COMPLETE, llcache_post_data_clone(), llcache_process_metadata(), NSERROR_NOT_FOUND, NSERROR_OK, nsurl_ref(), and llcache_object::url.
Referenced by llcache_object_retrieve_from_cache().
|
static |
Find a user of a low-level cache object.
handle | External cache handle to search for |
Definition at line 3271 of file llcache.c.
References llcache_object_user::handle, llcache_object_user::next, llcache_handle::object, and llcache_object::users.
Referenced by llcache_handle_abort(), llcache_handle_force_stream(), and llcache_handle_release().
|
static |
Determine if a low-level cache object resides in a given list.
object | Object to search for |
list | List to search in |
Definition at line 3294 of file llcache.c.
References llcache_object::next.
Referenced by llcache_handle_force_stream().
|
static |
Determine if an object is still fresh.
object | Object to consider |
Definition at line 1179 of file llcache.c.
References cd, llcache_object::fetch, llcache, LLCACHE_FETCH_COMPLETE, llcache_object_rfc2616_remaining_lifetime(), LLCACHE_VALIDATE_FRESH, NSLOG, and llcache_fetch_ctx::state.
Referenced by llcache_object_retrieve_from_cache().
|
static |
Create a new low-level cache object.
url | URL of object to create |
result | Pointer to location to receive result |
Definition at line 423 of file llcache.c.
References llcache, NSERROR_NOMEM, NSERROR_OK, NSLOG, nsurl_access(), nsurl_ref(), result, and llcache_object::url.
Referenced by llcache_object_retrieve(), llcache_object_retrieve_from_cache(), and llcache_object_snapshot().
|
static |
Notify users of an object's current state.
object | Object to notify users about |
State transitions and event emission for users. Rows: user state. Cols: object state.
User - Obj INIT HEADERS DATA COMPLETE INIT - T T* T* HEADERS - - T T* DATA - - M T COMPLETE - - - -
T => transition user to object state M => no transition required, but may need to emit event
The transitions marked with an asterisk can be removed by moving the user context into the subsequent state and then reevaluating.
Events are issued as follows:
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
Definition at line 3313 of file llcache.c.
References llcache_handle::bytes, llcache_handle::cb, llcache_object::chain, llcache_object::fetch, llcache_fetch_ctx::flags, llcache_object_user::handle, llcache_object_user::iterator_target, llcache, LLCACHE_EVENT_DONE, LLCACHE_EVENT_GOT_CERTS, LLCACHE_EVENT_HAD_DATA, LLCACHE_EVENT_HAD_HEADERS, LLCACHE_FETCH_COMPLETE, LLCACHE_FETCH_DATA, LLCACHE_FETCH_HEADERS, LLCACHE_FETCH_INIT, llcache_object_remove_user(), llcache_object_user_destroy(), LLCACHE_RETRIEVE_STREAM_DATA, llcache_users_not_caught_up(), llcache_object_user::next, NSERROR_NEED_DATA, NSERROR_OK, NSLOG, llcache_handle::pw, llcache_object_user::queued_for_delete, llcache_object::source_len, llcache_handle::state, and llcache_object::users.
Referenced by llcache_catch_up_all_users().
|
static |
(Re)fetch an object
Sets up headers and attempts to start an actual fetch from the fetchers system updating the llcache object with the new fetch on successful start.
object | Object to refetch |
Definition at line 903 of file llcache.c.
References llcache_object::cache, llcache_cache_control::etag, llcache_fetch_ctx::fetch, llcache_object::fetch, fetch_start(), llcache_fetch_ctx::flags, get_referer_header(), llcache_cache_control::last_modified, llcache, llcache_fetch_callback(), LLCACHE_FETCH_INIT, llcache_invalidate_cache_control_data(), LLCACHE_RETRIEVE_NO_ERROR_PAGES, LLCACHE_RETRIEVE_VERIFIABLE, NSERROR_NOMEM, NSERROR_OK, NSLOG, llcache_fetch_ctx::post, llcache_fetch_ctx::referer, rfc1123_date(), SLEN, llcache_fetch_ctx::tried_with_tls_downgrade, llcache_post_data::type, and llcache_object::url.
Referenced by llcache_fetch_auth(), llcache_fetch_ssl_error(), llcache_fetch_timeout(), and llcache_object_fetch().
|
static |
Remove a low-level cache object from a cache list.
object | Object to remove |
list | List to remove from |
Definition at line 1267 of file llcache.c.
References llcache_object::next, NSERROR_OK, and llcache_object::prev.
Referenced by llcache_clean(), llcache_handle_force_stream(), and llcache_object_retrieve_from_cache().
|
static |
Remove a user from a low-level cache object.
object | Object to remove user from |
user | User to remove |
Definition at line 348 of file llcache.c.
References llcache_object_user::handle, llcache, llcache_object_user::next, NSERROR_OK, NSLOG, llcache_handle::object, llcache_object_user::prev, and llcache_object::users.
Referenced by llcache_fetch_notmodified(), llcache_fetch_redirect(), llcache_handle_abort(), llcache_handle_release(), llcache_object_notify_users(), and llcache_send_event_to_users().
|
static |
Retrieve an object from the cache, fetching it if necessary.
url | URL of object to retrieve |
flags | Fetch flags |
referer | Referring URL, or NULL if none |
post | POST data, or NULL for a GET request |
redirect_count | Number of redirects followed so far |
hsts_in_use | Whether HSTS applies to this fetch |
result | Pointer to location to receive retrieved object |
Definition at line 2090 of file llcache.c.
References llcache, llcache__scheme_is_cachable(), llcache_object_add_to_list(), llcache_object_destroy(), llcache_object_fetch(), llcache_object_new(), llcache_object_retrieve_from_cache(), LLCACHE_RETRIEVE_FORCE_FETCH, NSERROR_OK, NSLOG, nsurl_access(), nsurl_defragment(), nsurl_unref(), result, and llcache_s::uncached_objects.
Referenced by llcache_fetch_redirect(), and llcache_handle_retrieve().
|
static |
Retrieve a potentially cached object.
url | URL of object to retrieve |
flags | Fetch flags |
referer | Referring URL, or NULL if none |
post | POST data, or NULL for a GET request |
redirect_count | Number of redirects followed so far |
hsts_in_use | Whether HSTS applies to this fetch |
result | Pointer to location to receive retrieved object |
Definition at line 1914 of file llcache.c.
References llcache_object::cache, llcache_s::cached_objects, llcache_object::candidate, llcache_object::candidate_count, llcache, llcache_object_add_to_list(), llcache_object_clone_cache_data(), llcache_object_destroy(), llcache_object_fetch(), llcache_object_fetch_persistent(), llcache_object_is_fresh(), llcache_object_new(), llcache_object_remove_from_list(), llcache_retrieve_persisted_data(), llcache_object::next, NSERROR_OK, NSLOG, nsurl_access(), nsurl_compare(), NSURL_COMPLETE, llcache_cache_control::req_time, result, and llcache_object::url.
Referenced by llcache_object_retrieve().
|
static |
Determine the remaining lifetime of a cache object using the.
cd | cache control data. |
Definition at line 1136 of file llcache.c.
References cd, INVALID_AGE, llcache, LLCACHE_VALIDATE_FRESH, max, and NSLOG.
Referenced by build_candidate_list(), llcache_clean(), and llcache_object_is_fresh().
|
static |
Make a snapshot of the current state of an llcache_object.
This has the side-effect of the new object being non-cacheable, also not-fetching and not a candidate for any other object.
Also note that this new object has no users and at least one should be assigned to it before llcache_clean is entered or it will be immediately cleaned up.
object | The object to take a snapshot of |
snapshot | Pointer to receive snapshot of object |
Definition at line 3580 of file llcache.c.
References cert_chain_dup(), llcache_object::chain, llcache_object::fetch, llcache_object::headers, LLCACHE_FETCH_COMPLETE, llcache_object_destroy(), llcache_object_new(), llcache_header::name, NSERROR_NOMEM, NSERROR_OK, llcache_object::num_headers, snapshot, llcache_object::source_alloc, llcache_object::source_data, llcache_object::source_len, llcache_fetch_ctx::state, llcache_object::url, and llcache_header::value.
Referenced by llcache_handle_abort().
|
static |
Destroy an object user.
user | User to destroy |
Definition at line 326 of file llcache.c.
References llcache_object_user::handle, llcache, llcache_object_user::next, NSERROR_OK, NSLOG, and llcache_object_user::prev.
Referenced by llcache_handle_release(), llcache_handle_retrieve(), llcache_object_notify_users(), and llcache_send_event_to_users().
|
static |
Create a new object user.
cb | Callback routine. |
pw | Private data for callback. |
user | Pointer to location to receive result. |
Definition at line 288 of file llcache.c.
References llcache_handle::cb, llcache_object_user::handle, llcache, NSERROR_NOMEM, NSERROR_OK, NSLOG, and llcache_handle::pw.
Referenced by llcache_handle_clone(), and llcache_handle_retrieve().
|
static |
Possibly write objects data to backing store.
p | The context pointer passed to the callback. |
Definition at line 2938 of file llcache.c.
References build_candidate_list(), guit, llcache, llcache_persist(), llcache_persist_slowcheck(), llcache_s::maximum_bandwidth, netsurf_table::misc, llcache_object::next, NSERROR_OK, NSLOG, nsurl_access(), PRIsizet, gui_misc_table::schedule, llcache_s::time_quantum, llcache_s::total_elapsed, llcache_s::total_written, llcache_object::url, and write_backing_store().
Referenced by llcache_clean(), llcache_fetch_callback(), llcache_finalise(), and llcache_persist().
|
static |
Check for overall write performance.
If the overall write bandwidth has fallen below a useful level for the backing store to be effective disable it.
It is important to ensure a useful amount of data has been written before calculating bandwidths otherwise tiny files taking a disproportionately long time to write might trigger this erroneously.
p | The context pointer passed to the callback. |
Definition at line 2915 of file llcache.c.
References gui_llcache_table::finalise, guit, llcache, netsurf_table::llcache, llcache_s::minimum_bandwidth, NSLOG, PRIsizet, PRIu64, llcache_s::total_elapsed, and llcache_s::total_written.
Referenced by llcache_persist().
|
static |
Clone a POST data object.
orig | Object to clone |
clone | Pointer to location to receive clone |
Definition at line 445 of file llcache.c.
References llcache_post_data::data, fetch_multipart_data_clone(), llcache_post_data::multipart, NSERROR_NOMEM, NSERROR_OK, llcache_post_data::type, and llcache_post_data::urlenc.
Referenced by llcache_object_fetch(), and llcache_object_fetch_persistent().
|
static |
Deserialisation of an object's metadata.
Attempt to retrieve and deserialise the metadata for an object from the backing store.
This must only update object if it is successful otherwise difficult to debug crashes happen later by using bad leftover object state.
object | The object to retrieve the metadata for. |
Definition at line 1532 of file llcache.c.
References BACKING_STORE_META, cert_chain_alloc(), cert_chain_free(), cert_chain::certs, cert_chain::der, cert_chain::der_length, cert_chain::err, gui_llcache_table::fetch, guit, line(), llcache, netsurf_table::llcache, llcache_fetch_process_header(), LLCACHE_STATE_DISC, MAX_CERT_DEPTH, nsc_snptimet(), NSERROR_BAD_URL, NSERROR_INVALID, NSERROR_NOMEM, NSERROR_OK, NSLOG, nsurl_access(), nsurl_compare(), NSURL_COMPLETE, nsurl_create(), nsurl_unref(), PRIsizet, gui_llcache_table::release, SSL_CERT_ERR_MAX_KNOWN, SSL_CERT_ERR_OK, SSL_CERT_ERR_UNKNOWN, and llcache_object::url.
Referenced by llcache_object_fetch_persistent().
|
static |
Retrieve source data for an object from persistent store if necessary.
If an object's source data has been placed in the persistent store and there is no in-memory copy, then attempt to retrieve the source data.
object | the object to operate on. |
Definition at line 1290 of file llcache.c.
References BACKING_STORE_NONE, gui_llcache_table::fetch, guit, netsurf_table::llcache, LLCACHE_STATE_DISC, NSERROR_OK, llcache_object::source_data, llcache_object::source_len, llcache_object::store_state, and llcache_object::url.
Referenced by llcache_object_retrieve_from_cache().
|
static |
Iterate the users of an object, calling their callbacks.
object | The object to iterate |
event | The event to pass to the callback. |
Definition at line 384 of file llcache.c.
References llcache_handle::cb, llcache_object_user::handle, llcache_object_user::iterator_target, llcache_object_remove_user(), llcache_object_user_destroy(), llcache_object_user::next, NSERROR_OK, llcache_handle::pw, and llcache_object_user::queued_for_delete.
Referenced by llcache_fetch_auth(), llcache_fetch_callback(), llcache_fetch_cert_error(), llcache_fetch_redirect(), llcache_fetch_ssl_error(), and llcache_fetch_timeout().
|
static |
Generate a serialised version of an object's metadata.
The metadata includes object headers.
object | The cache object to serialise the metadata of. |
data_out | Where the serialised buffer will be placed. |
datasize_out | The size of the serialised data. |
Definition at line 1322 of file llcache.c.
References llcache_object::cache, cert_chain::certs, llcache_object::chain, cert_chain::der, cert_chain::der_length, cert_chain::err, llcache_cache_control::fin_time, llcache_object::headers, llcache, llcache_header::name, nsc_sntimet(), NSERROR_INVALID, NSERROR_NOMEM, NSERROR_OK, NSLOG, nsurl_access(), nsurl_length(), llcache_object::num_headers, PRIsizet, llcache_cache_control::req_time, llcache_cache_control::res_time, llcache_object::source_len, llcache_object::url, and llcache_header::value.
Referenced by write_backing_store().
|
static |
Ask for llcache_catch_up_all_users to be scheduled ASAP to pump the user state machines.
Definition at line 3705 of file llcache.c.
References llcache_s::all_caught_up, guit, llcache, llcache_catch_up_all_users(), netsurf_table::misc, and gui_misc_table::schedule.
Referenced by llcache_fetch_callback(), llcache_handle_retrieve(), and llcache_object_notify_users().
|
inlinestatic |
total ram usage of object
object | The object to calculate the total RAM usage of. |
Definition at line 3646 of file llcache.c.
References cert_chain_size(), llcache_object::chain, llcache_object::headers, llcache_header::name, nsurl_length(), llcache_object::num_headers, llcache_object::source_data, llcache_object::url, and llcache_header::value.
Referenced by llcache_clean().
|
static |
Write an object to the backing store.
object | The object to put in the backing store. |
written_out | The amount of data written out. |
elapsed | The time in ms it took to complete the write to backing store. |
Definition at line 2839 of file llcache.c.
References BACKING_STORE_META, BACKING_STORE_NONE, guit, gui_llcache_table::invalidate, netsurf_table::llcache, llcache_serialise_metadata(), LLCACHE_STATE_DISC, NSERROR_OK, gui_llcache_table::release, llcache_object::source_data, llcache_object::source_len, gui_llcache_table::store, and llcache_object::url.
Referenced by llcache_persist().
|
static |
low level cache state
Definition at line 267 of file llcache.c.
Referenced by amiga_plugin_hack_create(), build_candidate_list(), content__init(), content_factory_create_content(), content_llcache_callback(), download_context_create(), gif_create(), html_create(), image_cache_snentryf(), javascript_create(), llcache_catch_up_all_users(), llcache_clean(), llcache_fetch_callback(), llcache_fetch_header_cache_control(), llcache_fetch_redirect(), llcache_finalise(), llcache_handle_abort(), llcache_handle_force_stream(), llcache_initialise(), llcache_object_add_user(), llcache_object_destroy(), llcache_object_fetch(), llcache_object_is_fresh(), llcache_object_new(), llcache_object_notify_users(), llcache_object_refetch(), llcache_object_remove_user(), llcache_object_retrieve(), llcache_object_retrieve_from_cache(), llcache_object_rfc2616_remaining_lifetime(), llcache_object_user_destroy(), llcache_object_user_new(), llcache_persist(), llcache_persist_slowcheck(), llcache_process_metadata(), llcache_serialise_metadata(), llcache_users_not_caught_up(), nsbmp_create(), nscss_create(), nsico_create(), nsjpeg_create(), nsjpegxl_create(), nspng_create(), nssprite_create(), nsvideo_create(), rsvg_create(), svg_create(), textplain_create(), and webp_create().