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

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

Issue 8477004: Have content/ create and destroy its own threads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Temporary - look at browser_list, browser_main_loop, content/p/b/browser_shutdown Created 9 years 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 <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
14 #include "chrome/browser/net/ssl_config_service_manager.h" 16 #include "chrome/browser/net/ssl_config_service_manager.h"
15 #include "chrome/browser/prefs/pref_member.h" 17 #include "chrome/browser/prefs/pref_member.h"
16 #include "content/browser/browser_process_sub_thread.h"
17 #include "net/base/network_change_notifier.h" 18 #include "net/base/network_change_notifier.h"
18 19
20 // TODO(joi): Remove these in a follow-up change and IWYU in files
21 // that were getting them directly or indirectly from here.
22 #include "base/memory/ref_counted.h"
23 #include "base/memory/scoped_ptr.h"
24 #include "base/message_loop.h"
25 #include "base/message_loop_proxy.h"
26 #include "base/synchronization/lock.h"
27 #include "base/threading/thread.h"
28
29 class BrowserProcessImpl;
19 class ChromeNetLog; 30 class ChromeNetLog;
20 class ExtensionEventRouterForwarder; 31 class ExtensionEventRouterForwarder;
21 class MediaInternals; 32 class MediaInternals;
22 class PrefProxyConfigTrackerImpl; 33 class PrefProxyConfigTrackerImpl;
23 class PrefService; 34 class PrefService;
24 class SystemURLRequestContextGetter; 35 class SystemURLRequestContextGetter;
25 36
26 namespace net { 37 namespace net {
27 class CertVerifier; 38 class CertVerifier;
28 class CookieStore; 39 class CookieStore;
29 class DnsRRResolver; 40 class DnsRRResolver;
30 class FtpTransactionFactory; 41 class FtpTransactionFactory;
31 class HostResolver; 42 class HostResolver;
32 class HttpAuthHandlerFactory; 43 class HttpAuthHandlerFactory;
33 class HttpServerProperties; 44 class HttpServerProperties;
34 class HttpTransactionFactory; 45 class HttpTransactionFactory;
35 class NetworkDelegate; 46 class NetworkDelegate;
36 class OriginBoundCertService; 47 class OriginBoundCertService;
37 class ProxyConfigService; 48 class ProxyConfigService;
38 class ProxyService; 49 class ProxyService;
39 class SdchManager; 50 class SdchManager;
40 class SSLConfigService; 51 class SSLConfigService;
41 class URLRequestContext; 52 class URLRequestContext;
42 class URLRequestContextGetter; 53 class URLRequestContextGetter;
43 class URLSecurityManager; 54 class URLSecurityManager;
44 } // namespace net 55 } // namespace net
45 56
46 class IOThread : public content::BrowserProcessSubThread { 57 // Contains state associated with, initialized and cleaned up on, and
58 // primarily used on, the IO thread. Also acts as a convenience
59 // accessor to the Thread object for the IO thread.
60 class IOThread : public MessageLoop::DestructionObserver {
47 public: 61 public:
48 struct Globals { 62 struct Globals {
49 Globals(); 63 Globals();
50 ~Globals(); 64 ~Globals();
51 65
52 struct MediaGlobals { 66 struct MediaGlobals {
53 MediaGlobals(); 67 MediaGlobals();
54 ~MediaGlobals(); 68 ~MediaGlobals();
55 // MediaInternals singleton used to aggregate media information. 69 // MediaInternals singleton used to aggregate media information.
56 scoped_ptr<MediaInternals> media_internals; 70 scoped_ptr<MediaInternals> media_internals;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 ChromeNetLog* net_log(); 116 ChromeNetLog* net_log();
103 117
104 // Returns a getter for the URLRequestContext. Only called on the UI thread. 118 // Returns a getter for the URLRequestContext. Only called on the UI thread.
105 net::URLRequestContextGetter* system_url_request_context_getter(); 119 net::URLRequestContextGetter* system_url_request_context_getter();
106 120
107 // Clears the host cache. Intended to be used to prevent exposing recently 121 // Clears the host cache. Intended to be used to prevent exposing recently
108 // visited sites on about:net-internals/#dns and about:dns pages. Must be 122 // visited sites on about:net-internals/#dns and about:dns pages. Must be
109 // called on the IO thread. 123 // called on the IO thread.
110 void ClearHostCache(); 124 void ClearHostCache();
111 125
112 protected: 126 // Convenience method similar to base::Thread, giving access to the
113 virtual void Init() OVERRIDE; 127 // actual IO thread.
114 virtual void CleanUp() OVERRIDE; 128 // TODO(joi): Remove this in follow-up changes.
129 MessageLoop* message_loop() const;
115 130
116 private: 131 private:
132 // For InitializeGlobalState/TearDownGlobalState.
133 friend class BrowserProcessImpl;
134
117 // Provide SystemURLRequestContextGetter with access to 135 // Provide SystemURLRequestContextGetter with access to
118 // InitSystemRequestContext(). 136 // InitSystemRequestContext().
119 friend class SystemURLRequestContextGetter; 137 friend class SystemURLRequestContextGetter;
120 138
139 // This is posted as the very first task to the IO thread. This is
140 // the responsibility of BrowserProcessImpl.
141 void InitializeGlobalState();
142
143 // Global state must be initialized on the IO thread, then this
144 // method must be invoked on the UI thread.
145 void InitSystemRequestContext();
146
147 // Lazy initialization of system request context for
148 // SystemURLRequestContextGetter. To be called on IO thread only
149 // after global state has been initialized on the IO thread, and
150 // SystemRequestContext state has been initialized on the UI thread.
151 void InitSystemRequestContextOnIOThread();
152
121 static void RegisterPrefs(PrefService* local_state); 153 static void RegisterPrefs(PrefService* local_state);
122 154
123 net::HttpAuthHandlerFactory* CreateDefaultAuthHandlerFactory( 155 net::HttpAuthHandlerFactory* CreateDefaultAuthHandlerFactory(
124 net::HostResolver* resolver); 156 net::HostResolver* resolver);
125 157
126 void InitSystemRequestContext();
127
128 // Lazy initialization of system request context for
129 // SystemURLRequestContextGetter. To be called on IO thread.
130 void InitSystemRequestContextOnIOThread();
131
132 // Returns an SSLConfigService instance. 158 // Returns an SSLConfigService instance.
133 net::SSLConfigService* GetSSLConfigService(); 159 net::SSLConfigService* GetSSLConfigService();
134 160
161 // MessageLoop::DestructionObserver implementation.
162 virtual void WillDestroyCurrentMessageLoop() OVERRIDE;
163
135 // The NetLog is owned by the browser process, to allow logging from other 164 // The NetLog is owned by the browser process, to allow logging from other
136 // threads during shutdown, but is used most frequently on the IOThread. 165 // threads during shutdown, but is used most frequently on the IOThread.
137 ChromeNetLog* net_log_; 166 ChromeNetLog* net_log_;
138 167
139 // The ExtensionEventRouterForwarder allows for sending events to extensions 168 // The ExtensionEventRouterForwarder allows for sending events to extensions
140 // from the IOThread. 169 // from the IOThread.
141 ExtensionEventRouterForwarder* extension_event_router_forwarder_; 170 ExtensionEventRouterForwarder* extension_event_router_forwarder_;
142 171
143 // These member variables are basically global, but their lifetimes are tied 172 // These member variables are basically global, but their lifetimes are tied
144 // to the IOThread. IOThread owns them all, despite not using scoped_ptr. 173 // to the IOThread. IOThread owns them all, despite not using scoped_ptr.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 system_url_request_context_getter_; 207 system_url_request_context_getter_;
179 208
180 net::SdchManager* sdch_manager_; 209 net::SdchManager* sdch_manager_;
181 210
182 base::WeakPtrFactory<IOThread> weak_factory_; 211 base::WeakPtrFactory<IOThread> weak_factory_;
183 212
184 DISALLOW_COPY_AND_ASSIGN(IOThread); 213 DISALLOW_COPY_AND_ASSIGN(IOThread);
185 }; 214 };
186 215
187 #endif // CHROME_BROWSER_IO_THREAD_H_ 216 #endif // CHROME_BROWSER_IO_THREAD_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698