OLD | NEW |
---|---|
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 15 matching lines...) Expand all Loading... | |
26 #include "net/http/http_cache.h" | 26 #include "net/http/http_cache.h" |
27 #include "net/http/http_network_session.h" | 27 #include "net/http/http_network_session.h" |
28 #include "net/http/http_server_properties_impl.h" | 28 #include "net/http/http_server_properties_impl.h" |
29 #include "net/http/transport_security_state.h" | 29 #include "net/http/transport_security_state.h" |
30 #include "net/proxy/proxy_service.h" | 30 #include "net/proxy/proxy_service.h" |
31 #include "net/ssl/default_server_bound_cert_store.h" | 31 #include "net/ssl/default_server_bound_cert_store.h" |
32 #include "net/ssl/server_bound_cert_service.h" | 32 #include "net/ssl/server_bound_cert_service.h" |
33 #include "net/ssl/ssl_config_service_defaults.h" | 33 #include "net/ssl/ssl_config_service_defaults.h" |
34 #include "net/url_request/data_protocol_handler.h" | 34 #include "net/url_request/data_protocol_handler.h" |
35 #include "net/url_request/file_protocol_handler.h" | 35 #include "net/url_request/file_protocol_handler.h" |
36 #include "net/url_request/protocol_intercept_job_factory.h" | |
37 #include "net/url_request/static_http_user_agent_settings.h" | 36 #include "net/url_request/static_http_user_agent_settings.h" |
38 #include "net/url_request/url_request_context.h" | 37 #include "net/url_request/url_request_context.h" |
39 #include "net/url_request/url_request_context_storage.h" | 38 #include "net/url_request/url_request_context_storage.h" |
39 #include "net/url_request/url_request_intercepting_job_factory.h" | |
40 #include "net/url_request/url_request_job_factory_impl.h" | 40 #include "net/url_request/url_request_job_factory_impl.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 content::URLRequestInterceptorScopedVector request_interceptors, |
jam
2014/05/30 01:19:15
ditto
mmenke
2014/05/30 14:40:22
Done.
| |
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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
213 kFileScheme, | 213 kFileScheme, |
214 new net::FileProtocolHandler( | 214 new net::FileProtocolHandler( |
215 content::BrowserThread::GetBlockingPool()-> | 215 content::BrowserThread::GetBlockingPool()-> |
216 GetTaskRunnerWithShutdownBehavior( | 216 GetTaskRunnerWithShutdownBehavior( |
217 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN))); | 217 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN))); |
218 DCHECK(set_protocol); | 218 DCHECK(set_protocol); |
219 | 219 |
220 // Set up interceptors in the reverse order. | 220 // Set up interceptors in the reverse order. |
221 scoped_ptr<net::URLRequestJobFactory> top_job_factory = | 221 scoped_ptr<net::URLRequestJobFactory> top_job_factory = |
222 job_factory.PassAs<net::URLRequestJobFactory>(); | 222 job_factory.PassAs<net::URLRequestJobFactory>(); |
223 for (ProtocolHandlerScopedVector::reverse_iterator i = | 223 for (URLRequestInterceptorScopedVector::reverse_iterator i = |
224 protocol_interceptors_.rbegin(); | 224 request_interceptors_.rbegin(); |
225 i != protocol_interceptors_.rend(); | 225 i != request_interceptors_.rend(); |
226 ++i) { | 226 ++i) { |
227 top_job_factory.reset(new net::ProtocolInterceptJobFactory( | 227 top_job_factory.reset(new net::URLRequestInterceptingJobFactory( |
228 top_job_factory.Pass(), make_scoped_ptr(*i))); | 228 top_job_factory.Pass(), make_scoped_ptr(*i))); |
229 } | 229 } |
230 protocol_interceptors_.weak_clear(); | 230 request_interceptors_.weak_clear(); |
231 | 231 |
232 storage_->set_job_factory(top_job_factory.release()); | 232 storage_->set_job_factory(top_job_factory.release()); |
233 } | 233 } |
234 | 234 |
235 return url_request_context_.get(); | 235 return url_request_context_.get(); |
236 } | 236 } |
237 | 237 |
238 scoped_refptr<base::SingleThreadTaskRunner> | 238 scoped_refptr<base::SingleThreadTaskRunner> |
239 ShellURLRequestContextGetter::GetNetworkTaskRunner() const { | 239 ShellURLRequestContextGetter::GetNetworkTaskRunner() const { |
240 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 240 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
241 } | 241 } |
242 | 242 |
243 net::HostResolver* ShellURLRequestContextGetter::host_resolver() { | 243 net::HostResolver* ShellURLRequestContextGetter::host_resolver() { |
244 return url_request_context_->host_resolver(); | 244 return url_request_context_->host_resolver(); |
245 } | 245 } |
246 | 246 |
247 } // namespace content | 247 } // namespace content |
OLD | NEW |