summaryrefslogtreecommitdiffstats
path: root/chrome/browser/renderer_host
diff options
context:
space:
mode:
authormichaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-16 21:05:47 +0000
committermichaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-16 21:05:47 +0000
commita5c713fdc8d0bf21f65ebdae95827e423d14b07c (patch)
tree82e553e97f38aa159978805e415fa683189201e0 /chrome/browser/renderer_host
parent2cb1ecb7aa5b6bf5c17cfaa75293121c8bd73130 (diff)
downloadchromium_src-a5c713fdc8d0bf21f65ebdae95827e423d14b07c.zip
chromium_src-a5c713fdc8d0bf21f65ebdae95827e423d14b07c.tar.gz
chromium_src-a5c713fdc8d0bf21f65ebdae95827e423d14b07c.tar.bz2
URLRequest::Interceptor enhancements1) Allow an interceptor to change its mind and not intercept after all. This allows the decision to start or not to start to be made asynchronously.2) Allow an interceptor to intercept on error conditions if the original job fails. This is to support the FALLBACK semantics in the appcache.Info about where this is going can be found in the appcache design doc at https://docs.google.com/a/google.com/Doc?docid=agv6ghfsqr_15f749cgt3&hl=enI still have to put together test cases, so I'm not ready to submit this yet, but wanted to get some feedback at this point.
Review URL: http://codereview.chromium.org/67019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13877 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host')
-rw-r--r--chrome/browser/renderer_host/resource_dispatcher_host.cc6
-rw-r--r--chrome/browser/renderer_host/resource_dispatcher_host.h21
2 files changed, 16 insertions, 11 deletions
diff --git a/chrome/browser/renderer_host/resource_dispatcher_host.cc b/chrome/browser/renderer_host/resource_dispatcher_host.cc
index f73d507..db852b4 100644
--- a/chrome/browser/renderer_host/resource_dispatcher_host.cc
+++ b/chrome/browser/renderer_host/resource_dispatcher_host.cc
@@ -402,7 +402,7 @@ void ResourceDispatcherHost::BeginRequest(
upload_size);
extra_info->allow_download =
ResourceType::IsFrame(request_data.resource_type);
- request->set_user_data(extra_info); // takes pointer ownership
+ SetExtraInfoForRequest(request, extra_info); // request takes ownership
BeginRequestInternal(request);
}
@@ -541,7 +541,7 @@ void ResourceDispatcherHost::BeginDownload(const GURL& url,
0 /* upload_size */);
extra_info->allow_download = true;
extra_info->is_download = true;
- request->set_user_data(extra_info); // Takes pointer ownership.
+ SetExtraInfoForRequest(request, extra_info); // request takes ownership
BeginRequestInternal(request);
}
@@ -596,7 +596,7 @@ void ResourceDispatcherHost::BeginSaveFile(const GURL& url,
// Just saving some resources we need, disallow downloading.
extra_info->allow_download = false;
extra_info->is_download = false;
- request->set_user_data(extra_info); // Takes pointer ownership.
+ SetExtraInfoForRequest(request, extra_info); // request takes ownership
BeginRequestInternal(request);
}
diff --git a/chrome/browser/renderer_host/resource_dispatcher_host.h b/chrome/browser/renderer_host/resource_dispatcher_host.h
index 052c157..ba699bc 100644
--- a/chrome/browser/renderer_host/resource_dispatcher_host.h
+++ b/chrome/browser/renderer_host/resource_dispatcher_host.h
@@ -309,20 +309,21 @@ class ResourceDispatcherHost : public URLRequest::Delegate {
virtual void OnReadCompleted(URLRequest* request, int bytes_read);
void OnResponseCompleted(URLRequest* request);
- // Helper function to get our extra data out of a request. The given request
+ // Helper functions to get our extra data out of a request. The given request
// must have been one we created so that it has the proper extra data pointer.
static ExtraRequestInfo* ExtraInfoForRequest(URLRequest* request) {
- ExtraRequestInfo* r = static_cast<ExtraRequestInfo*>(request->user_data());
- DLOG_IF(WARNING, !r) << "Request doesn't seem to have our data";
- return r;
+ ExtraRequestInfo* info
+ = static_cast<ExtraRequestInfo*>(request->GetUserData(NULL));
+ DLOG_IF(WARNING, !info) << "Request doesn't seem to have our data";
+ return info;
}
static const ExtraRequestInfo* ExtraInfoForRequest(
const URLRequest* request) {
- const ExtraRequestInfo* r =
- static_cast<const ExtraRequestInfo*>(request->user_data());
- DLOG_IF(WARNING, !r) << "Request doesn't seem to have our data";
- return r;
+ const ExtraRequestInfo* info =
+ static_cast<const ExtraRequestInfo*>(request->GetUserData(NULL));
+ DLOG_IF(WARNING, !info) << "Request doesn't seem to have our data";
+ return info;
}
// Adds an observer. The observer will be called on the IO thread. To
@@ -380,6 +381,10 @@ class ResourceDispatcherHost : public URLRequest::Delegate {
friend class ShutdownTask;
+ void SetExtraInfoForRequest(URLRequest* request, ExtraRequestInfo* info) {
+ request->SetUserData(NULL, info);
+ }
+
// A shutdown helper that runs on the IO thread.
void OnShutdown();