summaryrefslogtreecommitdiffstats
path: root/android_webview/browser
diff options
context:
space:
mode:
authorpauljensen@chromium.org <pauljensen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-08 18:17:11 +0000
committerpauljensen@chromium.org <pauljensen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-08 18:17:11 +0000
commit6bd3007d35fb0ca49c927d32acb4941fe70cb88e (patch)
tree51b70122c9c6645c26fdeb7736b438ef3c70e2c1 /android_webview/browser
parent4a4d26d2cf5f584bc347394196bb520030ed68ce (diff)
downloadchromium_src-6bd3007d35fb0ca49c927d32acb4941fe70cb88e.zip
chromium_src-6bd3007d35fb0ca49c927d32acb4941fe70cb88e.tar.gz
chromium_src-6bd3007d35fb0ca49c927d32acb4941fe70cb88e.tar.bz2
Add StoragePartition's ProtocolHandlers at URLRequestContext construction time.
Previously they were added later which doesn't mesh with pending URLRequestJobFactory API changes. BUG=146602,161529 Review URL: https://chromiumcodereview.appspot.com/11308362 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181519 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'android_webview/browser')
-rw-r--r--android_webview/browser/aw_browser_context.cc84
-rw-r--r--android_webview/browser/aw_browser_context.h34
-rw-r--r--android_webview/browser/aw_content_browser_client.cc43
-rw-r--r--android_webview/browser/aw_content_browser_client.h32
-rw-r--r--android_webview/browser/net/aw_url_request_context_getter.cc114
-rw-r--r--android_webview/browser/net/aw_url_request_context_getter.h47
6 files changed, 271 insertions, 83 deletions
diff --git a/android_webview/browser/aw_browser_context.cc b/android_webview/browser/aw_browser_context.cc
index d7f9789..8043adc 100644
--- a/android_webview/browser/aw_browser_context.cc
+++ b/android_webview/browser/aw_browser_context.cc
@@ -6,10 +6,40 @@
#include "android_webview/browser/net/aw_url_request_context_getter.h"
#include "components/visitedlink/browser/visitedlink_master.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/resource_context.h"
+#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents.h"
+#include "net/url_request/url_request_context.h"
namespace android_webview {
+namespace {
+
+class AwResourceContext : public content::ResourceContext {
+ public:
+ explicit AwResourceContext(net::URLRequestContextGetter* getter)
+ : getter_(getter) {}
+ virtual ~AwResourceContext() {}
+
+ // content::ResourceContext implementation.
+ virtual net::HostResolver* GetHostResolver() OVERRIDE {
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
+ return getter_->GetURLRequestContext()->host_resolver();
+ }
+ virtual net::URLRequestContext* GetRequestContext() OVERRIDE {
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
+ return getter_->GetURLRequestContext();
+ }
+
+ private:
+ net::URLRequestContextGetter* getter_;
+
+ DISALLOW_COPY_AND_ASSIGN(AwResourceContext);
+};
+
+} // namespace
+
AwBrowserContext::AwBrowserContext(
const FilePath path,
GeolocationPermissionFactoryFn* geolocation_permission_factory)
@@ -43,6 +73,43 @@ void AwBrowserContext::AddVisitedURLs(const std::vector<GURL>& urls) {
visitedlink_master_->AddURLs(urls);
}
+net::URLRequestContextGetter* AwBrowserContext::CreateRequestContext(
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ blob_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ file_system_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ developer_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ chrome_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ chrome_devtools_protocol_handler) {
+ CHECK(url_request_context_getter_);
+ url_request_context_getter_->SetProtocolHandlers(
+ blob_protocol_handler.Pass(), file_system_protocol_handler.Pass(),
+ developer_protocol_handler.Pass(), chrome_protocol_handler.Pass(),
+ chrome_devtools_protocol_handler.Pass());
+ return url_request_context_getter_.get();
+}
+
+net::URLRequestContextGetter*
+AwBrowserContext::CreateRequestContextForStoragePartition(
+ const FilePath& partition_path,
+ bool in_memory,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ blob_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ file_system_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ developer_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ chrome_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ chrome_devtools_protocol_handler) {
+ CHECK(url_request_context_getter_);
+ return url_request_context_getter_.get();
+}
+
FilePath AwBrowserContext::GetPath() {
return context_storage_path_;
}
@@ -53,8 +120,7 @@ bool AwBrowserContext::IsOffTheRecord() const {
}
net::URLRequestContextGetter* AwBrowserContext::GetRequestContext() {
- DCHECK(url_request_context_getter_);
- return url_request_context_getter_;
+ return GetDefaultStoragePartition(this)->GetURLRequestContext();
}
net::URLRequestContextGetter*
@@ -63,13 +129,6 @@ AwBrowserContext::GetRequestContextForRenderProcess(
return GetRequestContext();
}
-net::URLRequestContextGetter*
-AwBrowserContext::GetRequestContextForStoragePartition(
- const FilePath& partition_path,
- bool in_memory) {
- return GetRequestContext();
-}
-
net::URLRequestContextGetter* AwBrowserContext::GetMediaRequestContext() {
return GetRequestContext();
}
@@ -88,7 +147,12 @@ AwBrowserContext::GetMediaRequestContextForStoragePartition(
}
content::ResourceContext* AwBrowserContext::GetResourceContext() {
- return url_request_context_getter_->GetResourceContext();
+ if (!resource_context_) {
+ CHECK(url_request_context_getter_);
+ resource_context_.reset(new AwResourceContext(
+ url_request_context_getter_.get()));
+ }
+ return resource_context_.get();
}
content::DownloadManagerDelegate*
diff --git a/android_webview/browser/aw_browser_context.h b/android_webview/browser/aw_browser_context.h
index 198c970..b7f1b37 100644
--- a/android_webview/browser/aw_browser_context.h
+++ b/android_webview/browser/aw_browser_context.h
@@ -8,11 +8,15 @@
#include <vector>
#include "android_webview/browser/aw_download_manager_delegate.h"
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
#include "base/file_path.h"
#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
#include "components/visitedlink/browser/visitedlink_delegate.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/geolocation_permission_context.h"
+#include "net/url_request/url_request_job_factory.h"
class GURL;
@@ -21,6 +25,7 @@ class VisitedLinkMaster;
} // namespace components
namespace content {
+class ResourceContext;
class WebContents;
} // namespace content
@@ -53,14 +58,37 @@ class AwBrowserContext : public content::BrowserContext,
// These methods map to Add methods in components::VisitedLinkMaster.
void AddVisitedURLs(const std::vector<GURL>& urls);
+ net::URLRequestContextGetter* CreateRequestContext(
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ blob_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ file_system_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ developer_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ chrome_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ chrome_devtools_protocol_handler);
+ net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
+ const FilePath& partition_path,
+ bool in_memory,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ blob_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ file_system_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ developer_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ chrome_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ chrome_devtools_protocol_handler);
+
// content::BrowserContext implementation.
virtual FilePath GetPath() OVERRIDE;
virtual bool IsOffTheRecord() const OVERRIDE;
virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE;
virtual net::URLRequestContextGetter* GetRequestContextForRenderProcess(
int renderer_child_id) OVERRIDE;
- virtual net::URLRequestContextGetter* GetRequestContextForStoragePartition(
- const FilePath& partition_path, bool in_memory) OVERRIDE;
virtual net::URLRequestContextGetter* GetMediaRequestContext() OVERRIDE;
virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess(
int renderer_child_id) OVERRIDE;
@@ -81,7 +109,6 @@ class AwBrowserContext : public content::BrowserContext,
const scoped_refptr<URLEnumerator>& enumerator) OVERRIDE;
private:
-
// The file path where data for this context is persisted.
FilePath context_storage_path_;
@@ -93,6 +120,7 @@ class AwBrowserContext : public content::BrowserContext,
AwDownloadManagerDelegate download_manager_delegate_;
scoped_ptr<components::VisitedLinkMaster> visitedlink_master_;
+ scoped_ptr<content::ResourceContext> resource_context_;
DISALLOW_COPY_AND_ASSIGN(AwBrowserContext);
};
diff --git a/android_webview/browser/aw_content_browser_client.cc b/android_webview/browser/aw_content_browser_client.cc
index 03f631d..8bd40a4 100644
--- a/android_webview/browser/aw_content_browser_client.cc
+++ b/android_webview/browser/aw_content_browser_client.cc
@@ -101,6 +101,49 @@ void AwContentBrowserClient::RenderProcessHostCreated(
host->GetID(), chrome::kFileScheme);
}
+net::URLRequestContextGetter*
+AwContentBrowserClient::CreateRequestContext(
+ content::BrowserContext* browser_context,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ blob_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ file_system_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ developer_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ chrome_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ chrome_devtools_protocol_handler) {
+ DCHECK(browser_context_.get() == browser_context);
+ return browser_context_->CreateRequestContext(
+ blob_protocol_handler.Pass(), file_system_protocol_handler.Pass(),
+ developer_protocol_handler.Pass(), chrome_protocol_handler.Pass(),
+ chrome_devtools_protocol_handler.Pass());
+}
+
+net::URLRequestContextGetter*
+AwContentBrowserClient::CreateRequestContextForStoragePartition(
+ content::BrowserContext* browser_context,
+ const FilePath& partition_path,
+ bool in_memory,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ blob_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ file_system_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ developer_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ chrome_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ chrome_devtools_protocol_handler) {
+ DCHECK(browser_context_.get() == browser_context);
+ return browser_context_->CreateRequestContextForStoragePartition(
+ partition_path, in_memory, blob_protocol_handler.Pass(),
+ file_system_protocol_handler.Pass(),
+ developer_protocol_handler.Pass(), chrome_protocol_handler.Pass(),
+ chrome_devtools_protocol_handler.Pass());
+}
+
std::string AwContentBrowserClient::GetCanonicalEncodingNameByAliasName(
const std::string& alias_name) {
return alias_name;
diff --git a/android_webview/browser/aw_content_browser_client.h b/android_webview/browser/aw_content_browser_client.h
index 2f5dee0..59a1c9e 100644
--- a/android_webview/browser/aw_content_browser_client.h
+++ b/android_webview/browser/aw_content_browser_client.h
@@ -5,10 +5,12 @@
#ifndef ANDROID_WEBVIEW_LIB_AW_CONTENT_BROWSER_CLIENT_H_
#define ANDROID_WEBVIEW_LIB_AW_CONTENT_BROWSER_CLIENT_H_
-#include "content/public/browser/content_browser_client.h"
-
#include "android_webview/browser/aw_browser_context.h"
+#include "base/basictypes.h"
#include "base/compiler_specific.h"
+#include "base/memory/scoped_ptr.h"
+#include "content/public/browser/content_browser_client.h"
+#include "net/url_request/url_request_job_factory.h"
namespace android_webview {
@@ -37,6 +39,32 @@ class AwContentBrowserClient : public content::ContentBrowserClient {
content::WebContents* web_contents) OVERRIDE;
virtual void RenderProcessHostCreated(
content::RenderProcessHost* host) OVERRIDE;
+ virtual net::URLRequestContextGetter* CreateRequestContext(
+ content::BrowserContext* browser_context,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ blob_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ file_system_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ developer_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ chrome_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ chrome_devtools_protocol_handler) OVERRIDE;
+ virtual net::URLRequestContextGetter* CreateRequestContextForStoragePartition(
+ content::BrowserContext* browser_context,
+ const FilePath& partition_path,
+ bool in_memory,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ blob_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ file_system_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ developer_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ chrome_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ chrome_devtools_protocol_handler) OVERRIDE;
virtual std::string GetCanonicalEncodingNameByAliasName(
const std::string& alias_name) OVERRIDE;
virtual void AppendExtraCommandLineSwitches(CommandLine* command_line,
diff --git a/android_webview/browser/net/aw_url_request_context_getter.cc b/android_webview/browser/net/aw_url_request_context_getter.cc
index f80f0c2..6ec1aad 100644
--- a/android_webview/browser/net/aw_url_request_context_getter.cc
+++ b/android_webview/browser/net/aw_url_request_context_getter.cc
@@ -11,7 +11,6 @@
#include "android_webview/browser/net/init_native_callback.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
-#include "content/public/browser/resource_context.h"
#include "content/public/common/content_client.h"
#include "content/public/common/url_constants.h"
#include "net/http/http_cache.h"
@@ -26,40 +25,6 @@ using content::BrowserThread;
namespace android_webview {
-namespace {
-
-class AwResourceContext : public content::ResourceContext {
- public:
- AwResourceContext(net::URLRequestContext* getter);
- virtual ~AwResourceContext();
- virtual net::HostResolver* GetHostResolver() OVERRIDE;
- virtual net::URLRequestContext* GetRequestContext() OVERRIDE;
-
- private:
- net::URLRequestContext* context_; // weak
-
- DISALLOW_COPY_AND_ASSIGN(AwResourceContext);
-};
-
-AwResourceContext::AwResourceContext(net::URLRequestContext* context)
- : context_(context) {
-}
-
-AwResourceContext::~AwResourceContext() {
-}
-
-net::HostResolver* AwResourceContext::GetHostResolver() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- return context_->host_resolver();
-}
-
-net::URLRequestContext* AwResourceContext::GetRequestContext() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- return context_;
-}
-
-} // namespace
-
AwURLRequestContextGetter::AwURLRequestContextGetter(
AwBrowserContext* browser_context)
: browser_context_(browser_context),
@@ -95,14 +60,6 @@ void AwURLRequestContextGetter::Init() {
url_request_context_.reset(builder.Build());
- scoped_ptr<AwURLRequestJobFactory> job_factory(new AwURLRequestJobFactory);
- bool set_protocol = job_factory->SetProtocolHandler(
- chrome::kFileScheme, new net::FileProtocolHandler());
- DCHECK(set_protocol);
- set_protocol = job_factory->SetProtocolHandler(
- chrome::kDataScheme, new net::DataProtocolHandler());
- DCHECK(set_protocol);
-
// TODO(mnaganov): Fix URLRequestContextBuilder to use proper threads.
net::HttpNetworkSession::Params network_session_params;
PopulateNetworkSessionParams(&network_session_params);
@@ -115,14 +72,6 @@ void AwURLRequestContextGetter::Init() {
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE)));
main_http_factory_.reset(main_cache);
url_request_context_->set_http_transaction_factory(main_cache);
-
- job_factory_ = CreateAndroidJobFactoryAndCookieMonster(
- url_request_context_.get(), job_factory.Pass());
- job_factory_.reset(new net::ProtocolInterceptJobFactory(
- job_factory_.Pass(),
- scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>(
- new AwRequestInterceptor())));
- url_request_context_->set_job_factory(job_factory_.get());
}
void AwURLRequestContextGetter::PopulateNetworkSessionParams(
@@ -140,15 +89,46 @@ void AwURLRequestContextGetter::PopulateNetworkSessionParams(
params->net_log = context->net_log();
}
-content::ResourceContext* AwURLRequestContextGetter::GetResourceContext() {
- DCHECK(url_request_context_);
- if (!resource_context_)
- resource_context_.reset(new AwResourceContext(url_request_context_.get()));
- return resource_context_.get();
-}
-
net::URLRequestContext* AwURLRequestContextGetter::GetURLRequestContext() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ if (!job_factory_) {
+ scoped_ptr<AwURLRequestJobFactory> job_factory(new AwURLRequestJobFactory);
+ bool set_protocol = job_factory->SetProtocolHandler(
+ chrome::kFileScheme, new net::FileProtocolHandler());
+ DCHECK(set_protocol);
+ set_protocol = job_factory->SetProtocolHandler(
+ chrome::kDataScheme, new net::DataProtocolHandler());
+ DCHECK(set_protocol);
+ DCHECK(blob_protocol_handler_);
+ set_protocol = job_factory->SetProtocolHandler(
+ chrome::kBlobScheme, blob_protocol_handler_.release());
+ DCHECK(set_protocol);
+ DCHECK(file_system_protocol_handler_);
+ set_protocol = job_factory->SetProtocolHandler(
+ chrome::kFileSystemScheme, file_system_protocol_handler_.release());
+ DCHECK(set_protocol);
+ DCHECK(chrome_protocol_handler_);
+ set_protocol = job_factory->SetProtocolHandler(
+ chrome::kChromeUIScheme, chrome_protocol_handler_.release());
+ DCHECK(set_protocol);
+ DCHECK(chrome_devtools_protocol_handler_);
+ set_protocol = job_factory->SetProtocolHandler(
+ chrome::kChromeDevToolsScheme,
+ chrome_devtools_protocol_handler_.release());
+ DCHECK(set_protocol);
+ // Create a chain of URLRequestJobFactories. Keep |job_factory_| pointed
+ // at the beginning of the chain.
+ job_factory_ = CreateAndroidJobFactoryAndCookieMonster(
+ url_request_context_.get(), job_factory.Pass());
+ job_factory_.reset(new net::ProtocolInterceptJobFactory(
+ job_factory_.Pass(),
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>(
+ new AwRequestInterceptor())));
+ job_factory_.reset(new net::ProtocolInterceptJobFactory(
+ job_factory_.Pass(),
+ developer_protocol_handler_.Pass()));
+ url_request_context_->set_job_factory(job_factory_.get());
+ }
return url_request_context_.get();
}
@@ -157,4 +137,22 @@ AwURLRequestContextGetter::GetNetworkTaskRunner() const {
return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO);
}
+void AwURLRequestContextGetter::SetProtocolHandlers(
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ blob_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ file_system_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ developer_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ chrome_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ chrome_devtools_protocol_handler) {
+ blob_protocol_handler_ = blob_protocol_handler.Pass();
+ file_system_protocol_handler_ = file_system_protocol_handler.Pass();
+ developer_protocol_handler_ = developer_protocol_handler.Pass();
+ chrome_protocol_handler_ = chrome_protocol_handler.Pass();
+ chrome_devtools_protocol_handler_ = chrome_devtools_protocol_handler.Pass();
+}
+
} // namespace android_webview
diff --git a/android_webview/browser/net/aw_url_request_context_getter.h b/android_webview/browser/net/aw_url_request_context_getter.h
index c5b9ecf..cc2d81f 100644
--- a/android_webview/browser/net/aw_url_request_context_getter.h
+++ b/android_webview/browser/net/aw_url_request_context_getter.h
@@ -5,15 +5,13 @@
#ifndef ANDROID_WEBVIEW_BROWSER_NET_AW_URL_REQUEST_CONTEXT_GETTER_H_
#define ANDROID_WEBVIEW_BROWSER_NET_AW_URL_REQUEST_CONTEXT_GETTER_H_
-#include "content/public/browser/browser_thread_delegate.h"
-
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
+#include "content/public/browser/browser_thread_delegate.h"
#include "net/http/http_network_session.h"
#include "net/url_request/url_request_context_getter.h"
-
-namespace content {
-class ResourceContext;
-}
+#include "net/url_request/url_request_job_factory.h"
namespace net {
class HttpTransactionFactory;
@@ -30,12 +28,10 @@ class AwNetworkDelegate;
class AwURLRequestContextGetter : public net::URLRequestContextGetter,
public content::BrowserThreadDelegate {
public:
- AwURLRequestContextGetter(AwBrowserContext* browser_context);
+ explicit AwURLRequestContextGetter(AwBrowserContext* browser_context);
void InitializeOnNetworkThread();
- content::ResourceContext* GetResourceContext();
-
// content::BrowserThreadDelegate implementation.
virtual void Init() OVERRIDE;
virtual void CleanUp() OVERRIDE {}
@@ -46,17 +42,48 @@ class AwURLRequestContextGetter : public net::URLRequestContextGetter,
GetNetworkTaskRunner() const OVERRIDE;
private:
+ friend class AwBrowserContext;
+
virtual ~AwURLRequestContextGetter();
+ // Prior to GetURLRequestContext() being called, SetProtocolHandlers() is
+ // called to hand over the ProtocolHandlers that GetURLRequestContext() will
+ // later install into |job_factory_|. This ordering is enforced by having
+ // AwBrowserContext::CreateRequestContext() call SetProtocolHandlers().
+ // SetProtocolHandlers() is necessary because the ProtocolHandlers are created
+ // on the UI thread while |job_factory_| must be created on the IO thread.
+ void SetProtocolHandlers(
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ blob_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ file_system_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ developer_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ chrome_protocol_handler,
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ chrome_devtools_protocol_handler);
+
void PopulateNetworkSessionParams(net::HttpNetworkSession::Params* params);
AwBrowserContext* browser_context_; // weak
scoped_ptr<net::URLRequestContext> url_request_context_;
scoped_ptr<net::ProxyConfigService> proxy_config_service_;
- scoped_ptr<content::ResourceContext> resource_context_;
scoped_ptr<net::URLRequestJobFactory> job_factory_;
scoped_ptr<net::HttpTransactionFactory> main_http_factory_;
+ // ProtocolHandlers are stored here between SetProtocolHandlers() and the
+ // first GetURLRequestContext() call.
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> blob_protocol_handler_;
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ file_system_protocol_handler_;
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ developer_protocol_handler_;
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ chrome_protocol_handler_;
+ scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
+ chrome_devtools_protocol_handler_;
+
DISALLOW_COPY_AND_ASSIGN(AwURLRequestContextGetter);
};