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/browser/url_request_context_factory.h" | 5 #include "chromecast/browser/url_request_context_factory.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 std::unique_ptr<net::URLRequestContext> request_context_; | 158 std::unique_ptr<net::URLRequestContext> request_context_; |
159 | 159 |
160 DISALLOW_COPY_AND_ASSIGN(MainURLRequestContextGetter); | 160 DISALLOW_COPY_AND_ASSIGN(MainURLRequestContextGetter); |
161 }; | 161 }; |
162 | 162 |
163 URLRequestContextFactory::URLRequestContextFactory() | 163 URLRequestContextFactory::URLRequestContextFactory() |
164 : app_network_delegate_(CastNetworkDelegate::Create()), | 164 : app_network_delegate_(CastNetworkDelegate::Create()), |
165 system_network_delegate_(CastNetworkDelegate::Create()), | 165 system_network_delegate_(CastNetworkDelegate::Create()), |
166 system_dependencies_initialized_(false), | 166 system_dependencies_initialized_(false), |
167 main_dependencies_initialized_(false), | 167 main_dependencies_initialized_(false), |
168 media_dependencies_initialized_(false) { | 168 media_dependencies_initialized_(false), |
169 } | 169 enable_quic_(true) {} |
170 | 170 |
171 URLRequestContextFactory::~URLRequestContextFactory() { | 171 URLRequestContextFactory::~URLRequestContextFactory() { |
172 } | 172 } |
173 | 173 |
174 void URLRequestContextFactory::InitializeOnUIThread(net::NetLog* net_log) { | 174 void URLRequestContextFactory::InitializeOnUIThread(net::NetLog* net_log) { |
175 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 175 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
176 // Cast http user agent settings must be initialized in UI thread | 176 // Cast http user agent settings must be initialized in UI thread |
177 // because it registers itself to pref notification observer which is not | 177 // because it registers itself to pref notification observer which is not |
178 // thread safe. | 178 // thread safe. |
179 http_user_agent_settings_.reset(new CastHttpUserAgentSettings()); | 179 http_user_agent_settings_.reset(new CastHttpUserAgentSettings()); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 if (media_dependencies_initialized_) | 300 if (media_dependencies_initialized_) |
301 return; | 301 return; |
302 | 302 |
303 media_transaction_factory_.reset(transaction_factory); | 303 media_transaction_factory_.reset(transaction_factory); |
304 media_dependencies_initialized_ = true; | 304 media_dependencies_initialized_ = true; |
305 } | 305 } |
306 | 306 |
307 void URLRequestContextFactory::PopulateNetworkSessionParams( | 307 void URLRequestContextFactory::PopulateNetworkSessionParams( |
308 bool ignore_certificate_errors, | 308 bool ignore_certificate_errors, |
309 net::HttpNetworkSession::Params* params) { | 309 net::HttpNetworkSession::Params* params) { |
| 310 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
310 params->host_resolver = host_resolver_.get(); | 311 params->host_resolver = host_resolver_.get(); |
311 params->cert_verifier = cert_verifier_.get(); | 312 params->cert_verifier = cert_verifier_.get(); |
312 params->channel_id_service = channel_id_service_.get(); | 313 params->channel_id_service = channel_id_service_.get(); |
313 params->ssl_config_service = ssl_config_service_.get(); | 314 params->ssl_config_service = ssl_config_service_.get(); |
314 params->transport_security_state = transport_security_state_.get(); | 315 params->transport_security_state = transport_security_state_.get(); |
315 params->cert_transparency_verifier = cert_transparency_verifier_.get(); | 316 params->cert_transparency_verifier = cert_transparency_verifier_.get(); |
316 params->ct_policy_enforcer = ct_policy_enforcer_.get(); | 317 params->ct_policy_enforcer = ct_policy_enforcer_.get(); |
317 params->http_auth_handler_factory = http_auth_handler_factory_.get(); | 318 params->http_auth_handler_factory = http_auth_handler_factory_.get(); |
318 params->http_server_properties = http_server_properties_.get(); | 319 params->http_server_properties = http_server_properties_.get(); |
319 params->ignore_certificate_errors = ignore_certificate_errors; | 320 params->ignore_certificate_errors = ignore_certificate_errors; |
320 params->proxy_service = proxy_service_.get(); | 321 params->proxy_service = proxy_service_.get(); |
| 322 |
| 323 LOG(INFO) << "Set HttpNetworkSessionParams.enable_quic = " << enable_quic_; |
| 324 params->enable_quic = enable_quic_; |
321 } | 325 } |
322 | 326 |
323 net::URLRequestContext* URLRequestContextFactory::CreateSystemRequestContext() { | 327 net::URLRequestContext* URLRequestContextFactory::CreateSystemRequestContext() { |
324 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 328 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
325 InitializeSystemContextDependencies(); | 329 InitializeSystemContextDependencies(); |
326 net::HttpNetworkSession::Params system_params; | 330 net::HttpNetworkSession::Params system_params; |
327 PopulateNetworkSessionParams(false, &system_params); | 331 PopulateNetworkSessionParams(false, &system_params); |
328 system_transaction_factory_.reset(new net::HttpNetworkLayer( | 332 system_transaction_factory_.reset(new net::HttpNetworkLayer( |
329 new net::HttpNetworkSession(system_params))); | 333 new net::HttpNetworkSession(system_params))); |
330 system_job_factory_.reset(new net::URLRequestJobFactoryImpl()); | 334 system_job_factory_.reset(new net::URLRequestJobFactoryImpl()); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 return main_context; | 424 return main_context; |
421 } | 425 } |
422 | 426 |
423 void URLRequestContextFactory::InitializeNetworkDelegates() { | 427 void URLRequestContextFactory::InitializeNetworkDelegates() { |
424 app_network_delegate_->Initialize(false); | 428 app_network_delegate_->Initialize(false); |
425 LOG(INFO) << "Initialized app network delegate."; | 429 LOG(INFO) << "Initialized app network delegate."; |
426 system_network_delegate_->Initialize(false); | 430 system_network_delegate_->Initialize(false); |
427 LOG(INFO) << "Initialized system network delegate."; | 431 LOG(INFO) << "Initialized system network delegate."; |
428 } | 432 } |
429 | 433 |
| 434 void URLRequestContextFactory::DisableQuic() { |
| 435 content::BrowserThread::PostTask( |
| 436 content::BrowserThread::IO, FROM_HERE, |
| 437 base::Bind(&URLRequestContextFactory::DisableQuicOnBrowserIOThread, |
| 438 base::Unretained(this))); |
| 439 } |
| 440 |
| 441 void URLRequestContextFactory::DisableQuicOnBrowserIOThread() { |
| 442 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 443 if (!enable_quic_) |
| 444 return; |
| 445 |
| 446 LOG(INFO) << "Disabled QUIC."; |
| 447 |
| 448 enable_quic_ = false; |
| 449 |
| 450 if (main_getter_) { |
| 451 main_getter_->GetURLRequestContext() |
| 452 ->http_transaction_factory() |
| 453 ->GetSession() |
| 454 ->DisableQuic(); |
| 455 } |
| 456 |
| 457 if (system_getter_) { |
| 458 system_getter_->GetURLRequestContext() |
| 459 ->http_transaction_factory() |
| 460 ->GetSession() |
| 461 ->DisableQuic(); |
| 462 } |
| 463 |
| 464 if (media_getter_) { |
| 465 media_getter_->GetURLRequestContext() |
| 466 ->http_transaction_factory() |
| 467 ->GetSession() |
| 468 ->DisableQuic(); |
| 469 } |
| 470 } |
| 471 |
430 } // namespace shell | 472 } // namespace shell |
431 } // namespace chromecast | 473 } // namespace chromecast |
OLD | NEW |