OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_IO_THREAD_H_ | 5 #ifndef CHROME_BROWSER_IO_THREAD_H_ |
6 #define CHROME_BROWSER_IO_THREAD_H_ | 6 #define CHROME_BROWSER_IO_THREAD_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <list> | 9 #include <list> |
10 #include <string> | 10 #include <string> |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/ref_counted.h" | 12 #include "base/ref_counted.h" |
13 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
14 #include "chrome/browser/browser_process_sub_thread.h" | 14 #include "chrome/browser/browser_process_sub_thread.h" |
15 #include "chrome/browser/net/chrome_network_delegate.h" | 15 #include "chrome/browser/net/chrome_network_delegate.h" |
16 #include "chrome/common/net/predictor_common.h" | 16 #include "chrome/common/net/predictor_common.h" |
17 #include "net/base/network_change_notifier.h" | 17 #include "net/base/network_change_notifier.h" |
18 | 18 |
19 class ChromeNetLog; | 19 class ChromeNetLog; |
20 class ChromeURLRequestContextGetter; | 20 class ChromeURLRequestContextGetter; |
21 class ListValue; | 21 class ListValue; |
| 22 class PrefProxyConfigTracker; |
22 class PrefService; | 23 class PrefService; |
| 24 class URLRequestContextGetter; |
23 | 25 |
24 namespace chrome_browser_net { | 26 namespace chrome_browser_net { |
25 class ConnectInterceptor; | 27 class ConnectInterceptor; |
26 class Predictor; | 28 class Predictor; |
27 } // namespace chrome_browser_net | 29 } // namespace chrome_browser_net |
28 | 30 |
29 namespace net { | 31 namespace net { |
30 class CertVerifier; | 32 class CertVerifier; |
31 class DnsRRResolver; | 33 class DnsRRResolver; |
32 class HostResolver; | 34 class HostResolver; |
33 class HttpAuthHandlerFactory; | 35 class HttpAuthHandlerFactory; |
34 class HttpTransactionFactory; | 36 class HttpTransactionFactory; |
| 37 class ProxyConfigService; |
35 class ProxyScriptFetcher; | 38 class ProxyScriptFetcher; |
36 class ProxyService; | 39 class ProxyService; |
37 class SSLConfigService; | 40 class SSLConfigService; |
38 class URLRequestContext; | 41 class URLRequestContext; |
39 class URLSecurityManager; | 42 class URLSecurityManager; |
40 } // namespace net | 43 } // namespace net |
41 | 44 |
42 class IOThread : public BrowserProcessSubThread { | 45 class IOThread : public BrowserProcessSubThread { |
43 public: | 46 public: |
44 struct Globals { | 47 struct Globals { |
45 Globals(); | 48 Globals(); |
46 ~Globals(); | 49 ~Globals(); |
47 | 50 |
48 scoped_ptr<net::HostResolver> host_resolver; | 51 scoped_ptr<net::HostResolver> host_resolver; |
49 scoped_ptr<net::CertVerifier> cert_verifier; | 52 scoped_ptr<net::CertVerifier> cert_verifier; |
50 scoped_ptr<net::DnsRRResolver> dnsrr_resolver; | 53 scoped_ptr<net::DnsRRResolver> dnsrr_resolver; |
51 scoped_refptr<net::SSLConfigService> ssl_config_service; | 54 scoped_refptr<net::SSLConfigService> ssl_config_service; |
52 scoped_ptr<net::HttpAuthHandlerFactory> http_auth_handler_factory; | 55 scoped_ptr<net::HttpAuthHandlerFactory> http_auth_handler_factory; |
53 scoped_refptr<net::ProxyService> proxy_script_fetcher_proxy_service; | 56 scoped_refptr<net::ProxyService> proxy_script_fetcher_proxy_service; |
54 scoped_ptr<net::HttpTransactionFactory> | 57 scoped_ptr<net::HttpTransactionFactory> |
55 proxy_script_fetcher_http_transaction_factory; | 58 proxy_script_fetcher_http_transaction_factory; |
56 scoped_ptr<net::URLSecurityManager> url_security_manager; | 59 scoped_ptr<net::URLSecurityManager> url_security_manager; |
57 ChromeNetworkDelegate network_delegate; | 60 ChromeNetworkDelegate network_delegate; |
58 scoped_refptr<net::URLRequestContext> proxy_script_fetcher_context; | 61 scoped_refptr<net::URLRequestContext> proxy_script_fetcher_context; |
| 62 scoped_ptr<net::HttpTransactionFactory> system_http_transaction_factory; |
| 63 scoped_refptr<net::ProxyService> system_proxy_service; |
| 64 // NOTE(willchan): This request context is unusable until a system |
| 65 // SSLConfigService is provided that doesn't rely on |
| 66 // Profiles. Do NOT use this yet. |
| 67 scoped_refptr<net::URLRequestContext> system_request_context; |
59 }; | 68 }; |
60 | 69 |
61 // |net_log| must either outlive the IOThread or be NULL. | 70 // |net_log| must either outlive the IOThread or be NULL. |
62 IOThread(PrefService* local_state, ChromeNetLog* net_log); | 71 IOThread(PrefService* local_state, ChromeNetLog* net_log); |
63 | 72 |
64 virtual ~IOThread(); | 73 virtual ~IOThread(); |
65 | 74 |
66 // Can only be called on the IO thread. | 75 // Can only be called on the IO thread. |
67 Globals* globals(); | 76 Globals* globals(); |
68 | 77 |
69 ChromeNetLog* net_log(); | 78 ChromeNetLog* net_log(); |
70 | 79 |
| 80 // Triggers an asynchronous initialization of the system request context. |
| 81 // Takes ownership of config_service. Needs to be called from UI thread. |
| 82 void InitSystemRequestContext(net::ProxyConfigService* config_service); |
| 83 |
71 // Initializes the network predictor, which induces DNS pre-resolution and/or | 84 // Initializes the network predictor, which induces DNS pre-resolution and/or |
72 // TCP/IP preconnections. |prefetching_enabled| indicates whether or not DNS | 85 // TCP/IP preconnections. |prefetching_enabled| indicates whether or not DNS |
73 // prefetching should be enabled, and |preconnect_enabled| controls whether | 86 // prefetching should be enabled, and |preconnect_enabled| controls whether |
74 // TCP/IP preconnection is enabled. This should be called by the UI thread. | 87 // TCP/IP preconnection is enabled. This should be called by the UI thread. |
75 // It will post a task to the IO thread to perform the actual initialization. | 88 // It will post a task to the IO thread to perform the actual initialization. |
76 void InitNetworkPredictor(bool prefetching_enabled, | 89 void InitNetworkPredictor(bool prefetching_enabled, |
77 base::TimeDelta max_dns_queue_delay, | 90 base::TimeDelta max_dns_queue_delay, |
78 size_t max_speculative_parallel_resolves, | 91 size_t max_speculative_parallel_resolves, |
79 const chrome_common_net::UrlList& startup_urls, | 92 const chrome_common_net::UrlList& startup_urls, |
80 ListValue* referral_list, | 93 ListValue* referral_list, |
(...skipping 11 matching lines...) Expand all Loading... |
92 | 105 |
93 // Unregisters |url_request_context_getter| from the IO thread. Only called | 106 // Unregisters |url_request_context_getter| from the IO thread. Only called |
94 // on the IO thread. | 107 // on the IO thread. |
95 void UnregisterURLRequestContextGetter( | 108 void UnregisterURLRequestContextGetter( |
96 ChromeURLRequestContextGetter* url_request_context_getter); | 109 ChromeURLRequestContextGetter* url_request_context_getter); |
97 | 110 |
98 // Handles changing to On The Record mode. Post a task for this onto the | 111 // Handles changing to On The Record mode. Post a task for this onto the |
99 // IOThread's message loop. | 112 // IOThread's message loop. |
100 void ChangedToOnTheRecord(); | 113 void ChangedToOnTheRecord(); |
101 | 114 |
| 115 // Returns a getter for the URLRequestContext. Only called on the UI thread. |
| 116 scoped_refptr<URLRequestContextGetter> system_url_request_context_getter(); |
| 117 |
102 // Clears the host cache. Intended to be used to prevent exposing recently | 118 // Clears the host cache. Intended to be used to prevent exposing recently |
103 // visited sites on about:net-internals/#dns and about:dns pages. Must be | 119 // visited sites on about:net-internals/#dns and about:dns pages. Must be |
104 // called on the IO thread. | 120 // called on the IO thread. |
105 void ClearHostCache(); | 121 void ClearHostCache(); |
106 | 122 |
107 protected: | 123 protected: |
108 virtual void Init(); | 124 virtual void Init(); |
109 virtual void CleanUp(); | 125 virtual void CleanUp(); |
110 virtual void CleanUpAfterMessageLoopDestruction(); | 126 virtual void CleanUpAfterMessageLoopDestruction(); |
111 | 127 |
112 private: | 128 private: |
113 static void RegisterPrefs(PrefService* local_state); | 129 static void RegisterPrefs(PrefService* local_state); |
114 | 130 |
115 net::HttpAuthHandlerFactory* CreateDefaultAuthHandlerFactory( | 131 net::HttpAuthHandlerFactory* CreateDefaultAuthHandlerFactory( |
116 net::HostResolver* resolver); | 132 net::HostResolver* resolver); |
117 | 133 |
| 134 void InitSystemRequestContextOnIOThread( |
| 135 net::ProxyConfigService* config_service); |
| 136 |
118 void InitNetworkPredictorOnIOThread( | 137 void InitNetworkPredictorOnIOThread( |
119 bool prefetching_enabled, | 138 bool prefetching_enabled, |
120 base::TimeDelta max_dns_queue_delay, | 139 base::TimeDelta max_dns_queue_delay, |
121 size_t max_speculative_parallel_resolves, | 140 size_t max_speculative_parallel_resolves, |
122 const chrome_common_net::UrlList& startup_urls, | 141 const chrome_common_net::UrlList& startup_urls, |
123 ListValue* referral_list, | 142 ListValue* referral_list, |
124 bool preconnect_enabled); | 143 bool preconnect_enabled); |
125 | 144 |
126 void ChangedToOnTheRecordOnIOThread(); | 145 void ChangedToOnTheRecordOnIOThread(); |
127 | 146 |
(...skipping 30 matching lines...) Expand all Loading... |
158 // these observers would be used accidentally after we have begun to tear | 177 // these observers would be used accidentally after we have begun to tear |
159 // down. | 178 // down. |
160 chrome_browser_net::ConnectInterceptor* speculative_interceptor_; | 179 chrome_browser_net::ConnectInterceptor* speculative_interceptor_; |
161 chrome_browser_net::Predictor* predictor_; | 180 chrome_browser_net::Predictor* predictor_; |
162 | 181 |
163 // Keeps track of all live ChromeURLRequestContextGetters, so the | 182 // Keeps track of all live ChromeURLRequestContextGetters, so the |
164 // ChromeURLRequestContexts can be released during | 183 // ChromeURLRequestContexts can be released during |
165 // IOThread::CleanUpAfterMessageLoopDestruction(). | 184 // IOThread::CleanUpAfterMessageLoopDestruction(). |
166 std::list<ChromeURLRequestContextGetter*> url_request_context_getters_; | 185 std::list<ChromeURLRequestContextGetter*> url_request_context_getters_; |
167 | 186 |
| 187 scoped_refptr<URLRequestContextGetter> system_url_request_context_getter_; |
| 188 |
168 DISALLOW_COPY_AND_ASSIGN(IOThread); | 189 DISALLOW_COPY_AND_ASSIGN(IOThread); |
169 }; | 190 }; |
170 | 191 |
171 #endif // CHROME_BROWSER_IO_THREAD_H_ | 192 #endif // CHROME_BROWSER_IO_THREAD_H_ |
OLD | NEW |