blob: 1918e6e1e1e25d757c39fd6aa5c6674c4e3dec76 [file] [log] [blame]
[email protected]27a112c2011-01-06 04:19:301// Copyright (c) 2011 The Chromium Authors. All rights reserved.
[email protected]0ac83682010-01-22 17:46:272// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_IO_THREAD_H_
6#define CHROME_BROWSER_IO_THREAD_H_
[email protected]32b76ef2010-07-26 23:08:247#pragma once
[email protected]0ac83682010-01-22 17:46:278
[email protected]bcefe0f2010-11-10 16:19:109#include <string>
[email protected]c38831a12011-10-28 12:44:4910
[email protected]0ac83682010-01-22 17:46:2711#include "base/basictypes.h"
[email protected]3b63f8f42011-03-28 01:54:1512#include "base/memory/ref_counted.h"
13#include "base/memory/scoped_ptr.h"
[email protected]addb3242011-06-13 21:39:1614#include "base/task.h"
[email protected]4d45a6de2011-05-13 05:20:1815#include "chrome/browser/net/ssl_config_service_manager.h"
[email protected]0a8db0d2011-04-13 15:15:4016#include "chrome/browser/prefs/pref_member.h"
[email protected]b0f146f2011-09-15 22:14:2517#include "content/browser/browser_process_sub_thread.h"
[email protected]58bc7042010-07-07 18:04:1418#include "net/base/network_change_notifier.h"
[email protected]0ac83682010-01-22 17:46:2719
[email protected]9e743cd2010-03-16 07:03:5320class ChromeNetLog;
[email protected]0ee7a3b2010-11-09 06:13:4021class ChromeURLRequestContextGetter;
[email protected]3ce02412011-03-01 12:01:1522class ExtensionEventRouterForwarder;
[email protected]cc87500b2011-06-24 20:59:1923class MediaInternals;
[email protected]db0e86dd2011-03-16 14:47:2124class PrefProxyConfigTracker;
[email protected]bcefe0f2010-11-10 16:19:1025class PrefService;
[email protected]db0e86dd2011-03-16 14:47:2126class SystemURLRequestContextGetter;
[email protected]0ac83682010-01-22 17:46:2727
[email protected]f3a1c642011-07-12 19:15:0328namespace base {
29class ListValue;
30}
31
[email protected]d13c3272010-02-04 00:24:5132namespace net {
[email protected]822581d2010-12-16 17:27:1533class CertVerifier;
[email protected]273e37d2011-08-11 01:49:1234class CookieStore;
[email protected]2db580532010-10-08 14:32:3735class DnsRRResolver;
[email protected]933bc5c62011-04-12 19:08:0236class FtpTransactionFactory;
[email protected]1889dc1b2010-10-14 22:03:1337class HostResolver;
[email protected]fa55e192010-02-15 14:25:5038class HttpAuthHandlerFactory;
[email protected]17291a022011-10-10 07:32:5339class HttpServerProperties;
[email protected]52617df2010-12-24 07:30:0140class HttpTransactionFactory;
[email protected]0651b812011-02-24 00:22:5041class NetworkDelegate;
[email protected]273e37d2011-08-11 01:49:1242class OriginBoundCertService;
[email protected]db0e86dd2011-03-16 14:47:2143class ProxyConfigService;
[email protected]2fb629202010-12-23 23:52:5744class ProxyService;
[email protected]3b543ab2011-09-17 21:47:0045class SdchManager;
[email protected]2fb629202010-12-23 23:52:5746class SSLConfigService;
[email protected]27a112c2011-01-06 04:19:3047class URLRequestContext;
[email protected]abe2c032011-03-31 18:49:3448class URLRequestContextGetter;
[email protected]b4955e7d2010-04-16 20:22:3049class URLSecurityManager;
[email protected]d13c3272010-02-04 00:24:5150} // namespace net
51
[email protected]c38831a12011-10-28 12:44:4952class IOThread : public content::BrowserProcessSubThread {
[email protected]0ac83682010-01-22 17:46:2753 public:
[email protected]d13c3272010-02-04 00:24:5154 struct Globals {
[email protected]1889dc1b2010-10-14 22:03:1355 Globals();
56 ~Globals();
57
[email protected]cc87500b2011-06-24 20:59:1958 struct MediaGlobals {
59 MediaGlobals();
60 ~MediaGlobals();
61 // MediaInternals singleton used to aggregate media information.
62 scoped_ptr<MediaInternals> media_internals;
63 } media;
64
[email protected]0651b812011-02-24 00:22:5065 // The "system" NetworkDelegate, used for Profile-agnostic network events.
66 scoped_ptr<net::NetworkDelegate> system_network_delegate;
[email protected]73c45322010-10-01 23:57:5467 scoped_ptr<net::HostResolver> host_resolver;
[email protected]822581d2010-12-16 17:27:1568 scoped_ptr<net::CertVerifier> cert_verifier;
[email protected]2db580532010-10-08 14:32:3769 scoped_ptr<net::DnsRRResolver> dnsrr_resolver;
[email protected]2fb629202010-12-23 23:52:5770 scoped_refptr<net::SSLConfigService> ssl_config_service;
[email protected]fa55e192010-02-15 14:25:5071 scoped_ptr<net::HttpAuthHandlerFactory> http_auth_handler_factory;
[email protected]17291a022011-10-10 07:32:5372 scoped_ptr<net::HttpServerProperties> http_server_properties;
[email protected]6104ea5d2011-04-27 21:37:1273 scoped_ptr<net::ProxyService> proxy_script_fetcher_proxy_service;
[email protected]52617df2010-12-24 07:30:0174 scoped_ptr<net::HttpTransactionFactory>
75 proxy_script_fetcher_http_transaction_factory;
[email protected]933bc5c62011-04-12 19:08:0276 scoped_ptr<net::FtpTransactionFactory>
77 proxy_script_fetcher_ftp_transaction_factory;
[email protected]b4955e7d2010-04-16 20:22:3078 scoped_ptr<net::URLSecurityManager> url_security_manager;
[email protected]77feb462011-05-16 23:37:2579 // We use a separate URLRequestContext for PAC fetches, in order to break
80 // the reference cycle:
81 // URLRequestContext=>PAC fetch=>URLRequest=>URLRequestContext.
82 // The first URLRequestContext is |system_url_request_context|. We introduce
83 // |proxy_script_fetcher_context| for the second context. It has a direct
84 // ProxyService, since we always directly connect to fetch the PAC script.
[email protected]27a112c2011-01-06 04:19:3085 scoped_refptr<net::URLRequestContext> proxy_script_fetcher_context;
[email protected]6104ea5d2011-04-27 21:37:1286 scoped_ptr<net::ProxyService> system_proxy_service;
[email protected]db0e86dd2011-03-16 14:47:2187 scoped_ptr<net::HttpTransactionFactory> system_http_transaction_factory;
[email protected]933bc5c62011-04-12 19:08:0288 scoped_ptr<net::FtpTransactionFactory> system_ftp_transaction_factory;
[email protected]db0e86dd2011-03-16 14:47:2189 scoped_refptr<net::URLRequestContext> system_request_context;
[email protected]273e37d2011-08-11 01:49:1290 // |cookie_store| and |origin_bound_cert_service| are shared between
91 // |proxy_script_fetcher_context| and |system_request_context|.
92 scoped_refptr<net::CookieStore> system_cookie_store;
93 scoped_ptr<net::OriginBoundCertService> system_origin_bound_cert_service;
[email protected]3ce02412011-03-01 12:01:1594 scoped_refptr<ExtensionEventRouterForwarder>
95 extension_event_router_forwarder;
[email protected]d13c3272010-02-04 00:24:5196 };
97
[email protected]b2fcd0e2010-12-01 15:19:4098 // |net_log| must either outlive the IOThread or be NULL.
[email protected]3ce02412011-03-01 12:01:1599 IOThread(PrefService* local_state,
100 ChromeNetLog* net_log,
101 ExtensionEventRouterForwarder* extension_event_router_forwarder);
[email protected]0ac83682010-01-22 17:46:27102
103 virtual ~IOThread();
104
[email protected]d13c3272010-02-04 00:24:51105 // Can only be called on the IO thread.
106 Globals* globals();
[email protected]0ac83682010-01-22 17:46:27107
[email protected]b2fcd0e2010-12-01 15:19:40108 ChromeNetLog* net_log();
109
[email protected]db0e86dd2011-03-16 14:47:21110 // Returns a getter for the URLRequestContext. Only called on the UI thread.
[email protected]abe2c032011-03-31 18:49:34111 net::URLRequestContextGetter* system_url_request_context_getter();
[email protected]db0e86dd2011-03-16 14:47:21112
[email protected]67372ecf2011-09-10 01:30:46113 // Clears the host cache. Intended to be used to prevent exposing recently
114 // visited sites on about:net-internals/#dns and about:dns pages. Must be
115 // called on the IO thread.
116 void ClearHostCache();
[email protected]d6f37fc2011-02-13 23:58:41117
[email protected]0ac83682010-01-22 17:46:27118 protected:
119 virtual void Init();
[email protected]2a92cd92010-04-27 00:01:41120 virtual void CleanUp();
[email protected]0ac83682010-01-22 17:46:27121
122 private:
[email protected]db0e86dd2011-03-16 14:47:21123 // Provide SystemURLRequestContextGetter with access to
124 // InitSystemRequestContext().
125 friend class SystemURLRequestContextGetter;
126
[email protected]bcefe0f2010-11-10 16:19:10127 static void RegisterPrefs(PrefService* local_state);
128
[email protected]65d34382010-07-01 18:12:26129 net::HttpAuthHandlerFactory* CreateDefaultAuthHandlerFactory(
130 net::HostResolver* resolver);
[email protected]eb3cac72010-02-26 21:07:45131
[email protected]addb3242011-06-13 21:39:16132 void InitSystemRequestContext();
133
[email protected]db0e86dd2011-03-16 14:47:21134 // Lazy initialization of system request context for
135 // SystemURLRequestContextGetter. To be called on IO thread.
[email protected]addb3242011-06-13 21:39:16136 void InitSystemRequestContextOnIOThread();
[email protected]db0e86dd2011-03-16 14:47:21137
[email protected]4d45a6de2011-05-13 05:20:18138 // Returns an SSLConfigService instance.
139 net::SSLConfigService* GetSSLConfigService();
140
[email protected]b2fcd0e2010-12-01 15:19:40141 // The NetLog is owned by the browser process, to allow logging from other
142 // threads during shutdown, but is used most frequently on the IOThread.
143 ChromeNetLog* net_log_;
144
[email protected]3ce02412011-03-01 12:01:15145 // The ExtensionEventRouterForwarder allows for sending events to extensions
146 // from the IOThread.
147 ExtensionEventRouterForwarder* extension_event_router_forwarder_;
148
[email protected]0ac83682010-01-22 17:46:27149 // These member variables are basically global, but their lifetimes are tied
150 // to the IOThread. IOThread owns them all, despite not using scoped_ptr.
151 // This is because the destructor of IOThread runs on the wrong thread. All
[email protected]b2fcd0e2010-12-01 15:19:40152 // member variables should be deleted in CleanUp().
[email protected]0ac83682010-01-22 17:46:27153
[email protected]d13c3272010-02-04 00:24:51154 // These member variables are initialized in Init() and do not change for the
155 // lifetime of the IO thread.
156
157 Globals* globals_;
158
[email protected]58bc7042010-07-07 18:04:14159 // Observer that logs network changes to the ChromeNetLog.
[email protected]232a5812011-03-04 22:42:08160 scoped_ptr<net::NetworkChangeNotifier::IPAddressObserver>
161 network_change_observer_;
[email protected]58bc7042010-07-07 18:04:14162
[email protected]0a8db0d2011-04-13 15:15:40163 BooleanPrefMember system_enable_referrers_;
164
[email protected]bcefe0f2010-11-10 16:19:10165 // Store HTTP Auth-related policies in this thread.
166 std::string auth_schemes_;
167 bool negotiate_disable_cname_lookup_;
168 bool negotiate_enable_port_;
169 std::string auth_server_whitelist_;
170 std::string auth_delegate_whitelist_;
[email protected]ac7f3fdb2010-11-12 12:47:05171 std::string gssapi_library_name_;
[email protected]bcefe0f2010-11-10 16:19:10172
[email protected]4d45a6de2011-05-13 05:20:18173 // This is an instance of the default SSLConfigServiceManager for the current
174 // platform and it gets SSL preferences from local_state object.
175 scoped_ptr<SSLConfigServiceManager> ssl_config_service_manager_;
176
[email protected]d13c3272010-02-04 00:24:51177 // These member variables are initialized by a task posted to the IO thread,
178 // which gets posted by calling certain member functions of IOThread.
[email protected]db0e86dd2011-03-16 14:47:21179 scoped_ptr<net::ProxyConfigService> system_proxy_config_service_;
180
181 scoped_refptr<PrefProxyConfigTracker> pref_proxy_config_tracker_;
182
[email protected]abe2c032011-03-31 18:49:34183 scoped_refptr<net::URLRequestContextGetter>
184 system_url_request_context_getter_;
[email protected]db0e86dd2011-03-16 14:47:21185
[email protected]3b543ab2011-09-17 21:47:00186 net::SdchManager* sdch_manager_;
187
[email protected]addb3242011-06-13 21:39:16188 ScopedRunnableMethodFactory<IOThread> method_factory_;
189
[email protected]0ac83682010-01-22 17:46:27190 DISALLOW_COPY_AND_ASSIGN(IOThread);
191};
192
[email protected]fa55e192010-02-15 14:25:50193#endif // CHROME_BROWSER_IO_THREAD_H_