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 "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 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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::Init() { |
467 TRACE_EVENT0("startup", "IOThread::Init"); | 467 // Prefer to use InitAsync unless you need initialization to block |
| 468 // the UI thread |
| 469 } |
| 470 |
| 471 void IOThread::InitAsync() { |
| 472 TRACE_EVENT0("startup", "IOThread::InitAsync"); |
468 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 473 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
469 | 474 |
470 #if defined(USE_NSS) || defined(OS_IOS) | 475 #if defined(USE_NSS) || defined(OS_IOS) |
471 net::SetMessageLoopForNSSHttpIO(); | 476 net::SetMessageLoopForNSSHttpIO(); |
472 #endif | 477 #endif |
473 | 478 |
474 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 479 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
475 | 480 |
476 DCHECK(!globals_); | 481 DCHECK(!globals_); |
477 globals_ = new Globals; | 482 globals_ = new Globals; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 globals_->system_server_bound_cert_service.reset( | 523 globals_->system_server_bound_cert_service.reset( |
519 new net::ServerBoundCertService( | 524 new net::ServerBoundCertService( |
520 new net::DefaultServerBoundCertStore(NULL), | 525 new net::DefaultServerBoundCertStore(NULL), |
521 base::WorkerPool::GetTaskRunner(true))); | 526 base::WorkerPool::GetTaskRunner(true))); |
522 globals_->dns_probe_service.reset(new chrome_browser_net::DnsProbeService()); | 527 globals_->dns_probe_service.reset(new chrome_browser_net::DnsProbeService()); |
523 globals_->load_time_stats.reset(new chrome_browser_net::LoadTimeStats()); | 528 globals_->load_time_stats.reset(new chrome_browser_net::LoadTimeStats()); |
524 globals_->host_mapping_rules.reset(new net::HostMappingRules()); | 529 globals_->host_mapping_rules.reset(new net::HostMappingRules()); |
525 globals_->http_user_agent_settings.reset( | 530 globals_->http_user_agent_settings.reset( |
526 new BasicHttpUserAgentSettings(std::string())); | 531 new BasicHttpUserAgentSettings(std::string())); |
527 if (command_line.HasSwitch(switches::kHostRules)) { | 532 if (command_line.HasSwitch(switches::kHostRules)) { |
528 TRACE_EVENT_BEGIN0("startup", "IOThread::Init:SetRulesFromString"); | 533 TRACE_EVENT_BEGIN0("startup", "IOThread::InitAsync:SetRulesFromString"); |
529 globals_->host_mapping_rules->SetRulesFromString( | 534 globals_->host_mapping_rules->SetRulesFromString( |
530 command_line.GetSwitchValueASCII(switches::kHostRules)); | 535 command_line.GetSwitchValueASCII(switches::kHostRules)); |
531 TRACE_EVENT_END0("startup", "IOThread::Init:SetRulesFromString"); | 536 TRACE_EVENT_END0("startup", "IOThread::InitAsync:SetRulesFromString"); |
532 } | 537 } |
533 if (command_line.HasSwitch(switches::kIgnoreCertificateErrors)) | 538 if (command_line.HasSwitch(switches::kIgnoreCertificateErrors)) |
534 globals_->ignore_certificate_errors = true; | 539 globals_->ignore_certificate_errors = true; |
535 if (command_line.HasSwitch(switches::kTestingFixedHttpPort)) { | 540 if (command_line.HasSwitch(switches::kTestingFixedHttpPort)) { |
536 globals_->testing_fixed_http_port = | 541 globals_->testing_fixed_http_port = |
537 GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpPort); | 542 GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpPort); |
538 } | 543 } |
539 if (command_line.HasSwitch(switches::kTestingFixedHttpsPort)) { | 544 if (command_line.HasSwitch(switches::kTestingFixedHttpsPort)) { |
540 globals_->testing_fixed_https_port = | 545 globals_->testing_fixed_https_port = |
541 GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpsPort); | 546 GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpsPort); |
(...skipping 15 matching lines...) Expand all Loading... |
557 globals_->enable_user_alternate_protocol_ports = true; | 562 globals_->enable_user_alternate_protocol_ports = true; |
558 } | 563 } |
559 InitializeNetworkOptions(command_line); | 564 InitializeNetworkOptions(command_line); |
560 | 565 |
561 net::HttpNetworkSession::Params session_params; | 566 net::HttpNetworkSession::Params session_params; |
562 InitializeNetworkSessionParams(&session_params); | 567 InitializeNetworkSessionParams(&session_params); |
563 session_params.net_log = net_log_; | 568 session_params.net_log = net_log_; |
564 session_params.proxy_service = | 569 session_params.proxy_service = |
565 globals_->proxy_script_fetcher_proxy_service.get(); | 570 globals_->proxy_script_fetcher_proxy_service.get(); |
566 | 571 |
567 TRACE_EVENT_BEGIN0("startup", "IOThread::Init:HttpNetworkSession"); | 572 TRACE_EVENT_BEGIN0("startup", "IOThread::InitAsync:HttpNetworkSession"); |
568 scoped_refptr<net::HttpNetworkSession> network_session( | 573 scoped_refptr<net::HttpNetworkSession> network_session( |
569 new net::HttpNetworkSession(session_params)); | 574 new net::HttpNetworkSession(session_params)); |
570 globals_->proxy_script_fetcher_http_transaction_factory | 575 globals_->proxy_script_fetcher_http_transaction_factory |
571 .reset(new net::HttpNetworkLayer(network_session.get())); | 576 .reset(new net::HttpNetworkLayer(network_session.get())); |
572 TRACE_EVENT_END0("startup", "IOThread::Init:HttpNetworkSession"); | 577 TRACE_EVENT_END0("startup", "IOThread::InitAsync:HttpNetworkSession"); |
573 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory( | 578 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory( |
574 new net::URLRequestJobFactoryImpl()); | 579 new net::URLRequestJobFactoryImpl()); |
575 job_factory->SetProtocolHandler(chrome::kDataScheme, | 580 job_factory->SetProtocolHandler(chrome::kDataScheme, |
576 new net::DataProtocolHandler()); | 581 new net::DataProtocolHandler()); |
577 job_factory->SetProtocolHandler(chrome::kFileScheme, | 582 job_factory->SetProtocolHandler(chrome::kFileScheme, |
578 new net::FileProtocolHandler()); | 583 new net::FileProtocolHandler()); |
579 #if !defined(DISABLE_FTP_SUPPORT) | 584 #if !defined(DISABLE_FTP_SUPPORT) |
580 globals_->proxy_script_fetcher_ftp_transaction_factory.reset( | 585 globals_->proxy_script_fetcher_ftp_transaction_factory.reset( |
581 new net::FtpNetworkLayer(globals_->host_resolver.get())); | 586 new net::FtpNetworkLayer(globals_->host_resolver.get())); |
582 job_factory->SetProtocolHandler( | 587 job_factory->SetProtocolHandler( |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
966 if (command_line.HasSwitch(switches::kDisableQuic)) | 971 if (command_line.HasSwitch(switches::kDisableQuic)) |
967 return false; | 972 return false; |
968 | 973 |
969 if (command_line.HasSwitch(switches::kEnableQuic) || | 974 if (command_line.HasSwitch(switches::kEnableQuic) || |
970 command_line.HasSwitch(switches::kEnableQuicHttps)) { | 975 command_line.HasSwitch(switches::kEnableQuicHttps)) { |
971 return true; | 976 return true; |
972 } | 977 } |
973 | 978 |
974 return quic_trial_group == kQuicFieldTrialEnabledGroupName; | 979 return quic_trial_group == kQuicFieldTrialEnabledGroupName; |
975 } | 980 } |
OLD | NEW |