Author: jmb
Date: Sat Oct 10 07:00:49 2009
New Revision: 9618
URL:
http://source.netsurf-browser.org?rev=9618&view=rev
Log:
Indirect access to cache objects through a handle.
Introduce llcache_poll()
Various constification changes.
Modified:
branches/jmb/new-cache/content/llcache.h
Modified: branches/jmb/new-cache/content/llcache.h
URL:
http://source.netsurf-browser.org/branches/jmb/new-cache/content/llcache....
==============================================================================
--- branches/jmb/new-cache/content/llcache.h (original)
+++ branches/jmb/new-cache/content/llcache.h Sat Oct 10 07:00:49 2009
@@ -34,6 +34,9 @@
/** Type of low-level cache object */
typedef struct llcache_object llcache_object;
+
+/** Handle for low-level cache object */
+typedef struct llcache_handle llcache_handle;
/** POST data object for low-level cache requests */
typedef struct {
@@ -67,18 +70,19 @@
/**
* Client callback for low-level cache events
*
- * \param object Object for which event is issued
+ * \param handle Handle for which event is issued
* \param event Event data
* \param pw Pointer to client-specific data
* \return NSERROR_OK on success, appropriate error otherwise.
*/
-typedef nserror (*llcache_object_callback)(llcache_object *object,
- llcache_event *event, void *pw);
+typedef nserror (*llcache_handle_callback)(const llcache_handle *handle,
+ const llcache_event *event, void *pw);
/** Flags for low-level cache object retrieval */
#define LLCACHE_RETRIEVE_FORCE_FETCH (1 << 0) /* Force a new fetch */
#define LLCACHE_RETRIEVE_VERIFIABLE (1 << 1) /* Requested URL was verified */
#define LLCACHE_RETRIEVE_SNIFF_TYPE (1 << 2) /* Permit content-type sniffing */
+#define LLCACHE_RETRIEVE_NO_ERROR_PAGES (1 << 3) /* No error pages */
/** Low-level cache query types */
typedef enum {
@@ -131,7 +135,7 @@
* the query has been obtained, the provided response callback should be
* called. This is intended to be an entirely asynchronous process.
*/
-typedef nserror (*llcache_query_callback)(llcache_query *query, void *pw,
+typedef nserror (*llcache_query_callback)(const llcache_query *query, void *pw,
llcache_query_response cb, void *cbpw);
/**
@@ -144,7 +148,14 @@
nserror llcache_initialise(llcache_query_callback cb, void *pw);
/**
- * Retrieve a low-level cache object
+ * Poll the low-level cache
+ *
+ * \return NSERROR_OK on success, appropriate error otherwise.
+ */
+nserror llcache_poll(void);
+
+/**
+ * Retrieve a handle for a low-level cache object
*
* \param url URL of the object to fetch
* \param flags Object retrieval flags
@@ -152,24 +163,29 @@
* \param post POST data, or NULL for a GET request
* \param cb Client callback for events
* \param pw Pointer to client-specific data
- * \param result Pointer to location to recieve cache object
- * \return NSERROR_OK on success, appropriate error otherwise
- */
-nserror llcache_object_retrieve(const char *url, uint32_t flags,
- const char *referer, llcache_post_data *post,
- llcache_object_callback cb, void *pw,
- llcache_object **result);
-
-/**
- * Remove a callback from a low-level cache object
- *
- * \param object Object to remove callback from
- * \param cb Callback to remove
- * \param pw Pointer to client-specific data
- * \return NSERROR_OK on success, appropriate error otherwise
- */
-nserror llcache_object_remove_callback(llcache_object *object,
- llcache_object_callback cb, void *pw);
+ * \param result Pointer to location to recieve cache handle
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
+nserror llcache_handle_retrieve(const char *url, uint32_t flags,
+ const char *referer, const llcache_post_data *post,
+ llcache_handle_callback cb, void *pw,
+ llcache_handle **result);
+
+/**
+ * Release a low-level cache handle
+ *
+ * \param handle Handle to release
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
+nserror llcache_handle_release(llcache_handle *handle);
+
+/**
+ * Retrieve the low-level cache object associated with a handle
+ *
+ * \param handle Handle to dereference
+ * \return Pointer to low-level cache object
+ */
+const llcache_object *llcache_object_from_handle(const llcache_handle *handle);
/**
* Retrieve the post-redirect URL of a low-level cache object
@@ -177,7 +193,7 @@
* \param object Object to retrieve URL from
* \return Post-redirect URL of cache object
*/
-const char *llcache_object_get_url(llcache_object *object);
+const char *llcache_object_get_url(const llcache_object *object);
/**
* Retrieve a header value associated with a low-level cache object
@@ -191,6 +207,7 @@
* Better would be to return the actual value part and an array of
* key-value pairs for any additional parameters.
*/
-const char *llcache_object_get_header(llcache_object *object, const char *key);
+const char *llcache_object_get_header(const llcache_object *object,
+ const char *key);
#endif