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

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

Issue 282103004: Rename ProtocolInterceptJobFactory and make it not use ProtocolHandlers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Response to jam's comments (And a merge) Created 6 years, 6 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/browser/shell_url_request_context_getter.h ('k') | net/net.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/browser/shell_url_request_context_getter.h" 5 #include "content/shell/browser/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/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
(...skipping 14 matching lines...) Expand all
25 #include "net/http/http_cache.h" 25 #include "net/http/http_cache.h"
26 #include "net/http/http_network_session.h" 26 #include "net/http/http_network_session.h"
27 #include "net/http/http_server_properties_impl.h" 27 #include "net/http/http_server_properties_impl.h"
28 #include "net/http/transport_security_state.h" 28 #include "net/http/transport_security_state.h"
29 #include "net/proxy/proxy_service.h" 29 #include "net/proxy/proxy_service.h"
30 #include "net/ssl/default_server_bound_cert_store.h" 30 #include "net/ssl/default_server_bound_cert_store.h"
31 #include "net/ssl/server_bound_cert_service.h" 31 #include "net/ssl/server_bound_cert_service.h"
32 #include "net/ssl/ssl_config_service_defaults.h" 32 #include "net/ssl/ssl_config_service_defaults.h"
33 #include "net/url_request/data_protocol_handler.h" 33 #include "net/url_request/data_protocol_handler.h"
34 #include "net/url_request/file_protocol_handler.h" 34 #include "net/url_request/file_protocol_handler.h"
35 #include "net/url_request/protocol_intercept_job_factory.h"
36 #include "net/url_request/static_http_user_agent_settings.h" 35 #include "net/url_request/static_http_user_agent_settings.h"
37 #include "net/url_request/url_request_context.h" 36 #include "net/url_request/url_request_context.h"
38 #include "net/url_request/url_request_context_storage.h" 37 #include "net/url_request/url_request_context_storage.h"
38 #include "net/url_request/url_request_intercepting_job_factory.h"
39 #include "net/url_request/url_request_job_factory_impl.h" 39 #include "net/url_request/url_request_job_factory_impl.h"
40 #include "url/url_constants.h" 40 #include "url/url_constants.h"
41 41
42 namespace content { 42 namespace content {
43 43
44 namespace { 44 namespace {
45 45
46 void InstallProtocolHandlers(net::URLRequestJobFactoryImpl* job_factory, 46 void InstallProtocolHandlers(net::URLRequestJobFactoryImpl* job_factory,
47 ProtocolHandlerMap* protocol_handlers) { 47 ProtocolHandlerMap* protocol_handlers) {
48 for (ProtocolHandlerMap::iterator it = 48 for (ProtocolHandlerMap::iterator it =
49 protocol_handlers->begin(); 49 protocol_handlers->begin();
50 it != protocol_handlers->end(); 50 it != protocol_handlers->end();
51 ++it) { 51 ++it) {
52 bool set_protocol = job_factory->SetProtocolHandler( 52 bool set_protocol = job_factory->SetProtocolHandler(
53 it->first, it->second.release()); 53 it->first, it->second.release());
54 DCHECK(set_protocol); 54 DCHECK(set_protocol);
55 } 55 }
56 protocol_handlers->clear(); 56 protocol_handlers->clear();
57 } 57 }
58 58
59 } // namespace 59 } // namespace
60 60
61 ShellURLRequestContextGetter::ShellURLRequestContextGetter( 61 ShellURLRequestContextGetter::ShellURLRequestContextGetter(
62 bool ignore_certificate_errors, 62 bool ignore_certificate_errors,
63 const base::FilePath& base_path, 63 const base::FilePath& base_path,
64 base::MessageLoop* io_loop, 64 base::MessageLoop* io_loop,
65 base::MessageLoop* file_loop, 65 base::MessageLoop* file_loop,
66 ProtocolHandlerMap* protocol_handlers, 66 ProtocolHandlerMap* protocol_handlers,
67 ProtocolHandlerScopedVector protocol_interceptors, 67 URLRequestInterceptorScopedVector request_interceptors,
68 net::NetLog* net_log) 68 net::NetLog* net_log)
69 : ignore_certificate_errors_(ignore_certificate_errors), 69 : ignore_certificate_errors_(ignore_certificate_errors),
70 base_path_(base_path), 70 base_path_(base_path),
71 io_loop_(io_loop), 71 io_loop_(io_loop),
72 file_loop_(file_loop), 72 file_loop_(file_loop),
73 net_log_(net_log), 73 net_log_(net_log),
74 protocol_interceptors_(protocol_interceptors.Pass()) { 74 request_interceptors_(request_interceptors.Pass()) {
75 // Must first be created on the UI thread. 75 // Must first be created on the UI thread.
76 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 76 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
77 77
78 std::swap(protocol_handlers_, *protocol_handlers); 78 std::swap(protocol_handlers_, *protocol_handlers);
79 79
80 // We must create the proxy config service on the UI loop on Linux because it 80 // We must create the proxy config service on the UI loop on Linux because it
81 // must synchronously run on the glib message loop. This will be passed to 81 // must synchronously run on the glib message loop. This will be passed to
82 // the URLRequestContextStorage on the IO thread in GetURLRequestContext(). 82 // the URLRequestContextStorage on the IO thread in GetURLRequestContext().
83 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) { 83 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) {
84 proxy_config_service_.reset( 84 proxy_config_service_.reset(
(...skipping 12 matching lines...) Expand all
97 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 97 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
98 98
99 url_request_context_.reset(new net::URLRequestContext()); 99 url_request_context_.reset(new net::URLRequestContext());
100 url_request_context_->set_net_log(net_log_); 100 url_request_context_->set_net_log(net_log_);
101 network_delegate_.reset(new ShellNetworkDelegate); 101 network_delegate_.reset(new ShellNetworkDelegate);
102 if (command_line.HasSwitch(switches::kDumpRenderTree)) 102 if (command_line.HasSwitch(switches::kDumpRenderTree))
103 ShellNetworkDelegate::SetAcceptAllCookies(false); 103 ShellNetworkDelegate::SetAcceptAllCookies(false);
104 url_request_context_->set_network_delegate(network_delegate_.get()); 104 url_request_context_->set_network_delegate(network_delegate_.get());
105 storage_.reset( 105 storage_.reset(
106 new net::URLRequestContextStorage(url_request_context_.get())); 106 new net::URLRequestContextStorage(url_request_context_.get()));
107 storage_->set_cookie_store( 107 storage_->set_cookie_store(CreateCookieStore(CookieStoreConfig()));
108 content::CreateCookieStore(content::CookieStoreConfig()));
109 storage_->set_server_bound_cert_service(new net::ServerBoundCertService( 108 storage_->set_server_bound_cert_service(new net::ServerBoundCertService(
110 new net::DefaultServerBoundCertStore(NULL), 109 new net::DefaultServerBoundCertStore(NULL),
111 base::WorkerPool::GetTaskRunner(true))); 110 base::WorkerPool::GetTaskRunner(true)));
112 storage_->set_http_user_agent_settings( 111 storage_->set_http_user_agent_settings(
113 new net::StaticHttpUserAgentSettings("en-us,en", std::string())); 112 new net::StaticHttpUserAgentSettings("en-us,en", std::string()));
114 113
115 scoped_ptr<net::HostResolver> host_resolver( 114 scoped_ptr<net::HostResolver> host_resolver(
116 net::HostResolver::CreateDefaultResolver( 115 net::HostResolver::CreateDefaultResolver(
117 url_request_context_->net_log())); 116 url_request_context_->net_log()));
118 117
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 new net::URLRequestJobFactoryImpl()); 204 new net::URLRequestJobFactoryImpl());
206 // Keep ProtocolHandlers added in sync with 205 // Keep ProtocolHandlers added in sync with
207 // ShellContentBrowserClient::IsHandledURL(). 206 // ShellContentBrowserClient::IsHandledURL().
208 InstallProtocolHandlers(job_factory.get(), &protocol_handlers_); 207 InstallProtocolHandlers(job_factory.get(), &protocol_handlers_);
209 bool set_protocol = job_factory->SetProtocolHandler( 208 bool set_protocol = job_factory->SetProtocolHandler(
210 url::kDataScheme, new net::DataProtocolHandler); 209 url::kDataScheme, new net::DataProtocolHandler);
211 DCHECK(set_protocol); 210 DCHECK(set_protocol);
212 set_protocol = job_factory->SetProtocolHandler( 211 set_protocol = job_factory->SetProtocolHandler(
213 url::kFileScheme, 212 url::kFileScheme,
214 new net::FileProtocolHandler( 213 new net::FileProtocolHandler(
215 content::BrowserThread::GetBlockingPool()-> 214 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior(
216 GetTaskRunnerWithShutdownBehavior( 215 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)));
217 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)));
218 DCHECK(set_protocol); 216 DCHECK(set_protocol);
219 217
220 // Set up interceptors in the reverse order. 218 // Set up interceptors in the reverse order.
221 scoped_ptr<net::URLRequestJobFactory> top_job_factory = 219 scoped_ptr<net::URLRequestJobFactory> top_job_factory =
222 job_factory.PassAs<net::URLRequestJobFactory>(); 220 job_factory.PassAs<net::URLRequestJobFactory>();
223 for (ProtocolHandlerScopedVector::reverse_iterator i = 221 for (URLRequestInterceptorScopedVector::reverse_iterator i =
224 protocol_interceptors_.rbegin(); 222 request_interceptors_.rbegin();
225 i != protocol_interceptors_.rend(); 223 i != request_interceptors_.rend();
226 ++i) { 224 ++i) {
227 top_job_factory.reset(new net::ProtocolInterceptJobFactory( 225 top_job_factory.reset(new net::URLRequestInterceptingJobFactory(
228 top_job_factory.Pass(), make_scoped_ptr(*i))); 226 top_job_factory.Pass(), make_scoped_ptr(*i)));
229 } 227 }
230 protocol_interceptors_.weak_clear(); 228 request_interceptors_.weak_clear();
231 229
232 storage_->set_job_factory(top_job_factory.release()); 230 storage_->set_job_factory(top_job_factory.release());
233 } 231 }
234 232
235 return url_request_context_.get(); 233 return url_request_context_.get();
236 } 234 }
237 235
238 scoped_refptr<base::SingleThreadTaskRunner> 236 scoped_refptr<base::SingleThreadTaskRunner>
239 ShellURLRequestContextGetter::GetNetworkTaskRunner() const { 237 ShellURLRequestContextGetter::GetNetworkTaskRunner() const {
240 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); 238 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO);
241 } 239 }
242 240
243 net::HostResolver* ShellURLRequestContextGetter::host_resolver() { 241 net::HostResolver* ShellURLRequestContextGetter::host_resolver() {
244 return url_request_context_->host_resolver(); 242 return url_request_context_->host_resolver();
245 } 243 }
246 244
247 } // namespace content 245 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/browser/shell_url_request_context_getter.h ('k') | net/net.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698