NetSurf
Data Structures | Typedefs | Enumerations | Functions
hlcache.h File Reference

High-level resource cache interface. More...

#include "utils/errors.h"
#include "utils/nsurl.h"
#include "content/content.h"
#include "content/llcache.h"
Include dependency graph for hlcache.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  hlcache_child_context
 Context for retrieving a child object. More...
 
struct  hlcache_event
 High-level cache event. More...
 
struct  hlcache_parameters
 

Typedefs

typedef struct hlcache_handle hlcache_handle
 High-level cache handle. More...
 
typedef struct hlcache_child_context hlcache_child_context
 Context for retrieving a child object. More...
 
typedef struct hlcache_event hlcache_event
 High-level cache event. More...
 
typedef nserror(* hlcache_handle_callback) (hlcache_handle *handle, const hlcache_event *event, void *pw)
 Client callback for high-level cache events. More...
 

Enumerations

enum  hlcache_retrieve_flag { HLCACHE_RETRIEVE_MAY_DOWNLOAD = (1 << 31) , HLCACHE_RETRIEVE_SNIFF_TYPE = (1 << 30) }
 Flags for high-level cache object retrieval. More...
 

Functions

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...
 
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...
 
struct contenthlcache_handle_get_content (const hlcache_handle *handle)
 Retrieve a content object from a cache handle. More...
 
nserror hlcache_handle_clone (hlcache_handle *handle, hlcache_handle **result)
 Clone a high level cache handle. More...
 

Detailed Description

High-level resource cache interface.

Definition in file hlcache.h.

Typedef Documentation

◆ hlcache_child_context

Context for retrieving a child object.

◆ hlcache_event

typedef struct hlcache_event hlcache_event

High-level cache event.

◆ hlcache_handle

High-level cache handle.

Definition at line 34 of file hlcache.h.

◆ hlcache_handle_callback

typedef nserror(* hlcache_handle_callback) (hlcache_handle *handle, const hlcache_event *event, void *pw)

Client callback for high-level cache events.

Parameters
handleHandle to object generating event
eventEvent data
pwPointer to client-specific data
Returns
NSERROR_OK on success, appropriate error otherwise.

Definition at line 63 of file hlcache.h.

Enumeration Type Documentation

◆ hlcache_retrieve_flag

Flags for high-level cache object retrieval.

Enumerator
HLCACHE_RETRIEVE_MAY_DOWNLOAD 

It's permitted to convert this request into a download.

HLCACHE_RETRIEVE_SNIFF_TYPE 

Definition at line 67 of file hlcache.h.

Function Documentation

◆ hlcache_finalise()

void hlcache_finalise ( void  )

Finalise the high-level cache, destroying any remaining contents.

Definition at line 584 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hlcache_handle_abort()

nserror hlcache_handle_abort ( hlcache_handle handle)

Abort a high-level cache fetch.

Parameters
handleHandle to abort
Returns
NSERROR_OK on success, appropriate error otherwise

Definition at line 786 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hlcache_handle_clone()

nserror hlcache_handle_clone ( hlcache_handle handle,
hlcache_handle **  result 
)

Clone a high level cache handle.

Parameters
handleThe handle to clone.
resultThe cloned handle.
Returns
NSERROR_OK on success, appropriate error otherwise

Definition at line 869 of file hlcache.c.

References NSERROR_CLONE_FAILED, and result.

Referenced by print_init().

Here is the caller graph for this function:

◆ hlcache_handle_get_content()

struct content * hlcache_handle_get_content ( const hlcache_handle handle)

Retrieve a content object from a cache handle.

Parameters
handleCache handle to dereference
Returns
Pointer to content object, or NULL if there is none
Todo:
This may not be correct. Ideally, the client should never need to directly access a content object. It may, therefore, be better to provide a bunch of veneers here that take a hlcache_handle and invoke the corresponding content_ API. If there's no content object associated with the hlcache_handle (e.g. because the source data is still being fetched, so it doesn't exist yet), then these veneers would behave as a NOP. The important thing being that the client need not care about this possibility and can just call the functions with impugnity.

Definition at line 776 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().

Here is the caller graph for this function:

◆ hlcache_handle_release()

nserror hlcache_handle_release ( hlcache_handle handle)

Release a high-level cache handle.

Parameters
handleHandle to release
Returns
NSERROR_OK on success, appropriate error otherwise

Definition at line 740 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hlcache_handle_replace_callback()

nserror hlcache_handle_replace_callback ( hlcache_handle handle,
hlcache_handle_callback  cb,
void *  pw 
)

Replace a high-level cache handle's callback.

Parameters
handleHandle to replace callback of
cbNew callback routine
pwPrivate data for callback
Returns
NSERROR_OK on success, appropriate error otherwise

Definition at line 860 of file hlcache.c.

References hlcache_handle::cb, NSERROR_OK, and hlcache_handle::pw.

Referenced by theme_install_start().

Here is the caller graph for this function:

◆ hlcache_handle_retrieve()

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.

Parameters
urlURL of the object to retrieve handle for
flagsObject retrieval flags
refererReferring URL, or NULL if none
postPOST data, or NULL for a GET request
cbCallback to handle object events
pwPointer to client-specific data for callback
childChild retrieval context, or NULL for top-level content
accepted_typesBitmap of acceptable content types
resultPointer to location to recieve cache handle
Returns
NSERROR_OK on success, appropriate error otherwise

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.

Todo:
The above rules should be encoded in the handler_map.
Todo:
Is there any way to sensibly reduce the number of parameters here?

Definition at line 679 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hlcache_initialise()

nserror hlcache_initialise ( const struct hlcache_parameters hlcache_parameters)

Initialise the high-level cache, preparing the llcache also.

Parameters
hlcache_parametersSettings to initialise cache with
Returns
NSERROR_OK on success, appropriate error otherwise.

Definition at line 552 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hlcache_stop()

void hlcache_stop ( void  )

Stop the high-level cache periodic functionality so that the exit sequence can run.

Definition at line 577 of file hlcache.c.

References guit, hlcache_clean(), netsurf_table::misc, and gui_misc_table::schedule.

Referenced by netsurf_exit().

Here is the call graph for this function:
Here is the caller graph for this function: