Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: content/shell/shell_url_request_context_getter.cc

Issue 11308362: Add StoragePartition's ProtocolHandlers at URLRequestContext construction time. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync (r181485) Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/shell/shell_url_request_context_getter.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/shell/shell_url_request_context_getter.h" 5 #include "content/shell/shell_url_request_context_getter.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/string_split.h" 10 #include "base/string_split.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "base/threading/worker_pool.h" 12 #include "base/threading/worker_pool.h"
13 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
14 #include "content/public/common/content_switches.h" 14 #include "content/public/common/content_switches.h"
15 #include "content/public/common/url_constants.h"
15 #include "content/shell/shell_network_delegate.h" 16 #include "content/shell/shell_network_delegate.h"
16 #include "content/shell/shell_switches.h" 17 #include "content/shell/shell_switches.h"
17 #include "net/base/cert_verifier.h" 18 #include "net/base/cert_verifier.h"
18 #include "net/base/default_server_bound_cert_store.h" 19 #include "net/base/default_server_bound_cert_store.h"
19 #include "net/base/host_resolver.h" 20 #include "net/base/host_resolver.h"
20 #include "net/base/mapped_host_resolver.h" 21 #include "net/base/mapped_host_resolver.h"
21 #include "net/base/server_bound_cert_service.h" 22 #include "net/base/server_bound_cert_service.h"
22 #include "net/base/ssl_config_service_defaults.h" 23 #include "net/base/ssl_config_service_defaults.h"
23 #include "net/cookies/cookie_monster.h" 24 #include "net/cookies/cookie_monster.h"
24 #include "net/http/http_auth_handler_factory.h" 25 #include "net/http/http_auth_handler_factory.h"
25 #include "net/http/http_cache.h" 26 #include "net/http/http_cache.h"
26 #include "net/http/http_network_session.h" 27 #include "net/http/http_network_session.h"
27 #include "net/http/http_server_properties_impl.h" 28 #include "net/http/http_server_properties_impl.h"
28 #include "net/proxy/proxy_service.h" 29 #include "net/proxy/proxy_service.h"
30 #include "net/url_request/protocol_intercept_job_factory.h"
29 #include "net/url_request/static_http_user_agent_settings.h" 31 #include "net/url_request/static_http_user_agent_settings.h"
30 #include "net/url_request/url_request_context.h" 32 #include "net/url_request/url_request_context.h"
31 #include "net/url_request/url_request_context_storage.h" 33 #include "net/url_request/url_request_context_storage.h"
32 #include "net/url_request/url_request_job_factory_impl.h" 34 #include "net/url_request/url_request_job_factory_impl.h"
33 35
34 namespace content { 36 namespace content {
35 37
36 ShellURLRequestContextGetter::ShellURLRequestContextGetter( 38 ShellURLRequestContextGetter::ShellURLRequestContextGetter(
37 bool ignore_certificate_errors, 39 bool ignore_certificate_errors,
38 const base::FilePath& base_path, 40 const base::FilePath& base_path,
39 MessageLoop* io_loop, 41 MessageLoop* io_loop,
40 MessageLoop* file_loop) 42 MessageLoop* file_loop,
43 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
44 blob_protocol_handler,
45 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
46 file_system_protocol_handler,
47 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
48 developer_protocol_handler,
49 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
50 chrome_protocol_handler,
51 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
52 chrome_devtools_protocol_handler)
41 : ignore_certificate_errors_(ignore_certificate_errors), 53 : ignore_certificate_errors_(ignore_certificate_errors),
42 base_path_(base_path), 54 base_path_(base_path),
43 io_loop_(io_loop), 55 io_loop_(io_loop),
44 file_loop_(file_loop) { 56 file_loop_(file_loop),
57 blob_protocol_handler_(blob_protocol_handler.Pass()),
58 file_system_protocol_handler_(file_system_protocol_handler.Pass()),
59 developer_protocol_handler_(developer_protocol_handler.Pass()),
60 chrome_protocol_handler_(chrome_protocol_handler.Pass()),
61 chrome_devtools_protocol_handler_(
62 chrome_devtools_protocol_handler.Pass()) {
45 // Must first be created on the UI thread. 63 // Must first be created on the UI thread.
46 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 64 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
47 65
48 // We must create the proxy config service on the UI loop on Linux because it 66 // We must create the proxy config service on the UI loop on Linux because it
49 // must synchronously run on the glib message loop. This will be passed to 67 // must synchronously run on the glib message loop. This will be passed to
50 // the URLRequestContextStorage on the IO thread in GetURLRequestContext(). 68 // the URLRequestContextStorage on the IO thread in GetURLRequestContext().
51 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) { 69 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) {
52 proxy_config_service_.reset( 70 proxy_config_service_.reset(
53 net::ProxyService::CreateSystemProxyConfigService( 71 net::ProxyService::CreateSystemProxyConfigService(
54 io_loop_->message_loop_proxy(), file_loop_)); 72 io_loop_->message_loop_proxy(), file_loop_));
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 162
145 // Give |storage_| ownership at the end in case it's |mapped_host_resolver|. 163 // Give |storage_| ownership at the end in case it's |mapped_host_resolver|.
146 storage_->set_host_resolver(host_resolver.Pass()); 164 storage_->set_host_resolver(host_resolver.Pass());
147 network_session_params.host_resolver = 165 network_session_params.host_resolver =
148 url_request_context_->host_resolver(); 166 url_request_context_->host_resolver();
149 167
150 net::HttpCache* main_cache = new net::HttpCache( 168 net::HttpCache* main_cache = new net::HttpCache(
151 network_session_params, main_backend); 169 network_session_params, main_backend);
152 storage_->set_http_transaction_factory(main_cache); 170 storage_->set_http_transaction_factory(main_cache);
153 171
154 storage_->set_job_factory(new net::URLRequestJobFactoryImpl); 172 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory(
173 new net::URLRequestJobFactoryImpl());
174 bool set_protocol = job_factory->SetProtocolHandler(
175 chrome::kBlobScheme, blob_protocol_handler_.release());
176 DCHECK(set_protocol);
177 set_protocol = job_factory->SetProtocolHandler(
178 chrome::kFileSystemScheme, file_system_protocol_handler_.release());
179 DCHECK(set_protocol);
180 set_protocol = job_factory->SetProtocolHandler(
181 chrome::kChromeUIScheme, chrome_protocol_handler_.release());
182 DCHECK(set_protocol);
183 set_protocol = job_factory->SetProtocolHandler(
184 chrome::kChromeDevToolsScheme,
185 chrome_devtools_protocol_handler_.release());
186 DCHECK(set_protocol);
187 storage_->set_job_factory(new net::ProtocolInterceptJobFactory(
188 job_factory.PassAs<net::URLRequestJobFactory>(),
189 developer_protocol_handler_.Pass()));
155 } 190 }
156 191
157 return url_request_context_.get(); 192 return url_request_context_.get();
158 } 193 }
159 194
160 scoped_refptr<base::SingleThreadTaskRunner> 195 scoped_refptr<base::SingleThreadTaskRunner>
161 ShellURLRequestContextGetter::GetNetworkTaskRunner() const { 196 ShellURLRequestContextGetter::GetNetworkTaskRunner() const {
162 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); 197 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO);
163 } 198 }
164 199
165 net::HostResolver* ShellURLRequestContextGetter::host_resolver() { 200 net::HostResolver* ShellURLRequestContextGetter::host_resolver() {
166 return url_request_context_->host_resolver(); 201 return url_request_context_->host_resolver();
167 } 202 }
168 203
169 } // namespace content 204 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/shell_url_request_context_getter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698