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

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

Issue 8477004: Have content/ create and destroy its own threads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: With this patchset, Chrome runs and exits normally on Linux. Created 9 years, 1 month 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 // When each service is created, we set a flag indicating this. At this point, 5 // When each service is created, we set a flag indicating this. At this point,
6 // the service initialization could fail or succeed. This allows us to remember 6 // the service initialization could fail or succeed. This allows us to remember
7 // if we tried to create a service, and not try creating it over and over if 7 // if we tried to create a service, and not try creating it over and over if
8 // the creation failed. 8 // the creation failed.
9 9
10 #ifndef CHROME_BROWSER_BROWSER_PROCESS_IMPL_H_ 10 #ifndef CHROME_BROWSER_BROWSER_PROCESS_IMPL_H_
11 #define CHROME_BROWSER_BROWSER_PROCESS_IMPL_H_ 11 #define CHROME_BROWSER_BROWSER_PROCESS_IMPL_H_
12 #pragma once 12 #pragma once
13 13
14 #include <string> 14 #include <string>
15 15
16 #include "base/basictypes.h" 16 #include "base/basictypes.h"
17 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
18 #include "base/message_loop.h" 18 #include "base/message_loop.h"
19 #include "base/threading/non_thread_safe.h" 19 #include "base/threading/non_thread_safe.h"
20 #include "base/timer.h" 20 #include "base/timer.h"
21 #include "chrome/browser/browser_process.h" 21 #include "chrome/browser/browser_process.h"
22 #include "chrome/browser/prefs/pref_change_registrar.h" 22 #include "chrome/browser/prefs/pref_change_registrar.h"
23 #include "chrome/browser/prefs/pref_member.h" 23 #include "chrome/browser/prefs/pref_member.h"
24 #include "content/public/browser/browser_thread.h"
24 #include "content/public/browser/notification_observer.h" 25 #include "content/public/browser/notification_observer.h"
25 #include "content/public/browser/notification_registrar.h" 26 #include "content/public/browser/notification_registrar.h"
26 #include "ipc/ipc_message.h" 27 #include "ipc/ipc_message.h"
27 28
28 class BrowserOnlineStateObserver; 29 class BrowserOnlineStateObserver;
29 class ChromeNetLog; 30 class ChromeNetLog;
30 class ChromeResourceDispatcherHostDelegate; 31 class ChromeResourceDispatcherHostDelegate;
31 class CommandLine; 32 class CommandLine;
32 class DevToolsProtocolHandler; 33 class DevToolsProtocolHandler;
33 class FilePath; 34 class FilePath;
34 class PluginDataRemover; 35 class PluginDataRemover;
35 class RemoteDebuggingServer; 36 class RemoteDebuggingServer;
36 class TabCloseableStateWatcher; 37 class TabCloseableStateWatcher;
37 38
38 namespace policy { 39 namespace policy {
39 class BrowserPolicyConnector; 40 class BrowserPolicyConnector;
40 }; 41 };
41 42
42 // Real implementation of BrowserProcess that creates and returns the services. 43 // Real implementation of BrowserProcess that creates and returns the services.
43 class BrowserProcessImpl : public BrowserProcess, 44 class BrowserProcessImpl : public BrowserProcess,
44 public base::NonThreadSafe, 45 public base::NonThreadSafe,
45 public content::NotificationObserver { 46 public content::NotificationObserver {
46 public: 47 public:
47 explicit BrowserProcessImpl(const CommandLine& command_line); 48 explicit BrowserProcessImpl(const CommandLine& command_line);
48 virtual ~BrowserProcessImpl(); 49 virtual ~BrowserProcessImpl();
49 50
51 // Most cleanup is done by these three functions, driven from
52 // ChromeBrowserMain based on notifications from the content
53 // framework, rather than in the destructor, so that we can
54 // interleave cleanup with threads being stopped.
55 void StartTearDown();
56 void PreStopThread(content::BrowserThread::ID identifier);
57 void PostStopThread(content::BrowserThread::ID identifier);
58
50 base::Thread* process_launcher_thread(); 59 base::Thread* process_launcher_thread();
51 60
52 // BrowserProcess methods 61 // BrowserProcess methods
53 virtual void EndSession() OVERRIDE; 62 virtual void EndSession() OVERRIDE;
54 virtual ResourceDispatcherHost* resource_dispatcher_host() OVERRIDE; 63 virtual ResourceDispatcherHost* resource_dispatcher_host() OVERRIDE;
55 virtual MetricsService* metrics_service() OVERRIDE; 64 virtual MetricsService* metrics_service() OVERRIDE;
56 virtual IOThread* io_thread() OVERRIDE; 65 virtual IOThread* io_thread() OVERRIDE;
57 virtual base::Thread* file_thread() OVERRIDE; 66 virtual base::Thread* file_thread() OVERRIDE;
58 virtual base::Thread* db_thread() OVERRIDE; 67 virtual base::Thread* db_thread() OVERRIDE;
59 virtual base::Thread* cache_thread() OVERRIDE; 68 virtual base::Thread* cache_thread() OVERRIDE;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 #endif 132 #endif
124 133
125 virtual MHTMLGenerationManager* mhtml_generation_manager() OVERRIDE; 134 virtual MHTMLGenerationManager* mhtml_generation_manager() OVERRIDE;
126 135
127 virtual GpuBlacklistUpdater* gpu_blacklist_updater() OVERRIDE; 136 virtual GpuBlacklistUpdater* gpu_blacklist_updater() OVERRIDE;
128 137
129 virtual ComponentUpdateService* component_updater() OVERRIDE; 138 virtual ComponentUpdateService* component_updater() OVERRIDE;
130 139
131 virtual CRLSetFetcher* crl_set_fetcher(); 140 virtual CRLSetFetcher* crl_set_fetcher();
132 141
142 // Must be invoked before the IO thread is started.
143 void CreateIOThreadState();
144
133 private: 145 private:
134 void CreateResourceDispatcherHost(); 146 void CreateResourceDispatcherHost();
135 void CreateMetricsService(); 147 void CreateMetricsService();
136 148
137 void CreateIOThread();
138 static void CleanupOnIOThread();
139
140 void CreateFileThread();
141 void CreateDBThread();
142 void CreateProcessLauncherThread();
143 void CreateCacheThread();
144 void CreateGpuThread();
145 void CreateWatchdogThread(); 149 void CreateWatchdogThread();
146 #if defined(OS_CHROMEOS) 150 #if defined(OS_CHROMEOS)
147 void CreateWebSocketProxyThread(); 151 void InitializeWebSocketProxyThread();
148 #endif 152 #endif
149 void CreateTemplateURLService(); 153 void CreateTemplateURLService();
150 void CreateProfileManager(); 154 void CreateProfileManager();
151 void CreateWebDataService(); 155 void CreateWebDataService();
152 void CreateLocalState(); 156 void CreateLocalState();
153 void CreateViewedPageTracker(); 157 void CreateViewedPageTracker();
154 void CreateIconManager(); 158 void CreateIconManager();
155 void CreateDevToolsManager(); 159 void CreateDevToolsManager();
156 void CreateSidebarManager(); 160 void CreateSidebarManager();
157 void CreateGoogleURLTracker(); 161 void CreateGoogleURLTracker();
(...skipping 15 matching lines...) Expand all
173 #if defined(IPC_MESSAGE_LOG_ENABLED) 177 #if defined(IPC_MESSAGE_LOG_ENABLED)
174 void SetIPCLoggingEnabledForChildProcesses(bool enabled); 178 void SetIPCLoggingEnabledForChildProcesses(bool enabled);
175 #endif 179 #endif
176 180
177 bool created_resource_dispatcher_host_; 181 bool created_resource_dispatcher_host_;
178 scoped_ptr<ResourceDispatcherHost> resource_dispatcher_host_; 182 scoped_ptr<ResourceDispatcherHost> resource_dispatcher_host_;
179 183
180 bool created_metrics_service_; 184 bool created_metrics_service_;
181 scoped_ptr<MetricsService> metrics_service_; 185 scoped_ptr<MetricsService> metrics_service_;
182 186
183 bool created_io_thread_;
184 scoped_ptr<IOThread> io_thread_; 187 scoped_ptr<IOThread> io_thread_;
185 188
186 bool created_file_thread_;
187 scoped_ptr<base::Thread> file_thread_;
188
189 bool created_db_thread_;
190 scoped_ptr<base::Thread> db_thread_;
191
192 bool created_process_launcher_thread_;
193 scoped_ptr<base::Thread> process_launcher_thread_;
194
195 bool created_cache_thread_;
196 scoped_ptr<base::Thread> cache_thread_;
197
198 bool created_watchdog_thread_; 189 bool created_watchdog_thread_;
199 scoped_ptr<WatchDogThread> watchdog_thread_; 190 scoped_ptr<WatchDogThread> watchdog_thread_;
200 191
201 #if defined(OS_CHROMEOS)
202 bool created_web_socket_proxy_thread_;
203 scoped_ptr<base::Thread> web_socket_proxy_thread_;
204 #endif
205
206 bool created_profile_manager_; 192 bool created_profile_manager_;
207 scoped_ptr<ProfileManager> profile_manager_; 193 scoped_ptr<ProfileManager> profile_manager_;
208 194
209 bool created_local_state_; 195 bool created_local_state_;
210 scoped_ptr<PrefService> local_state_; 196 scoped_ptr<PrefService> local_state_;
211 197
212 bool created_icon_manager_; 198 bool created_icon_manager_;
213 scoped_ptr<IconManager> icon_manager_; 199 scoped_ptr<IconManager> icon_manager_;
214 200
215 scoped_refptr<ExtensionEventRouterForwarder> 201 scoped_refptr<ExtensionEventRouterForwarder>
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 scoped_ptr<prerender::PrerenderTracker> prerender_tracker_; 273 scoped_ptr<prerender::PrerenderTracker> prerender_tracker_;
288 274
289 scoped_ptr<ChromeResourceDispatcherHostDelegate> 275 scoped_ptr<ChromeResourceDispatcherHostDelegate>
290 resource_dispatcher_host_delegate_; 276 resource_dispatcher_host_delegate_;
291 277
292 content::NotificationRegistrar notification_registrar_; 278 content::NotificationRegistrar notification_registrar_;
293 279
294 scoped_refptr<MHTMLGenerationManager> mhtml_generation_manager_; 280 scoped_refptr<MHTMLGenerationManager> mhtml_generation_manager_;
295 281
296 // Monitors the state of the 'DisablePluginFinder' policy. 282 // Monitors the state of the 'DisablePluginFinder' policy.
297 BooleanPrefMember plugin_finder_disabled_pref_; 283 scoped_ptr<BooleanPrefMember> plugin_finder_disabled_pref_;
298 284
299 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) 285 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
300 base::RepeatingTimer<BrowserProcessImpl> autoupdate_timer_; 286 base::RepeatingTimer<BrowserProcessImpl> autoupdate_timer_;
301 287
302 // Gets called by autoupdate timer to see if browser needs restart and can be 288 // Gets called by autoupdate timer to see if browser needs restart and can be
303 // restarted, and if that's the case, restarts the browser. 289 // restarted, and if that's the case, restarts the browser.
304 void OnAutoupdateTimer(); 290 void OnAutoupdateTimer();
305 bool CanAutorestartForUpdate() const; 291 bool CanAutorestartForUpdate() const;
306 void RestartBackgroundInstance(); 292 void RestartBackgroundInstance();
307 #endif // defined(OS_WIN) || defined(OS_LINUX) 293 #endif // defined(OS_WIN) || defined(OS_LINUX)
(...skipping 10 matching lines...) Expand all
318 #if !defined(OS_CHROMEOS) 304 #if !defined(OS_CHROMEOS)
319 scoped_ptr<ComponentUpdateService> component_updater_; 305 scoped_ptr<ComponentUpdateService> component_updater_;
320 306
321 scoped_refptr<CRLSetFetcher> crl_set_fetcher_; 307 scoped_refptr<CRLSetFetcher> crl_set_fetcher_;
322 #endif 308 #endif
323 309
324 DISALLOW_COPY_AND_ASSIGN(BrowserProcessImpl); 310 DISALLOW_COPY_AND_ASSIGN(BrowserProcessImpl);
325 }; 311 };
326 312
327 #endif // CHROME_BROWSER_BROWSER_PROCESS_IMPL_H_ 313 #endif // CHROME_BROWSER_BROWSER_PROCESS_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698