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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 #include "net/http/http_auth_handler_factory.h" | 53 #include "net/http/http_auth_handler_factory.h" |
54 #include "net/http/http_network_layer.h" | 54 #include "net/http/http_network_layer.h" |
55 #include "net/http/http_network_session.h" | 55 #include "net/http/http_network_session.h" |
56 #include "net/http/http_server_properties_impl.h" | 56 #include "net/http/http_server_properties_impl.h" |
57 #include "net/proxy/proxy_config_service.h" | 57 #include "net/proxy/proxy_config_service.h" |
58 #include "net/proxy/proxy_script_fetcher_impl.h" | 58 #include "net/proxy/proxy_script_fetcher_impl.h" |
59 #include "net/proxy/proxy_service.h" | 59 #include "net/proxy/proxy_service.h" |
60 #include "net/url_request/url_fetcher.h" | 60 #include "net/url_request/url_fetcher.h" |
61 #include "net/url_request/url_request_throttler_manager.h" | 61 #include "net/url_request/url_request_throttler_manager.h" |
62 | 62 |
63 #if defined(USE_NSS) | 63 #if defined(USE_NSS) || defined(OS_IOS) |
64 #include "net/ocsp/nss_ocsp.h" | 64 #include "net/ocsp/nss_ocsp.h" |
65 #endif // defined(USE_NSS) | 65 #endif // defined(USE_NSS) || defined(OS_IOS) |
wtc
2012/11/29 19:24:33
Please let me know if you prefer that I simply rem
Ryan Sleevi
2012/11/29 20:35:13
Agreed
| |
66 | 66 |
67 #if defined(OS_CHROMEOS) | 67 #if defined(OS_CHROMEOS) |
68 #include "chrome/browser/chromeos/proxy_config_service_impl.h" | 68 #include "chrome/browser/chromeos/proxy_config_service_impl.h" |
69 #endif // defined(OS_CHROMEOS) | 69 #endif // defined(OS_CHROMEOS) |
70 | 70 |
71 using content::BrowserThread; | 71 using content::BrowserThread; |
72 | 72 |
73 class SafeBrowsingURLRequestContext; | 73 class SafeBrowsingURLRequestContext; |
74 | 74 |
75 // The IOThread object must outlive any tasks posted to the IO thread before the | 75 // The IOThread object must outlive any tasks posted to the IO thread before the |
76 // Quit task, so base::Bind() calls are not refcounted. | 76 // Quit task, so base::Bind() calls are not refcounted. |
77 | 77 |
78 namespace { | 78 namespace { |
79 | 79 |
80 #if defined(OS_MACOSX) && !defined(OS_IOS) | 80 #if defined(OS_MACOSX) && !defined(OS_IOS) |
81 void ObserveKeychainEvents() { | 81 void ObserveKeychainEvents() { |
82 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 82 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
83 net::CertDatabase::GetInstance()->SetMessageLoopForKeychainEvents(); | 83 net::CertDatabase::GetInstance()->SetMessageLoopForKeychainEvents(); |
84 } | 84 } |
85 #endif | 85 #endif |
86 | 86 |
87 // Used for the "system" URLRequestContext. | 87 // Used for the "system" URLRequestContext. |
88 class SystemURLRequestContext : public net::URLRequestContext { | 88 class SystemURLRequestContext : public net::URLRequestContext { |
89 public: | 89 public: |
90 SystemURLRequestContext() { | 90 SystemURLRequestContext() { |
91 #if defined(USE_NSS) | 91 #if defined(USE_NSS) || defined(OS_IOS) |
92 net::SetURLRequestContextForNSSHttpIO(this); | 92 net::SetURLRequestContextForNSSHttpIO(this); |
93 #endif // defined(USE_NSS) | 93 #endif // defined(USE_NSS) || defined(OS_IOS) |
94 } | 94 } |
95 | 95 |
96 private: | 96 private: |
97 virtual ~SystemURLRequestContext() { | 97 virtual ~SystemURLRequestContext() { |
98 #if defined(USE_NSS) | 98 #if defined(USE_NSS) || defined(OS_IOS) |
99 net::SetURLRequestContextForNSSHttpIO(NULL); | 99 net::SetURLRequestContextForNSSHttpIO(NULL); |
100 #endif // defined(USE_NSS) | 100 #endif // defined(USE_NSS) || defined(OS_IOS) |
101 } | 101 } |
102 }; | 102 }; |
103 | 103 |
104 scoped_ptr<net::HostResolver> CreateGlobalHostResolver(net::NetLog* net_log) { | 104 scoped_ptr<net::HostResolver> CreateGlobalHostResolver(net::NetLog* net_log) { |
105 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 105 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
106 | 106 |
107 bool allow_async_dns_field_trial = true; | 107 bool allow_async_dns_field_trial = true; |
108 | 108 |
109 net::HostResolver::Options options; | 109 net::HostResolver::Options options; |
110 | 110 |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
405 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 405 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
406 if (!system_url_request_context_getter_) { | 406 if (!system_url_request_context_getter_) { |
407 InitSystemRequestContext(); | 407 InitSystemRequestContext(); |
408 } | 408 } |
409 return system_url_request_context_getter_; | 409 return system_url_request_context_getter_; |
410 } | 410 } |
411 | 411 |
412 void IOThread::Init() { | 412 void IOThread::Init() { |
413 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 413 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
414 | 414 |
415 #if defined(USE_NSS) | 415 #if defined(USE_NSS) || defined(OS_IOS) |
416 net::SetMessageLoopForNSSHttpIO(); | 416 net::SetMessageLoopForNSSHttpIO(); |
417 #endif // defined(USE_NSS) | 417 #endif // defined(USE_NSS) || defined(OS_IOS) |
418 | 418 |
419 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 419 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
420 | 420 |
421 DCHECK(!globals_); | 421 DCHECK(!globals_); |
422 globals_ = new Globals; | 422 globals_ = new Globals; |
423 | 423 |
424 // Add an observer that will emit network change events to the ChromeNetLog. | 424 // Add an observer that will emit network change events to the ChromeNetLog. |
425 // Assuming NetworkChangeNotifier dispatches in FIFO order, we should be | 425 // Assuming NetworkChangeNotifier dispatches in FIFO order, we should be |
426 // logging the network change before other IO thread consumers respond to it. | 426 // logging the network change before other IO thread consumers respond to it. |
427 network_change_observer_.reset( | 427 network_change_observer_.reset( |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
568 // error. | 568 // error. |
569 weak_factory_.DetachFromThread(); | 569 weak_factory_.DetachFromThread(); |
570 } | 570 } |
571 | 571 |
572 void IOThread::CleanUp() { | 572 void IOThread::CleanUp() { |
573 base::debug::LeakTracker<SafeBrowsingURLRequestContext>::CheckForLeaks(); | 573 base::debug::LeakTracker<SafeBrowsingURLRequestContext>::CheckForLeaks(); |
574 | 574 |
575 delete sdch_manager_; | 575 delete sdch_manager_; |
576 sdch_manager_ = NULL; | 576 sdch_manager_ = NULL; |
577 | 577 |
578 #if defined(USE_NSS) | 578 #if defined(USE_NSS) || defined(OS_IOS) |
579 net::ShutdownNSSHttpIO(); | 579 net::ShutdownNSSHttpIO(); |
580 #endif // defined(USE_NSS) | 580 #endif // defined(USE_NSS) || defined(OS_IOS) |
581 | 581 |
582 system_url_request_context_getter_ = NULL; | 582 system_url_request_context_getter_ = NULL; |
583 | 583 |
584 // Release objects that the net::URLRequestContext could have been pointing | 584 // Release objects that the net::URLRequestContext could have been pointing |
585 // to. | 585 // to. |
586 | 586 |
587 // This must be reset before the ChromeNetLog is destroyed. | 587 // This must be reset before the ChromeNetLog is destroyed. |
588 network_change_observer_.reset(); | 588 network_change_observer_.reset(); |
589 | 589 |
590 system_proxy_config_service_.reset(); | 590 system_proxy_config_service_.reset(); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
734 new net::HttpNetworkLayer( | 734 new net::HttpNetworkLayer( |
735 new net::HttpNetworkSession(system_params))); | 735 new net::HttpNetworkSession(system_params))); |
736 globals_->system_ftp_transaction_factory.reset( | 736 globals_->system_ftp_transaction_factory.reset( |
737 new net::FtpNetworkLayer(globals_->host_resolver.get())); | 737 new net::FtpNetworkLayer(globals_->host_resolver.get())); |
738 globals_->system_request_context.reset( | 738 globals_->system_request_context.reset( |
739 ConstructSystemRequestContext(globals_, net_log_)); | 739 ConstructSystemRequestContext(globals_, net_log_)); |
740 | 740 |
741 sdch_manager_->set_sdch_fetcher( | 741 sdch_manager_->set_sdch_fetcher( |
742 new SdchDictionaryFetcher(system_url_request_context_getter_.get())); | 742 new SdchDictionaryFetcher(system_url_request_context_getter_.get())); |
743 } | 743 } |
OLD | NEW |