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

Side by Side Diff: chromecast/browser/url_request_context_factory.cc

Issue 2656283002: [Chromecast] Enable QUIC for Chromecast. (Closed)
Patch Set: Created 3 years, 10 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
OLDNEW
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
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
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_;
halliwell 2017/01/27 04:32:53 how frequently does this get logged? Just want to
mbjorge 2017/01/27 06:22:20 It'll get logged a max of 3 times, once for each o
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
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)));
halliwell 2017/01/27 04:32:53 Should this be done with weak ptr, or is there a g
mbjorge 2017/01/27 06:22:20 URLRequestContextFactory is owned by CastContentBr
halliwell 2017/01/27 18:35:35 That's fine, looks good.
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 // Disable QUIC for any new URLContextGetter that gets created.
halliwell 2017/01/27 04:32:53 this and the next 3 comments don't add value (what
mbjorge 2017/01/27 06:22:20 done
449 enable_quic_ = false;
450
451 // Disable QUIC for the main URLContext.
452 if (main_getter_) {
453 main_getter_->GetURLRequestContext()
454 ->http_transaction_factory()
455 ->GetSession()
456 ->DisableQuic();
457 }
458
459 // Disable QUIC for the system URLContext.
460 if (system_getter_) {
461 system_getter_->GetURLRequestContext()
462 ->http_transaction_factory()
463 ->GetSession()
464 ->DisableQuic();
465 }
466
467 // Disable QUIC for the media URLContext.
468 if (media_getter_) {
469 media_getter_->GetURLRequestContext()
470 ->http_transaction_factory()
471 ->GetSession()
472 ->DisableQuic();
473 }
474 }
475
430 } // namespace shell 476 } // namespace shell
431 } // namespace chromecast 477 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698