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 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 448 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
449 BrowserThread::PostTask( | 449 BrowserThread::PostTask( |
450 BrowserThread::IO, | 450 BrowserThread::IO, |
451 FROM_HERE, | 451 FROM_HERE, |
452 base::Bind(&IOThread::ChangedToOnTheRecordOnIOThread, | 452 base::Bind(&IOThread::ChangedToOnTheRecordOnIOThread, |
453 base::Unretained(this))); | 453 base::Unretained(this))); |
454 } | 454 } |
455 | 455 |
456 net::URLRequestContextGetter* IOThread::system_url_request_context_getter() { | 456 net::URLRequestContextGetter* IOThread::system_url_request_context_getter() { |
457 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 457 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
458 if (!system_url_request_context_getter_) { | 458 if (!system_url_request_context_getter_.get()) { |
459 InitSystemRequestContext(); | 459 InitSystemRequestContext(); |
460 } | 460 } |
461 return system_url_request_context_getter_; | 461 return system_url_request_context_getter_.get(); |
462 } | 462 } |
463 | 463 |
464 void IOThread::Init() { | 464 void IOThread::Init() { |
465 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 465 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
466 | 466 |
467 #if defined(USE_NSS) || defined(OS_IOS) | 467 #if defined(USE_NSS) || defined(OS_IOS) |
468 net::SetMessageLoopForNSSHttpIO(); | 468 net::SetMessageLoopForNSSHttpIO(); |
469 #endif | 469 #endif |
470 | 470 |
471 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 471 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 InitializeNetworkOptions(command_line); | 548 InitializeNetworkOptions(command_line); |
549 | 549 |
550 net::HttpNetworkSession::Params session_params; | 550 net::HttpNetworkSession::Params session_params; |
551 InitializeNetworkSessionParams(&session_params); | 551 InitializeNetworkSessionParams(&session_params); |
552 session_params.net_log = net_log_; | 552 session_params.net_log = net_log_; |
553 session_params.proxy_service = | 553 session_params.proxy_service = |
554 globals_->proxy_script_fetcher_proxy_service.get(); | 554 globals_->proxy_script_fetcher_proxy_service.get(); |
555 | 555 |
556 scoped_refptr<net::HttpNetworkSession> network_session( | 556 scoped_refptr<net::HttpNetworkSession> network_session( |
557 new net::HttpNetworkSession(session_params)); | 557 new net::HttpNetworkSession(session_params)); |
558 globals_->proxy_script_fetcher_http_transaction_factory.reset( | 558 globals_->proxy_script_fetcher_http_transaction_factory |
559 new net::HttpNetworkLayer(network_session)); | 559 .reset(new net::HttpNetworkLayer(network_session.get())); |
560 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory( | 560 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory( |
561 new net::URLRequestJobFactoryImpl()); | 561 new net::URLRequestJobFactoryImpl()); |
562 job_factory->SetProtocolHandler(chrome::kDataScheme, | 562 job_factory->SetProtocolHandler(chrome::kDataScheme, |
563 new net::DataProtocolHandler()); | 563 new net::DataProtocolHandler()); |
564 job_factory->SetProtocolHandler(chrome::kFileScheme, | 564 job_factory->SetProtocolHandler(chrome::kFileScheme, |
565 new net::FileProtocolHandler()); | 565 new net::FileProtocolHandler()); |
566 #if !defined(DISABLE_FTP_SUPPORT) | 566 #if !defined(DISABLE_FTP_SUPPORT) |
567 globals_->proxy_script_fetcher_ftp_transaction_factory.reset( | 567 globals_->proxy_script_fetcher_ftp_transaction_factory.reset( |
568 new net::FtpNetworkLayer(globals_->host_resolver.get())); | 568 new net::FtpNetworkLayer(globals_->host_resolver.get())); |
569 job_factory->SetProtocolHandler( | 569 job_factory->SetProtocolHandler( |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
880 | 880 |
881 void IOThread::ChangedToOnTheRecordOnIOThread() { | 881 void IOThread::ChangedToOnTheRecordOnIOThread() { |
882 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 882 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
883 | 883 |
884 // Clear the host cache to avoid showing entries from the OTR session | 884 // Clear the host cache to avoid showing entries from the OTR session |
885 // in about:net-internals. | 885 // in about:net-internals. |
886 ClearHostCache(); | 886 ClearHostCache(); |
887 } | 887 } |
888 | 888 |
889 void IOThread::InitSystemRequestContext() { | 889 void IOThread::InitSystemRequestContext() { |
890 if (system_url_request_context_getter_) | 890 if (system_url_request_context_getter_.get()) |
891 return; | 891 return; |
892 // If we're in unit_tests, IOThread may not be run. | 892 // If we're in unit_tests, IOThread may not be run. |
893 if (!BrowserThread::IsMessageLoopValid(BrowserThread::IO)) | 893 if (!BrowserThread::IsMessageLoopValid(BrowserThread::IO)) |
894 return; | 894 return; |
895 ChromeProxyConfigService* proxy_config_service = | 895 ChromeProxyConfigService* proxy_config_service = |
896 ProxyServiceFactory::CreateProxyConfigService(); | 896 ProxyServiceFactory::CreateProxyConfigService(); |
897 system_proxy_config_service_.reset(proxy_config_service); | 897 system_proxy_config_service_.reset(proxy_config_service); |
898 pref_proxy_config_tracker_->SetChromeProxyConfigService(proxy_config_service); | 898 pref_proxy_config_tracker_->SetChromeProxyConfigService(proxy_config_service); |
899 system_url_request_context_getter_ = | 899 system_url_request_context_getter_ = |
900 new SystemURLRequestContextGetter(this); | 900 new SystemURLRequestContextGetter(this); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
948 base::FieldTrialList::FindFullName(kQuicFieldTrialName); | 948 base::FieldTrialList::FindFullName(kQuicFieldTrialName); |
949 | 949 |
950 if (command_line.HasSwitch(switches::kDisableQuic)) | 950 if (command_line.HasSwitch(switches::kDisableQuic)) |
951 return false; | 951 return false; |
952 | 952 |
953 if (command_line.HasSwitch(switches::kEnableQuic)) | 953 if (command_line.HasSwitch(switches::kEnableQuic)) |
954 return true; | 954 return true; |
955 | 955 |
956 return quic_trial_group == kQuicFieldTrialEnabledGroupName; | 956 return quic_trial_group == kQuicFieldTrialEnabledGroupName; |
957 } | 957 } |
OLD | NEW |