114 bool force_clean = (force_clean_flag != NULL);
126 if (force_clean ==
false)
128 NSLOG(netsurf, DEBUG,
"Forcing content cleanup during shutdown");
141 if (entry->
prev == NULL)
146 if (entry->
next != NULL)
178 *computed_type =
type;
180 return ((accepted_types &
type) != 0);
204 if (handle->
cb != NULL)
205 error = handle->
cb(handle, &event, handle->
pw);
208 NSLOG(netsurf, INFO,
"Error in callback: %d", error);
226 lwc_string *effective_type)
349 lwc_string *effective_type)
356 if ((effective_type != NULL) &&
434 lwc_string *effective_type = NULL;
437 assert(ctx->
llcache == handle);
439 switch (event->
type) {
462 if (effective_type != NULL)
463 lwc_string_unref(effective_type);
481 assert(0 &&
"MIME sniff failed with data");
486 lwc_string_unref(effective_type);
495 NULL, 0,
false,
false, &effective_type);
499 if (effective_type != NULL) {
500 lwc_string_unref(effective_type);
586 uint32_t num_contents, prev_contents;
592 entry != NULL; entry = entry->
next) {
596 NSLOG(netsurf, INFO,
"%"PRIu32
" contents remain before cache drain",
601 prev_contents = num_contents;
606 entry != NULL; entry = entry->
next) {
609 }
while (num_contents > 0 && num_contents != prev_contents);
611 NSLOG(netsurf, INFO,
"%"PRIu32
" contents remaining after being polite",
616 prev_contents = num_contents;
621 entry != NULL; entry = entry->
next) {
624 }
while (num_contents > 0 && num_contents != prev_contents);
626 NSLOG(netsurf, INFO,
"%"PRIu32
" contents remaining:", num_contents);
631 NSLOG(netsurf, INFO,
" %p : %s (%"PRIu32
" users)",
636 NSLOG(netsurf, INFO,
" %p", entry);
673 NSLOG(netsurf, INFO,
"Finalising low-level cache");
699 if (ctx->
handle == NULL) {
742 if (handle->
entry != NULL) {
749 if (ictx->handle == handle &&
750 ictx->migrate_target ==
false) {
758 free((
char *) ictx->child.charset);
778 if ((handle != NULL) && (handle->
entry != NULL)) {
800 if (ictx->handle == handle &&
801 ictx->migrate_target ==
false) {
809 free((
char *) ictx->child.charset);
846 handle->
entry = entry;
880 assert(handle != NULL);
882 if (handle->
entry != NULL) {
888 if (ictx->handle == handle) {
void content_destroy(struct content *c)
Destroy and free a content.
void content_remove_user(struct content *c, void(*callback)(struct content *c, content_msg msg, const union content_msg_data *data, void *pw), void *pw)
Remove a callback user.
uint32_t content_count_users(struct content *c)
Count users for the content.
bool content_is_shareable(struct content *c)
Determine if a content is shareable.
void content_set_error(struct content *c)
Put a content in status CONTENT_STATUS_ERROR and unlock the content.
content_status content__get_status(struct content *c)
Retrieve status of content.
nsurl * content_get_url(struct content *c)
Retrieve URL associated with content.
bool content_add_user(struct content *c, void(*callback)(struct content *c, content_msg msg, const union content_msg_data *data, void *pw), void *pw)
Register a user for callbacks.
struct content * content_clone(struct content *c)
Clone a content object in its current state.
bool content_matches_quirks(struct content *c, bool quirks)
Determine if quirks mode matches.
nserror content_abort(struct content *c)
Abort a content object.
const llcache_handle * content_get_llcache_handle(struct content *c)
Retrieve the low-level cache handle for a content.
content_status content_get_status(hlcache_handle *h)
Retrieve status of content.
content_type content_factory_type_from_mime_type(lwc_string *mime_type)
Compute the generic content type for a MIME type.
struct content * content_factory_create_content(llcache_handle *llcache, const char *fallback_charset, bool quirks, lwc_string *effective_type)
Create a content object.
Protected interface to Content handling.
content_status
Status of a content.
@ CONTENT_STATUS_READY
Some parts of content still being loaded, but can be displayed.
@ CONTENT_STATUS_DONE
Content has completed all processing.
@ CONTENT_STATUS_ERROR
Error occurred, content will be destroyed imminently.
@ CONTENT_STATUS_LOADING
Content is being fetched or converted and is not safe to display.
content_type
The type of a content.
@ CONTENT_IMAGE
All images.
@ CONTENT_NONE
no type for content
content_msg
Used in callbacks to indicate what has occurred.
@ CONTENT_MSG_DONE
content has finished processing
@ CONTENT_MSG_DOWNLOAD
download, not for display
@ CONTENT_MSG_LOADING
fetching or converting
@ CONTENT_MSG_ERROR
error occurred
@ CONTENT_MSG_REDIRECT
fetch url redirect occured
@ CONTENT_MSG_SSL_CERTS
Content is from SSL and this is its chain.
@ CONTENT_MSG_READY
may be displayed
nserror
Enumeration of error codes.
@ NSERROR_NOT_FOUND
Requested item not found.
@ NSERROR_NEED_DATA
More data needed.
@ NSERROR_UNKNOWN
Unknown error - DO NOT USE.
@ NSERROR_NOMEM
Memory exhaustion.
@ NSERROR_CLONE_FAILED
Failed to clone handle.
struct netsurf_table * guit
The global interface table.
Interface to core interface table.
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.
nserror hlcache_initialise(const struct hlcache_parameters *hlcache_parameters)
Initialise the high-level cache, preparing the llcache also.
static nserror hlcache_migrate_ctx(hlcache_retrieval_ctx *ctx, lwc_string *effective_type)
Migrate a retrieval context into its final destination content.
static void hlcache_clean(void *force_clean_flag)
Attempt to clean the cache.
struct content * hlcache_handle_get_content(const hlcache_handle *handle)
Retrieve a content object from a cache handle.
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.
nsurl * hlcache_handle_get_url(const hlcache_handle *handle)
void hlcache_finalise(void)
Finalise the high-level cache, destroying any remaining contents.
void hlcache_stop(void)
Stop the high-level cache periodic functionality so that the exit sequence can run.
static nserror hlcache_find_content(hlcache_retrieval_ctx *ctx, lwc_string *effective_type)
Find a content for the high-level cache handle.
static nserror hlcache_llcache_callback(llcache_handle *handle, const llcache_event *event, void *pw)
Handler for low-level cache events.
nserror hlcache_handle_abort(hlcache_handle *handle)
Abort a high-level cache fetch.
static struct hlcache_s * hlcache
high level cache state
nserror hlcache_handle_clone(hlcache_handle *handle, hlcache_handle **result)
Clone a high level cache handle.
nserror hlcache_handle_replace_callback(hlcache_handle *handle, hlcache_handle_callback cb, void *pw)
Replace a high-level cache handle's callback.
nserror hlcache_handle_release(hlcache_handle *handle)
Release a high-level cache handle.
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.
High-level resource cache interface.
nserror(* hlcache_handle_callback)(hlcache_handle *handle, const hlcache_event *event, void *pw)
Client callback for high-level cache events.
@ HLCACHE_RETRIEVE_SNIFF_TYPE
@ HLCACHE_RETRIEVE_MAY_DOWNLOAD
It's permitted to convert this request into a download.
HTTP header parsing functions.
Public content interface.
Interface to platform-specific miscellaneous browser operation table.
Netsurf additional integer type formatting macros.
nserror llcache_initialise(const struct llcache_parameters *prm)
Initialise the low-level cache.
void llcache_clean(bool purge)
Cause the low-level cache to attempt to perform cleanup.
nserror llcache_handle_abort(llcache_handle *handle)
Abort a low-level fetch, informing all users of this action.
void llcache_finalise(void)
Finalise the low-level cache.
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.
nsurl * llcache_handle_get_url(const llcache_handle *handle)
Retrieve the post-redirect URL of a low-level cache object.
const char * llcache_handle_get_header(const llcache_handle *handle, const char *key)
Retrieve a header value associated with a low-level cache object.
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.
nserror llcache_handle_force_stream(llcache_handle *handle)
Force a low-level cache handle into streaming mode.
nserror llcache_handle_release(llcache_handle *handle)
Release a low-level cache handle.
@ LLCACHE_EVENT_DONE
Finished fetching data.
@ LLCACHE_EVENT_ERROR
An error occurred during fetch.
@ LLCACHE_EVENT_GOT_CERTS
SSL certificates arrived.
@ LLCACHE_EVENT_REDIRECT
Fetch URL redirect occured.
@ LLCACHE_EVENT_PROGRESS
Fetch progress update.
@ LLCACHE_EVENT_HAD_HEADERS
Received all headers.
@ LLCACHE_EVENT_HAD_DATA
Received some data.
#define NSLOG(catname, level, logmsg, args...)
const char * messages_get(const char *key)
Fast lookup of a message by key from the standard Messages hash.
Localised message support (interface).
nserror mimesniff_compute_effective_type(const char *content_type_header, const uint8_t *data, size_t len, bool sniff_allowed, bool image_only, lwc_string **effective_type)
Compute the effective MIME type for an object.
MIME type sniffer interface.
const char * nsurl_access(const nsurl *url)
Access a NetSurf URL object as a string.
struct nsurl nsurl
NetSurf URL object.
#define RING_ITERATE_STOP(ring, iteratorptr)
#define RING_REMOVE(ring, element)
Remove the given element from the specified ring.
#define RING_INSERT(ring, element)
Insert the given item into the specified ring.
#define RING_ITERATE_END(ring, iteratorptr)
#define RING_ITERATE_START(ringtype, ring, iteratorptr)
Interface to utility string handling.
Content which corresponds to a single URL.
nserror(* schedule)(int t, void(*callback)(void *p), void *p)
Schedule a callback.
Context for retrieving a child object.
bool quirks
Whether parent is quirky.
const char * charset
Charset of parent.
Entry in high-level cache.
hlcache_entry * next
Next sibling.
hlcache_entry * prev
Previous sibling.
struct content * content
Pointer to associated content.
content_msg type
Event type.
union content_msg_data data
Event data.
hlcache_handle_callback cb
Client callback.
hlcache_entry * entry
Pointer to cache entry.
unsigned int bg_clean_time
How frequently the background cache clean process is run (ms)
struct llcache_parameters llcache
High-level cache retrieval context.
hlcache_child_context child
Child context.
llcache_handle * llcache
Low-level cache handle.
struct hlcache_retrieval_ctx * r_next
Next retrieval context in the ring.
bool migrate_target
Whether this context is the migration target.
struct hlcache_retrieval_ctx * r_prev
Previous retrieval context in the ring.
content_type accepted_types
Accepted types.
uint32_t flags
Retrieval flags.
hlcache_handle * handle
High-level handle for object.
Current state of the cache.
hlcache_retrieval_ctx * retrieval_ctx_ring
Ring of retrieval contexts.
struct hlcache_parameters params
hlcache_entry * content_list
List of cached content objects.
struct llcache_event::@124::@125 data
Received data.
size_t len
Byte length of buffer.
llcache_event_type type
Type of event.
const uint8_t * buf
Buffer of data.
Handle to low-level cache object.
POST data object for low-level cache requests.
struct gui_misc_table * misc
Browser table.
Extra data for some content_msg messages.
struct content_msg_data::@99 errordata
CONTENT_MSG_ERROR - Error from content or underlying fetch.
nserror errorcode
The error code to convey meaning.
const char * errormsg
The message.
const struct cert_chain * chain
CONTENT_MSG_SSL_CERTS - The certificate chain from the underlying fetch.
struct nsurl * to
Redirect target.
struct nsurl * from
Redirect origin.
struct llcache_handle * download
CONTENT_MSG_DOWNLOAD - Low-level cache handle.
struct content_msg_data::@100 redirect
CONTENT_MSG_REDIRECT - Redirect info.
Interface to a number of general purpose functionality.