summaryrefslogtreecommitdiff
path: root/content
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2019-08-05 20:56:07 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2019-08-05 20:56:07 +0100
commit170dc5d52419450edc440c054a94135c1cc1296a (patch)
tree0943167d6fa71716bd1cd8936b94cfd02fe10e5c /content
parentbfb1bb119241d85bb9b400881328496e12a39aed (diff)
downloadnetsurf-170dc5d52419450edc440c054a94135c1cc1296a.tar.gz
netsurf-170dc5d52419450edc440c054a94135c1cc1296a.tar.bz2
Excise the llcache query pathway.
In further preparation for the auth and cert queries being handled as special contents from `about:` this excises the query pathway from the llcache pretty much entirely. Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
Diffstat (limited to 'content')
-rw-r--r--content/content.c13
-rw-r--r--content/content.h6
-rw-r--r--content/handlers/css/css.c8
-rw-r--r--content/handlers/html/html_css.c10
-rw-r--r--content/handlers/html/html_object.c10
-rw-r--r--content/handlers/html/html_script.c30
-rw-r--r--content/hlcache.c26
-rw-r--r--content/llcache.c113
-rw-r--r--content/llcache.h76
9 files changed, 34 insertions, 258 deletions
diff --git a/content/content.c b/content/content.c
index dc9805448..385847daf 100644
--- a/content/content.c
+++ b/content/content.c
@@ -176,12 +176,12 @@ nserror content_llcache_callback(llcache_handle *llcache,
case LLCACHE_EVENT_ERROR:
/** \todo Error page? */
c->status = CONTENT_STATUS_ERROR;
- msg_data.errordata.errorcode = NSERROR_UNKNOWN;
- msg_data.errordata.errormsg = event->data.msg;
+ msg_data.errordata.errorcode = event->data.error.code;
+ msg_data.errordata.errormsg = event->data.error.msg;
content_broadcast(c, CONTENT_MSG_ERROR, &msg_data);
break;
case LLCACHE_EVENT_PROGRESS:
- content_set_status(c, event->data.msg);
+ content_set_status(c, event->data.progress_msg);
msg_data.explicit_status_text = NULL;
content_broadcast(c, CONTENT_MSG_STATUS, &msg_data);
break;
@@ -190,13 +190,6 @@ nserror content_llcache_callback(llcache_handle *llcache,
msg_data.redirect.to = event->data.redirect.to;
content_broadcast(c, CONTENT_MSG_REDIRECT, &msg_data);
break;
- case LLCACHE_EVENT_QUERY:
- case LLCACHE_EVENT_QUERY_FINISHED:
- /* Should never happen, because the object can't query once
- * it has fetched enough that a migration to content happened.
- */
- NSLOG(netsurf, DEBUG, "Encountered query related events during content handling");
- break;
}
return error;
diff --git a/content/content.h b/content/content.h
index 6e298e045..a5bf46c61 100644
--- a/content/content.h
+++ b/content/content.h
@@ -61,8 +61,6 @@ typedef enum {
typedef enum {
CONTENT_MSG_LOG, /**< Content wishes to log something */
CONTENT_MSG_SSL_CERTS, /**< Content is from SSL and this is its chain */
- CONTENT_MSG_QUERY, /**< Something under the content has a query */
- CONTENT_MSG_QUERY_FINISHED, /**< Something under the content finished its query */
CONTENT_MSG_LOADING, /**< fetching or converting */
CONTENT_MSG_READY, /**< may be displayed */
CONTENT_MSG_DONE, /**< finished */
@@ -114,10 +112,6 @@ union content_msg_data {
const struct ssl_cert_info *certs; /**< The chain */
size_t num; /**< The number of certs in the chain */
} certs;
- /** CONTENT_MSG_QUERY - Query from underlying object somewhere */
- const struct llcache_query_msg *query_msg;
- /** CONTENT_MSG_QUERY_FINISHED - Query from underlying object finished */
- void *query_finished_pw;
/** CONTENT_MSG_ERROR - Error from content or underlying fetch */
struct {
nserror errorcode; /**< The error code to convey meaning */
diff --git a/content/handlers/css/css.c b/content/handlers/css/css.c
index 0ca47a2b6..af2a9bc88 100644
--- a/content/handlers/css/css.c
+++ b/content/handlers/css/css.c
@@ -641,14 +641,6 @@ nserror nscss_import(hlcache_handle *handle,
error = nscss_import_complete(ctx);
/* Already released handle */
break;
- case CONTENT_MSG_QUERY:
- /** \todo QUERY - Decide what is right here */
- /* For now, the only safe decision is to cancel the fetch */
- event->data.query_msg->cb(false, event->data.query_msg->cb_pw);
- break;
- case CONTENT_MSG_QUERY_FINISHED:
- /** \todo QUERY - Decide what is right here */
- break;
default:
break;
}
diff --git a/content/handlers/html/html_css.c b/content/handlers/html/html_css.c
index 37a70fa70..eb80c0e71 100644
--- a/content/handlers/html/html_css.c
+++ b/content/handlers/html/html_css.c
@@ -129,16 +129,6 @@ html_convert_css_callback(hlcache_handle *css,
/* Really don't want this to continue after the switch */
return NSERROR_OK;
- case CONTENT_MSG_QUERY:
- /** \todo QUERY - Decide what is right here */
- /* For now, the only safe decision is to cancel the fetch */
- event->data.query_msg->cb(false, event->data.query_msg->cb_pw);
- return NSERROR_OK;
-
- case CONTENT_MSG_QUERY_FINISHED:
- /** \todo QUERY - Decide what is right here */
- return NSERROR_OK;
-
default:
break;
}
diff --git a/content/handlers/html/html_object.c b/content/handlers/html/html_object.c
index dc8524499..acd32565b 100644
--- a/content/handlers/html/html_object.c
+++ b/content/handlers/html/html_object.c
@@ -451,16 +451,6 @@ html_object_callback(hlcache_handle *object,
}
break;
- case CONTENT_MSG_QUERY:
- /** \todo QUERY - Decide what is right here */
- /* For now, the only safe decision is to cancel the fetch */
- event->data.query_msg->cb(false, event->data.query_msg->cb_pw);
- return NSERROR_OK;
-
- case CONTENT_MSG_QUERY_FINISHED:
- /** \todo QUERY - Decide what is right here */
- return NSERROR_OK;
-
default:
break;
}
diff --git a/content/handlers/html/html_script.c b/content/handlers/html/html_script.c
index 6e037251c..f7131e2a2 100644
--- a/content/handlers/html/html_script.c
+++ b/content/handlers/html/html_script.c
@@ -193,16 +193,6 @@ convert_script_async_cb(hlcache_handle *script,
break;
- case CONTENT_MSG_QUERY:
- /** \todo QUERY - Decide what is right here */
- /* For now, the only safe decision is to cancel the fetch */
- event->data.query_msg->cb(false, event->data.query_msg->cb_pw);
- return NSERROR_OK;
-
- case CONTENT_MSG_QUERY_FINISHED:
- /** \todo QUERY - Decide what is right here */
- return NSERROR_OK;
-
default:
break;
}
@@ -267,16 +257,6 @@ convert_script_defer_cb(hlcache_handle *script,
break;
- case CONTENT_MSG_QUERY:
- /** \todo QUERY - Decide what is right here */
- /* For now, the only safe decision is to cancel the fetch */
- event->data.query_msg->cb(false, event->data.query_msg->cb_pw);
- return NSERROR_OK;
-
- case CONTENT_MSG_QUERY_FINISHED:
- /** \todo QUERY - Decide what is right here */
- return NSERROR_OK;
-
default:
break;
}
@@ -367,16 +347,6 @@ convert_script_sync_cb(hlcache_handle *script,
break;
- case CONTENT_MSG_QUERY:
- /** \todo QUERY - Decide what is right here */
- /* For now, the only safe decision is to cancel the fetch */
- event->data.query_msg->cb(false, event->data.query_msg->cb_pw);
- return NSERROR_OK;
-
- case CONTENT_MSG_QUERY_FINISHED:
- /** \todo QUERY - Decide what is right here */
- return NSERROR_OK;
-
default:
break;
}
diff --git a/content/hlcache.c b/content/hlcache.c
index d2b612d05..aa782b2e1 100644
--- a/content/hlcache.c
+++ b/content/hlcache.c
@@ -515,8 +515,8 @@ static nserror hlcache_llcache_callback(llcache_handle *handle,
hlcache_event hlevent;
hlevent.type = CONTENT_MSG_ERROR;
- hlevent.data.errordata.errorcode = NSERROR_UNKNOWN;
- hlevent.data.errordata.errormsg = event->data.msg;
+ hlevent.data.errordata.errorcode = event->data.error.code;
+ hlevent.data.errordata.errormsg = event->data.error.msg;
ctx->handle->cb(ctx->handle, &hlevent, ctx->handle->pw);
}
@@ -534,28 +534,6 @@ static nserror hlcache_llcache_callback(llcache_handle *handle,
ctx->handle->cb(ctx->handle, &hlevent, ctx->handle->pw);
}
break;
- case LLCACHE_EVENT_QUERY:
- if (ctx->handle->cb != NULL) {
- hlcache_event hlevent;
-
- hlevent.type = CONTENT_MSG_QUERY;
- hlevent.data.query_msg = &event->data.query;
-
- ctx->handle->cb(ctx->handle, &hlevent, ctx->handle->pw);
- } else {
- return NSERROR_NOT_IMPLEMENTED;
- }
- break;
- case LLCACHE_EVENT_QUERY_FINISHED:
- if (ctx->handle->cb != NULL) {
- hlcache_event hlevent;
-
- hlevent.type = CONTENT_MSG_QUERY_FINISHED;
- hlevent.data.query_finished_pw = event->data.query.cb_pw;
-
- ctx->handle->cb(ctx->handle, &hlevent, ctx->handle->pw);
- }
- break;
}
return NSERROR_OK;
diff --git a/content/llcache.c b/content/llcache.c
index b0f22b7fa..07533f15e 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -116,8 +116,6 @@ typedef struct {
bool tried_with_tls_downgrade; /**< Whether we've tried TLS <= 1.0 */
- bool outstanding_query; /**< Waiting for a query response */
-
bool tainted_tls; /**< Whether the TLS transport is tainted */
} llcache_fetch_ctx;
@@ -2004,7 +2002,8 @@ static nserror llcache_fetch_redirect(llcache_object *object,
NSLOG(llcache, INFO, "Too many nested redirects");
event.type = LLCACHE_EVENT_ERROR;
- event.data.msg = messages_get("BadRedirect");
+ event.data.error.code = NSERROR_BAD_REDIRECT;
+ event.data.error.msg = messages_get("BadRedirect");
return llcache_send_event_to_users(object, &event);
}
@@ -2249,46 +2248,6 @@ llcache_fetch_process_data(llcache_object *object,
return NSERROR_OK;
}
-/**
- * Handle a query response
- *
- * \param proceed Whether to proceed with fetch
- * \param cbpw Our context for query
- * \return NSERROR_OK on success, appropriate error otherwise
- */
-static nserror llcache_query_handle_response(bool proceed, void *cbpw)
-{
- llcache_event event;
- llcache_object *object = cbpw;
-
- if (object->fetch.outstanding_query == false) {
- /* This object has already had its query answered */
- return NSERROR_OK;
- }
-
- object->fetch.outstanding_query = false;
-
- /* Tell all the users that we're leaving query state */
- event.type = LLCACHE_EVENT_QUERY_FINISHED;
- event.data.query.cb_pw = object;
-
- /* Refetch, using existing fetch parameters, if client allows us to */
- if (llcache_send_event_to_users(object, &event) == NSERROR_OK && proceed)
- return llcache_object_refetch(object);
-
- /* Invalidate cache-control data */
- llcache_invalidate_cache_control_data(object);
-
- /* Mark it complete */
- object->fetch.state = LLCACHE_FETCH_COMPLETE;
-
- /* Inform client(s) that object fetch failed */
- event.type = LLCACHE_EVENT_ERROR;
- /** \todo More appropriate error message */
- event.data.msg = messages_get("FetchFailed");
-
- return llcache_send_event_to_users(object, &event);
-}
/**
* Handle an authentication request
@@ -2320,32 +2279,20 @@ static nserror llcache_fetch_auth(llcache_object *object, const char *realm)
auth = urldb_get_auth_details(object->url, realm);
if (auth == NULL || object->fetch.tried_with_auth == true) {
- llcache_query query;
llcache_event event;
-
/* No authentication details, or tried what we had, so ask */
object->fetch.tried_with_auth = false;
- /* Emit query for authentication details */
- query.type = LLCACHE_QUERY_AUTH;
- query.url = object->url;
- query.data.auth.realm = realm;
-
- /* Construct the query event */
- event.type = LLCACHE_EVENT_QUERY;
- event.data.query.query = &query;
- event.data.query.cb = llcache_query_handle_response;
- event.data.query.cb_pw = object;
+ /* Mark object complete */
+ object->fetch.state = LLCACHE_FETCH_COMPLETE;
- object->fetch.outstanding_query = true;
+ /* Inform client(s) that object fetch failed */
+ event.type = LLCACHE_EVENT_ERROR;
+ /** \todo More appropriate error message */
+ event.data.error.code = NSERROR_BAD_AUTH;
+ event.data.error.msg = messages_get("FetchFailed");
error = llcache_send_event_to_users(object, &event);
-
- if (error != NSERROR_OK) {
- /* do not continue if error querying user */
- error = llcache_query_handle_response(false,
- object);
- }
} else {
/* Flag that we've tried to refetch with credentials, so
* that if the fetch fails again, we ask the user again */
@@ -2377,27 +2324,18 @@ static nserror llcache_fetch_cert_error(llcache_object *object)
/* Only give the user a chance if HSTS isn't in use for this fetch */
if (object->fetch.hsts_in_use == false) {
- llcache_query query;
llcache_event event;
- /* Emit query for TLS */
- query.type = LLCACHE_QUERY_SSL;
- query.url = object->url;
-
- /* Construct the query event */
- event.type = LLCACHE_EVENT_QUERY;
- event.data.query.query = &query;
- event.data.query.cb = llcache_query_handle_response;
- event.data.query.cb_pw = object;
+ /* Mark object complete */
+ object->fetch.state = LLCACHE_FETCH_COMPLETE;
- object->fetch.outstanding_query = true;
+ /* Inform client(s) that object fetch failed */
+ event.type = LLCACHE_EVENT_ERROR;
+ /** \todo More appropriate error message */
+ event.data.error.code = NSERROR_BAD_CERTS;
+ event.data.error.msg = messages_get("FetchFailed");
error = llcache_send_event_to_users(object, &event);
-
- if (error != NSERROR_OK) {
- /* do not continue if error querying user */
- error = llcache_query_handle_response(false, object);
- }
} else {
llcache_event event;
@@ -2407,7 +2345,8 @@ static nserror llcache_fetch_cert_error(llcache_object *object)
/* Inform client(s) that object fetch failed */
event.type = LLCACHE_EVENT_ERROR;
/** \todo More appropriate error message */
- event.data.msg = messages_get("FetchFailed");
+ event.data.error.code = NSERROR_UNKNOWN;
+ event.data.error.msg = messages_get("FetchFailed");
error = llcache_send_event_to_users(object, &event);
}
@@ -2447,7 +2386,8 @@ static nserror llcache_fetch_ssl_error(llcache_object *object)
/* Inform client(s) that object fetch failed */
event.type = LLCACHE_EVENT_ERROR;
/** \todo More appropriate error message */
- event.data.msg = messages_get("FetchFailed");
+ event.data.error.code = NSERROR_UNKNOWN;
+ event.data.error.msg = messages_get("FetchFailed");
error = llcache_send_event_to_users(object, &event);
} else {
@@ -2502,7 +2442,6 @@ build_candidate_list(struct llcache_object ***lst_out, int *lst_len_out)
*/
if ((object->candidate_count == 0) &&
(object->fetch.fetch == NULL) &&
- (object->fetch.outstanding_query == false) &&
(object->store_state == LLCACHE_STATE_RAM) &&
(remaining_lifetime > llcache->minimum_lifetime)) {
lst[lst_len] = object;
@@ -2862,7 +2801,8 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p)
/** \todo Consider using errorcode for something */
event.type = LLCACHE_EVENT_ERROR;
- event.data.msg = msg->data.error;
+ event.data.error.code = NSERROR_UNKNOWN;
+ event.data.error.msg = msg->data.error;
error = llcache_send_event_to_users(object, &event);
@@ -2870,7 +2810,7 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p)
case FETCH_PROGRESS:
/* Progress update */
event.type = LLCACHE_EVENT_PROGRESS;
- event.data.msg = msg->data.progress;
+ event.data.progress_msg = msg->data.progress;
error = llcache_send_event_to_users(object, &event);
@@ -3349,8 +3289,7 @@ void llcache_clean(bool purge)
/* The candidate count of uncacheable objects is always 0 */
if ((object->users == NULL) &&
(object->candidate_count == 0) &&
- (object->fetch.fetch == NULL) &&
- (object->fetch.outstanding_query == false)) {
+ (object->fetch.fetch == NULL)) {
NSLOG(llcache, DEBUG, "Discarding uncachable object with no users (%p) %s",
object, nsurl_access(object->url));
@@ -3375,7 +3314,6 @@ void llcache_clean(bool purge)
if ((object->users == NULL) &&
(object->candidate_count == 0) &&
(object->fetch.fetch == NULL) &&
- (object->fetch.outstanding_query == false) &&
(remaining_lifetime <= 0)) {
/* object is stale */
NSLOG(llcache, DEBUG, "discarding stale cacheable object with no "
@@ -3416,7 +3354,6 @@ void llcache_clean(bool purge)
if ((object->users == NULL) &&
(object->candidate_count == 0) &&
(object->fetch.fetch == NULL) &&
- (object->fetch.outstanding_query == false) &&
(object->store_state == LLCACHE_STATE_DISC)) {
guit->llcache->release(object->url, BACKING_STORE_NONE);
@@ -3441,7 +3378,6 @@ void llcache_clean(bool purge)
if ((object->users == NULL) &&
(object->candidate_count == 0) &&
(object->fetch.fetch == NULL) &&
- (object->fetch.outstanding_query == false) &&
(object->store_state == LLCACHE_STATE_DISC) &&
(object->source_data == NULL)) {
NSLOG(llcache, DEBUG,
@@ -3473,7 +3409,6 @@ void llcache_clean(bool purge)
if ((object->users == NULL) &&
(object->candidate_count == 0) &&
(object->fetch.fetch == NULL) &&
- (object->fetch.outstanding_query == false) &&
(object->store_state == LLCACHE_STATE_RAM)) {
NSLOG(llcache, DEBUG,
"discarding fresh object len:%"PRIssizet" age:%ld (%p) %s",
diff --git a/content/llcache.h b/content/llcache.h
index b2577a6c1..8d2411e0a 100644
--- a/content/llcache.h
+++ b/content/llcache.h
@@ -63,44 +63,6 @@ enum llcache_retrieve_flag {
LLCACHE_RETRIEVE_STREAM_DATA = (1 << 3)
};
-/** Low-level cache query types */
-typedef enum {
- LLCACHE_QUERY_AUTH, /**< Need authentication details */
- LLCACHE_QUERY_REDIRECT, /**< Need permission to redirect */
- LLCACHE_QUERY_SSL /**< SSL chain needs inspection */
-} llcache_query_type;
-
-/** Low-level cache query */
-typedef struct {
- llcache_query_type type; /**< Type of query */
-
- nsurl *url; /**< URL being fetched */
-
- union {
- struct {
- const char *realm; /**< Authentication realm */
- } auth;
-
- struct {
- const char *target; /**< Redirect target */
- } redirect;
-
- struct {
- const struct ssl_cert_info *certs;
- size_t num; /**< Number of certs in chain */
- } ssl;
- } data;
-} llcache_query;
-
-/**
- * Response handler for fetch-related queries
- *
- * \param proceed Whether to proceed with the fetch or not
- * \param cbpw Opaque value provided to llcache_query_callback
- * \return NSERROR_OK on success, appropriate error otherwise
- */
-typedef nserror (*llcache_query_response)(bool proceed, void *cbpw);
-
/** Low-level cache event types */
typedef enum {
LLCACHE_EVENT_GOT_CERTS, /**< SSL certificates arrived */
@@ -111,22 +73,10 @@ typedef enum {
LLCACHE_EVENT_ERROR, /**< An error occurred during fetch */
LLCACHE_EVENT_PROGRESS, /**< Fetch progress update */
- LLCACHE_EVENT_QUERY, /**< Fetch has a query and is paused */
- LLCACHE_EVENT_QUERY_FINISHED, /**< Fetch had a query, but it is now finished */
-
LLCACHE_EVENT_REDIRECT /**< Fetch URL redirect occured */
} llcache_event_type;
/**
- * Low-level cache query message
- */
-typedef struct llcache_query_msg {
- llcache_query *query; /**< Query information */
- llcache_query_response cb; /**< Response callback */
- void *cb_pw; /**< Response callback private word */
-} llcache_query_msg;
-
-/**
* Low-level cache events.
*
* Lifetime of contained information is only for the duration of the event
@@ -139,7 +89,11 @@ typedef struct {
const uint8_t *buf; /**< Buffer of data */
size_t len; /**< Length of buffer, in bytes */
} data; /**< Received data */
- const char *msg; /**< Error or progress message */
+ struct {
+ nserror code; /**< The error code */
+ const char *msg; /**< Error message */
+ } error;
+ const char *progress_msg; /**< Progress message */
struct {
nsurl *from; /**< Redirect origin */
nsurl *to; /**< Redirect target */
@@ -148,7 +102,6 @@ typedef struct {
const struct ssl_cert_info *certs; /**< The chain */
size_t num; /**< Number of certs in chain */
} certs;
- llcache_query_msg query;/**< Query event */
} data; /**< Event data */
} llcache_event;
@@ -164,22 +117,6 @@ typedef nserror (*llcache_handle_callback)(llcache_handle *handle,
const llcache_event *event, void *pw);
/**
- * Callback to handle fetch-related queries
- *
- * \param query Object containing details of query
- * \param pw Pointer to callback-specific data
- * \param cb Callback that client should call once query is satisfied
- * \param cbpw Opaque value to pass into \a cb
- * \return NSERROR_OK on success, appropriate error otherwise
- *
- * \note This callback should return immediately. Once a suitable answer to
- * 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)(const llcache_query *query, void *pw,
- llcache_query_response cb, void *cbpw);
-
-/**
* Parameters to configure the low level cache backing store.
*/
struct llcache_store_parameters {
@@ -230,9 +167,6 @@ struct llcache_store_parameters {
* Parameters to configure the low level cache.
*/
struct llcache_parameters {
- llcache_query_callback cb; /**< Query handler for llcache */
- void *cb_ctx; /**< Pointer to llcache query handler data */
-
size_t limit; /**< The target upper bound for the RAM cache size */
size_t hysteresis; /**< The hysteresis around the target size */