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

Side by Side Diff: chrome/browser/io_thread.cc

Issue 18618004: Change BrowserThreadDelegate to run Init() async. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Init and InitAsync Created 7 years, 5 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 | Annotate | Revision Log
OLDNEW
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 "chrome/browser/io_thread.h" 5 #include "chrome/browser/io_thread.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 } 456 }
457 457
458 net::URLRequestContextGetter* IOThread::system_url_request_context_getter() { 458 net::URLRequestContextGetter* IOThread::system_url_request_context_getter() {
459 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 459 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
460 if (!system_url_request_context_getter_.get()) { 460 if (!system_url_request_context_getter_.get()) {
461 InitSystemRequestContext(); 461 InitSystemRequestContext();
462 } 462 }
463 return system_url_request_context_getter_.get(); 463 return system_url_request_context_getter_.get();
464 } 464 }
465 465
466 void IOThread::Init() { 466 void IOThread::InitAsync() {
467 TRACE_EVENT0("startup", "IOThread::Init"); 467 TRACE_EVENT0("startup", "IOThread::InitAsync");
468 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 468 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
469 469
470 #if defined(USE_NSS) || defined(OS_IOS) 470 #if defined(USE_NSS) || defined(OS_IOS)
471 net::SetMessageLoopForNSSHttpIO(); 471 net::SetMessageLoopForNSSHttpIO();
472 #endif 472 #endif
473 473
474 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 474 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
475 475
476 DCHECK(!globals_); 476 DCHECK(!globals_);
477 globals_ = new Globals; 477 globals_ = new Globals;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 globals_->system_server_bound_cert_service.reset( 518 globals_->system_server_bound_cert_service.reset(
519 new net::ServerBoundCertService( 519 new net::ServerBoundCertService(
520 new net::DefaultServerBoundCertStore(NULL), 520 new net::DefaultServerBoundCertStore(NULL),
521 base::WorkerPool::GetTaskRunner(true))); 521 base::WorkerPool::GetTaskRunner(true)));
522 globals_->dns_probe_service.reset(new chrome_browser_net::DnsProbeService()); 522 globals_->dns_probe_service.reset(new chrome_browser_net::DnsProbeService());
523 globals_->load_time_stats.reset(new chrome_browser_net::LoadTimeStats()); 523 globals_->load_time_stats.reset(new chrome_browser_net::LoadTimeStats());
524 globals_->host_mapping_rules.reset(new net::HostMappingRules()); 524 globals_->host_mapping_rules.reset(new net::HostMappingRules());
525 globals_->http_user_agent_settings.reset( 525 globals_->http_user_agent_settings.reset(
526 new BasicHttpUserAgentSettings(std::string())); 526 new BasicHttpUserAgentSettings(std::string()));
527 if (command_line.HasSwitch(switches::kHostRules)) { 527 if (command_line.HasSwitch(switches::kHostRules)) {
528 TRACE_EVENT_BEGIN0("startup", "IOThread::Init:SetRulesFromString"); 528 TRACE_EVENT_BEGIN0("startup", "IOThread::InitAsync:SetRulesFromString");
529 globals_->host_mapping_rules->SetRulesFromString( 529 globals_->host_mapping_rules->SetRulesFromString(
530 command_line.GetSwitchValueASCII(switches::kHostRules)); 530 command_line.GetSwitchValueASCII(switches::kHostRules));
531 TRACE_EVENT_END0("startup", "IOThread::Init:SetRulesFromString"); 531 TRACE_EVENT_END0("startup", "IOThread::InitAsync:SetRulesFromString");
532 } 532 }
533 if (command_line.HasSwitch(switches::kIgnoreCertificateErrors)) 533 if (command_line.HasSwitch(switches::kIgnoreCertificateErrors))
534 globals_->ignore_certificate_errors = true; 534 globals_->ignore_certificate_errors = true;
535 if (command_line.HasSwitch(switches::kTestingFixedHttpPort)) { 535 if (command_line.HasSwitch(switches::kTestingFixedHttpPort)) {
536 globals_->testing_fixed_http_port = 536 globals_->testing_fixed_http_port =
537 GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpPort); 537 GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpPort);
538 } 538 }
539 if (command_line.HasSwitch(switches::kTestingFixedHttpsPort)) { 539 if (command_line.HasSwitch(switches::kTestingFixedHttpsPort)) {
540 globals_->testing_fixed_https_port = 540 globals_->testing_fixed_https_port =
541 GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpsPort); 541 GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpsPort);
(...skipping 12 matching lines...) Expand all
554 globals_->enable_user_alternate_protocol_ports = true; 554 globals_->enable_user_alternate_protocol_ports = true;
555 } 555 }
556 InitializeNetworkOptions(command_line); 556 InitializeNetworkOptions(command_line);
557 557
558 net::HttpNetworkSession::Params session_params; 558 net::HttpNetworkSession::Params session_params;
559 InitializeNetworkSessionParams(&session_params); 559 InitializeNetworkSessionParams(&session_params);
560 session_params.net_log = net_log_; 560 session_params.net_log = net_log_;
561 session_params.proxy_service = 561 session_params.proxy_service =
562 globals_->proxy_script_fetcher_proxy_service.get(); 562 globals_->proxy_script_fetcher_proxy_service.get();
563 563
564 TRACE_EVENT_BEGIN0("startup", "IOThread::Init:HttpNetworkSession"); 564 TRACE_EVENT_BEGIN0("startup", "IOThread::InitAsync:HttpNetworkSession");
565 scoped_refptr<net::HttpNetworkSession> network_session( 565 scoped_refptr<net::HttpNetworkSession> network_session(
566 new net::HttpNetworkSession(session_params)); 566 new net::HttpNetworkSession(session_params));
567 globals_->proxy_script_fetcher_http_transaction_factory 567 globals_->proxy_script_fetcher_http_transaction_factory
568 .reset(new net::HttpNetworkLayer(network_session.get())); 568 .reset(new net::HttpNetworkLayer(network_session.get()));
569 TRACE_EVENT_END0("startup", "IOThread::Init:HttpNetworkSession"); 569 TRACE_EVENT_END0("startup", "IOThread::InitAsync:HttpNetworkSession");
570 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory( 570 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory(
571 new net::URLRequestJobFactoryImpl()); 571 new net::URLRequestJobFactoryImpl());
572 job_factory->SetProtocolHandler(chrome::kDataScheme, 572 job_factory->SetProtocolHandler(chrome::kDataScheme,
573 new net::DataProtocolHandler()); 573 new net::DataProtocolHandler());
574 job_factory->SetProtocolHandler(chrome::kFileScheme, 574 job_factory->SetProtocolHandler(chrome::kFileScheme,
575 new net::FileProtocolHandler()); 575 new net::FileProtocolHandler());
576 #if !defined(DISABLE_FTP_SUPPORT) 576 #if !defined(DISABLE_FTP_SUPPORT)
577 globals_->proxy_script_fetcher_ftp_transaction_factory.reset( 577 globals_->proxy_script_fetcher_ftp_transaction_factory.reset(
578 new net::FtpNetworkLayer(globals_->host_resolver.get())); 578 new net::FtpNetworkLayer(globals_->host_resolver.get()));
579 job_factory->SetProtocolHandler( 579 job_factory->SetProtocolHandler(
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 base::FieldTrialList::FindFullName(kQuicFieldTrialName); 960 base::FieldTrialList::FindFullName(kQuicFieldTrialName);
961 961
962 if (command_line.HasSwitch(switches::kDisableQuic)) 962 if (command_line.HasSwitch(switches::kDisableQuic))
963 return false; 963 return false;
964 964
965 if (command_line.HasSwitch(switches::kEnableQuic)) 965 if (command_line.HasSwitch(switches::kEnableQuic))
966 return true; 966 return true;
967 967
968 return quic_trial_group == kQuicFieldTrialEnabledGroupName; 968 return quic_trial_group == kQuicFieldTrialEnabledGroupName;
969 } 969 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698