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

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

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

Powered by Google App Engine
This is Rietveld 408576698