| OLD | NEW |
| 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 "net/base/cert_verifier.h" | 17 #include "net/base/cert_verifier.h" |
| 17 #include "net/base/default_server_bound_cert_store.h" | 18 #include "net/base/default_server_bound_cert_store.h" |
| 18 #include "net/base/host_resolver.h" | 19 #include "net/base/host_resolver.h" |
| 19 #include "net/base/mapped_host_resolver.h" | 20 #include "net/base/mapped_host_resolver.h" |
| 20 #include "net/base/server_bound_cert_service.h" | 21 #include "net/base/server_bound_cert_service.h" |
| 21 #include "net/base/ssl_config_service_defaults.h" | 22 #include "net/base/ssl_config_service_defaults.h" |
| 22 #include "net/cookies/cookie_monster.h" | 23 #include "net/cookies/cookie_monster.h" |
| 23 #include "net/http/http_auth_handler_factory.h" | 24 #include "net/http/http_auth_handler_factory.h" |
| 24 #include "net/http/http_cache.h" | 25 #include "net/http/http_cache.h" |
| 25 #include "net/http/http_network_session.h" | 26 #include "net/http/http_network_session.h" |
| 26 #include "net/http/http_server_properties_impl.h" | 27 #include "net/http/http_server_properties_impl.h" |
| 27 #include "net/proxy/proxy_service.h" | 28 #include "net/proxy/proxy_service.h" |
| 28 #include "net/url_request/static_http_user_agent_settings.h" | 29 #include "net/url_request/static_http_user_agent_settings.h" |
| 29 #include "net/url_request/url_request_context.h" | 30 #include "net/url_request/url_request_context.h" |
| 30 #include "net/url_request/url_request_context_storage.h" | 31 #include "net/url_request/url_request_context_storage.h" |
| 31 #include "net/url_request/url_request_job_factory_impl.h" | 32 #include "net/url_request/url_request_job_factory_impl.h" |
| 32 | 33 |
| 33 namespace content { | 34 namespace content { |
| 34 | 35 |
| 35 ShellURLRequestContextGetter::ShellURLRequestContextGetter( | 36 ShellURLRequestContextGetter::ShellURLRequestContextGetter( |
| 36 bool ignore_certificate_errors, | 37 bool ignore_certificate_errors, |
| 37 const FilePath& base_path, | 38 const FilePath& base_path, |
| 38 MessageLoop* io_loop, | 39 MessageLoop* io_loop, |
| 39 MessageLoop* file_loop) | 40 MessageLoop* file_loop, |
| 41 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 42 blob_protocol_handler, |
| 43 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
| 44 file_system_protocol_handler, |
| 45 scoped_ptr<net::URLRequestJobFactory::Interceptor> |
| 46 developer_protocol_handler) |
| 40 : ignore_certificate_errors_(ignore_certificate_errors), | 47 : ignore_certificate_errors_(ignore_certificate_errors), |
| 41 base_path_(base_path), | 48 base_path_(base_path), |
| 42 io_loop_(io_loop), | 49 io_loop_(io_loop), |
| 43 file_loop_(file_loop) { | 50 file_loop_(file_loop), |
| 51 blob_protocol_handler_(blob_protocol_handler.Pass()), |
| 52 file_system_protocol_handler_(file_system_protocol_handler.Pass()), |
| 53 developer_protocol_handler_(developer_protocol_handler.Pass()) { |
| 44 // Must first be created on the UI thread. | 54 // Must first be created on the UI thread. |
| 45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 55 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 46 | 56 |
| 47 // We must create the proxy config service on the UI loop on Linux because it | 57 // We must create the proxy config service on the UI loop on Linux because it |
| 48 // must synchronously run on the glib message loop. This will be passed to | 58 // must synchronously run on the glib message loop. This will be passed to |
| 49 // the URLRequestContextStorage on the IO thread in GetURLRequestContext(). | 59 // the URLRequestContextStorage on the IO thread in GetURLRequestContext(). |
| 50 proxy_config_service_.reset( | 60 proxy_config_service_.reset( |
| 51 net::ProxyService::CreateSystemProxyConfigService( | 61 net::ProxyService::CreateSystemProxyConfigService( |
| 52 io_loop_->message_loop_proxy(), file_loop_)); | 62 io_loop_->message_loop_proxy(), file_loop_)); |
| 53 } | 63 } |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 | 147 |
| 138 // Give |storage_| ownership at the end in case it's |mapped_host_resolver|. | 148 // Give |storage_| ownership at the end in case it's |mapped_host_resolver|. |
| 139 storage_->set_host_resolver(host_resolver.Pass()); | 149 storage_->set_host_resolver(host_resolver.Pass()); |
| 140 network_session_params.host_resolver = | 150 network_session_params.host_resolver = |
| 141 url_request_context_->host_resolver(); | 151 url_request_context_->host_resolver(); |
| 142 | 152 |
| 143 net::HttpCache* main_cache = new net::HttpCache( | 153 net::HttpCache* main_cache = new net::HttpCache( |
| 144 network_session_params, main_backend); | 154 network_session_params, main_backend); |
| 145 storage_->set_http_transaction_factory(main_cache); | 155 storage_->set_http_transaction_factory(main_cache); |
| 146 | 156 |
| 147 storage_->set_job_factory(new net::URLRequestJobFactoryImpl); | 157 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory( |
| 158 new net::URLRequestJobFactoryImpl()); |
| 159 job_factory->SetProtocolHandler( |
| 160 chrome::kBlobScheme, blob_protocol_handler_.release()); |
| 161 job_factory->SetProtocolHandler( |
| 162 chrome::kFileSystemScheme, file_system_protocol_handler_.release()); |
| 163 job_factory->AddInterceptor(developer_protocol_handler_.release()); |
| 164 storage_->set_job_factory(job_factory.release()); |
| 148 } | 165 } |
| 149 | 166 |
| 150 return url_request_context_.get(); | 167 return url_request_context_.get(); |
| 151 } | 168 } |
| 152 | 169 |
| 153 scoped_refptr<base::SingleThreadTaskRunner> | 170 scoped_refptr<base::SingleThreadTaskRunner> |
| 154 ShellURLRequestContextGetter::GetNetworkTaskRunner() const { | 171 ShellURLRequestContextGetter::GetNetworkTaskRunner() const { |
| 155 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | 172 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
| 156 } | 173 } |
| 157 | 174 |
| 158 net::HostResolver* ShellURLRequestContextGetter::host_resolver() { | 175 net::HostResolver* ShellURLRequestContextGetter::host_resolver() { |
| 159 return url_request_context_->host_resolver(); | 176 return url_request_context_->host_resolver(); |
| 160 } | 177 } |
| 161 | 178 |
| 162 } // namespace content | 179 } // namespace content |
| OLD | NEW |