OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chromecast/shell/browser/url_request_context_factory.h" | 5 #include "chromecast/shell/browser/url_request_context_factory.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
11 #include "base/threading/worker_pool.h" | 11 #include "base/threading/worker_pool.h" |
| 12 #include "chromecast/service/cast_network_delegate.h" |
12 #include "chromecast/shell/browser/cast_http_user_agent_settings.h" | 13 #include "chromecast/shell/browser/cast_http_user_agent_settings.h" |
13 #include "content/public/browser/browser_context.h" | 14 #include "content/public/browser/browser_context.h" |
14 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
15 #include "content/public/browser/cookie_store_factory.h" | 16 #include "content/public/browser/cookie_store_factory.h" |
16 #include "content/public/common/content_switches.h" | 17 #include "content/public/common/content_switches.h" |
17 #include "content/public/common/url_constants.h" | 18 #include "content/public/common/url_constants.h" |
18 #include "net/cert/cert_verifier.h" | 19 #include "net/cert/cert_verifier.h" |
19 #include "net/cookies/cookie_store.h" | 20 #include "net/cookies/cookie_store.h" |
20 #include "net/dns/host_resolver.h" | 21 #include "net/dns/host_resolver.h" |
21 #include "net/http/http_auth_handler_factory.h" | 22 #include "net/http/http_auth_handler_factory.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 content::BrowserContext* const browser_context_; | 127 content::BrowserContext* const browser_context_; |
127 URLRequestContextFactory* const factory_; | 128 URLRequestContextFactory* const factory_; |
128 content::ProtocolHandlerMap protocol_handlers_; | 129 content::ProtocolHandlerMap protocol_handlers_; |
129 content::URLRequestInterceptorScopedVector request_interceptors_; | 130 content::URLRequestInterceptorScopedVector request_interceptors_; |
130 scoped_ptr<net::URLRequestContext> request_context_; | 131 scoped_ptr<net::URLRequestContext> request_context_; |
131 | 132 |
132 DISALLOW_COPY_AND_ASSIGN(MainURLRequestContextGetter); | 133 DISALLOW_COPY_AND_ASSIGN(MainURLRequestContextGetter); |
133 }; | 134 }; |
134 | 135 |
135 URLRequestContextFactory::URLRequestContextFactory() | 136 URLRequestContextFactory::URLRequestContextFactory() |
136 : system_dependencies_initialized_(false), | 137 : app_network_delegate_(CastNetworkDelegate::Create()), |
| 138 system_network_delegate_(CastNetworkDelegate::Create()), |
| 139 system_dependencies_initialized_(false), |
137 main_dependencies_initialized_(false), | 140 main_dependencies_initialized_(false), |
138 media_dependencies_initialized_(false) { | 141 media_dependencies_initialized_(false) { |
139 } | 142 } |
140 | 143 |
141 URLRequestContextFactory::~URLRequestContextFactory() { | 144 URLRequestContextFactory::~URLRequestContextFactory() { |
142 } | 145 } |
143 | 146 |
144 void URLRequestContextFactory::InitializeOnUIThread() { | 147 void URLRequestContextFactory::InitializeOnUIThread() { |
145 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 148 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
146 // Cast http user agent settings must be initialized in UI thread | 149 // Cast http user agent settings must be initialized in UI thread |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 system_context->set_http_auth_handler_factory( | 318 system_context->set_http_auth_handler_factory( |
316 http_auth_handler_factory_.get()); | 319 http_auth_handler_factory_.get()); |
317 system_context->set_http_server_properties( | 320 system_context->set_http_server_properties( |
318 http_server_properties_->GetWeakPtr()); | 321 http_server_properties_->GetWeakPtr()); |
319 system_context->set_http_transaction_factory( | 322 system_context->set_http_transaction_factory( |
320 system_transaction_factory_.get()); | 323 system_transaction_factory_.get()); |
321 system_context->set_http_user_agent_settings( | 324 system_context->set_http_user_agent_settings( |
322 http_user_agent_settings_.get()); | 325 http_user_agent_settings_.get()); |
323 system_context->set_cookie_store( | 326 system_context->set_cookie_store( |
324 content::CreateCookieStore(content::CookieStoreConfig())); | 327 content::CreateCookieStore(content::CookieStoreConfig())); |
| 328 system_context->set_network_delegate(system_network_delegate_.get()); |
325 return system_context; | 329 return system_context; |
326 } | 330 } |
327 | 331 |
328 net::URLRequestContext* URLRequestContextFactory::CreateMediaRequestContext() { | 332 net::URLRequestContext* URLRequestContextFactory::CreateMediaRequestContext() { |
329 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 333 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
330 DCHECK(main_getter_.get()) | 334 DCHECK(main_getter_.get()) |
331 << "Getting MediaRequestContext before MainRequestContext"; | 335 << "Getting MediaRequestContext before MainRequestContext"; |
332 net::URLRequestContext* main_context = main_getter_->GetURLRequestContext(); | 336 net::URLRequestContext* main_context = main_getter_->GetURLRequestContext(); |
333 | 337 |
334 // Set non caching backend. | 338 // Set non caching backend. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 http_auth_handler_factory_.get()); | 391 http_auth_handler_factory_.get()); |
388 main_context->set_http_server_properties( | 392 main_context->set_http_server_properties( |
389 http_server_properties_->GetWeakPtr()); | 393 http_server_properties_->GetWeakPtr()); |
390 main_context->set_cookie_store(cookie_store.get()); | 394 main_context->set_cookie_store(cookie_store.get()); |
391 main_context->set_http_user_agent_settings( | 395 main_context->set_http_user_agent_settings( |
392 http_user_agent_settings_.get()); | 396 http_user_agent_settings_.get()); |
393 | 397 |
394 main_context->set_http_transaction_factory( | 398 main_context->set_http_transaction_factory( |
395 main_transaction_factory_.get()); | 399 main_transaction_factory_.get()); |
396 main_context->set_job_factory(main_job_factory_.get()); | 400 main_context->set_job_factory(main_job_factory_.get()); |
| 401 main_context->set_network_delegate(app_network_delegate_.get()); |
397 return main_context; | 402 return main_context; |
398 } | 403 } |
399 | 404 |
| 405 void URLRequestContextFactory::InitializeNetworkDelegates() { |
| 406 app_network_delegate_->Initialize(false); |
| 407 LOG(INFO) << "Initialized app network delegate."; |
| 408 system_network_delegate_->Initialize(false); |
| 409 LOG(INFO) << "Initialized system network delegate."; |
| 410 } |
| 411 |
400 } // namespace shell | 412 } // namespace shell |
401 } // namespace chromecast | 413 } // namespace chromecast |
OLD | NEW |