summaryrefslogtreecommitdiffstats
path: root/net/url_request/url_request_context.h
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-14 06:17:07 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-14 06:17:07 +0000
commita8c1e745a571a498a6727858d81631c903672d31 (patch)
treeaba124f89b8d9a2765bfcca677c3d4482f15f710 /net/url_request/url_request_context.h
parent1332c24d517e472758aae7e25301752561da6bc5 (diff)
downloadchromium_src-a8c1e745a571a498a6727858d81631c903672d31.zip
chromium_src-a8c1e745a571a498a6727858d81631c903672d31.tar.gz
chromium_src-a8c1e745a571a498a6727858d81631c903672d31.tar.bz2
Create a URLRequestJobFactory to replace the URLRequest globals.
URLRequest::Interceptor and URLRequest::ProtocolFactory are globally registered. This causes a variety of problems. This provides a method for replacing them. It used to be the case that we used net::URLRequest::IsHandledProtocol()/net::URLRequest::IsHandledURL() to see if the request would be handled by Chrome, or deferred to an external protocol handler. This required that URLRequest be aware of all protocol handlers. We instead provide ProfileIOData::IsHandledProtocol(), which checks to see if there are any Chrome registered protocol handlers, and if not, checks the default ones in net::URLRequest. Note this doesn't work for custom handlers (registerProtocolHandler) because they are dynamic and profile-specific. We would have to add a member function to ProfileIOData and not use a global. This is problematic since we check ProfileIOData::IsHandledProtocol in the RenderViewContextMenu, which runs on the UI thread, whereas ProfileIOData lives on the IO thread. RenderViewContextMenu is using also using it synchronously, which makes it a pain to support. So, we don't support custom handlers in ProfileIOData::IsHandledProtocol(). This means that "save as" won't work for custom handlers. Seems ok for now. This also fixes the multiprofile/incognito bugs where if a profile registers a custom handler, and then a different profile / an incognito profile registers the same custom handler and then unregisters it, which globally unregisters it, so the original profile is now broken. By removing the use of the globals, we fix this. Also fixes a bunch of style guide violations in the ProtocolHandler/ProtocolHandlerRegistry code. This changelist replaces two existing URLRequest::ProtocolFactory uses: chrome-extension/user-script and custom handlers. Also improve the tests in ResourceDispatcherHost so we don't have to do as many NULL checks. Change the MockResourceContext to create a TestURLRequestContext. BUG=81979 TEST=none Review URL: http://codereview.chromium.org/6960006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85376 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/url_request/url_request_context.h')
-rw-r--r--net/url_request/url_request_context.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/net/url_request/url_request_context.h b/net/url_request/url_request_context.h
index bc74459..8749573 100644
--- a/net/url_request/url_request_context.h
+++ b/net/url_request/url_request_context.h
@@ -32,6 +32,7 @@ class NetworkDelegate;
class ProxyService;
class SSLConfigService;
class URLRequest;
+class URLRequestJobFactory;
// Subclass to provide application-specific context for URLRequest
// instances. Note that URLRequestContext typically does not provide storage for
@@ -172,6 +173,11 @@ class URLRequestContext
bool is_main() const { return is_main_; }
void set_is_main(bool is_main) { is_main_ = is_main; }
+ const URLRequestJobFactory* job_factory() const { return job_factory_; }
+ void set_job_factory(const URLRequestJobFactory* job_factory) {
+ job_factory_ = job_factory;
+ }
+
protected:
friend class base::RefCountedThreadSafe<URLRequestContext>;
@@ -206,9 +212,9 @@ class URLRequestContext
// used in communication with a server but is used to construct a suggested
// filename for file download.
std::string referrer_charset_;
-
HttpTransactionFactory* http_transaction_factory_;
FtpTransactionFactory* ftp_transaction_factory_;
+ const URLRequestJobFactory* job_factory_;
// ---------------------------------------------------------------------------
// Important: When adding any new members below, consider whether they need to