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

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: Temporary - look at browser_list, browser_main_loop, content/p/b/browser_shutdown 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 RemoteDebuggingServer; 34 class RemoteDebuggingServer;
34 class TabCloseableStateWatcher; 35 class TabCloseableStateWatcher;
35 36
36 namespace policy { 37 namespace policy {
37 class BrowserPolicyConnector; 38 class BrowserPolicyConnector;
38 }; 39 };
39 40
40 // Real implementation of BrowserProcess that creates and returns the services. 41 // Real implementation of BrowserProcess that creates and returns the services.
41 class BrowserProcessImpl : public BrowserProcess, 42 class BrowserProcessImpl : public BrowserProcess,
42 public base::NonThreadSafe, 43 public base::NonThreadSafe,
43 public content::NotificationObserver { 44 public content::NotificationObserver {
44 public: 45 public:
45 explicit BrowserProcessImpl(const CommandLine& command_line); 46 explicit BrowserProcessImpl(const CommandLine& command_line);
46 virtual ~BrowserProcessImpl(); 47 virtual ~BrowserProcessImpl();
47 48
49 // Most cleanup is done by these three functions, driven from
50 // ChromeBrowserMain based on notifications from the content
51 // framework, rather than in the destructor, so that we can
52 // interleave cleanup with threads being stopped.
53 void StartTearDown();
54 void PreStopThread(content::BrowserThread::ID identifier);
55 void PostStopThread(content::BrowserThread::ID identifier);
56
48 base::Thread* process_launcher_thread(); 57 base::Thread* process_launcher_thread();
49 58
50 // BrowserProcess methods 59 // BrowserProcess methods
51 virtual void EndSession() OVERRIDE; 60 virtual void EndSession() OVERRIDE;
52 virtual ResourceDispatcherHost* resource_dispatcher_host() OVERRIDE; 61 virtual ResourceDispatcherHost* resource_dispatcher_host() OVERRIDE;
53 virtual MetricsService* metrics_service() OVERRIDE; 62 virtual MetricsService* metrics_service() OVERRIDE;
54 virtual IOThread* io_thread() OVERRIDE; 63 virtual IOThread* io_thread() OVERRIDE;
55 virtual base::Thread* file_thread() OVERRIDE; 64 virtual base::Thread* file_thread() OVERRIDE;
56 virtual base::Thread* db_thread() OVERRIDE; 65 virtual base::Thread* db_thread() OVERRIDE;
57 virtual base::Thread* cache_thread() OVERRIDE; 66 virtual base::Thread* cache_thread() OVERRIDE;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 virtual void StartAutoupdateTimer() OVERRIDE; 120 virtual void StartAutoupdateTimer() OVERRIDE;
112 #endif 121 #endif
113 122
114 virtual ChromeNetLog* net_log() OVERRIDE; 123 virtual ChromeNetLog* net_log() OVERRIDE;
115 virtual prerender::PrerenderTracker* prerender_tracker() OVERRIDE; 124 virtual prerender::PrerenderTracker* prerender_tracker() OVERRIDE;
116 virtual MHTMLGenerationManager* mhtml_generation_manager() OVERRIDE; 125 virtual MHTMLGenerationManager* mhtml_generation_manager() OVERRIDE;
117 virtual GpuBlacklistUpdater* gpu_blacklist_updater() OVERRIDE; 126 virtual GpuBlacklistUpdater* gpu_blacklist_updater() OVERRIDE;
118 virtual ComponentUpdateService* component_updater() OVERRIDE; 127 virtual ComponentUpdateService* component_updater() OVERRIDE;
119 virtual CRLSetFetcher* crl_set_fetcher() OVERRIDE; 128 virtual CRLSetFetcher* crl_set_fetcher() OVERRIDE;
120 129
130 // Must be invoked before the IO thread is started.
131 void CreateIOThreadState();
132
121 private: 133 private:
122 void CreateResourceDispatcherHost(); 134 void CreateResourceDispatcherHost();
123 void CreateMetricsService(); 135 void CreateMetricsService();
124 136
125 void CreateIOThread();
126 static void CleanupOnIOThread();
127
128 void CreateFileThread();
129 void CreateDBThread();
130 void CreateProcessLauncherThread();
131 void CreateCacheThread();
132 void CreateGpuThread();
133 void CreateWatchdogThread(); 137 void CreateWatchdogThread();
134 #if defined(OS_CHROMEOS) 138 #if defined(OS_CHROMEOS)
135 void CreateWebSocketProxyThread(); 139 void InitializeWebSocketProxyThread();
136 #endif 140 #endif
137 void CreateTemplateURLService(); 141 void CreateTemplateURLService();
138 void CreateProfileManager(); 142 void CreateProfileManager();
139 void CreateWebDataService(); 143 void CreateWebDataService();
140 void CreateLocalState(); 144 void CreateLocalState();
141 void CreateViewedPageTracker(); 145 void CreateViewedPageTracker();
142 void CreateIconManager(); 146 void CreateIconManager();
143 void CreateSidebarManager(); 147 void CreateSidebarManager();
144 void CreateGoogleURLTracker(); 148 void CreateGoogleURLTracker();
145 void CreateIntranetRedirectDetector(); 149 void CreateIntranetRedirectDetector();
(...skipping 10 matching lines...) Expand all
156 void ApplyDisabledSchemesPolicy(); 160 void ApplyDisabledSchemesPolicy();
157 void ApplyAllowCrossOriginAuthPromptPolicy(); 161 void ApplyAllowCrossOriginAuthPromptPolicy();
158 void ApplyDefaultBrowserPolicy(); 162 void ApplyDefaultBrowserPolicy();
159 163
160 bool created_resource_dispatcher_host_; 164 bool created_resource_dispatcher_host_;
161 scoped_ptr<ResourceDispatcherHost> resource_dispatcher_host_; 165 scoped_ptr<ResourceDispatcherHost> resource_dispatcher_host_;
162 166
163 bool created_metrics_service_; 167 bool created_metrics_service_;
164 scoped_ptr<MetricsService> metrics_service_; 168 scoped_ptr<MetricsService> metrics_service_;
165 169
166 bool created_io_thread_;
167 scoped_ptr<IOThread> io_thread_; 170 scoped_ptr<IOThread> io_thread_;
168 171
169 bool created_file_thread_;
170 scoped_ptr<base::Thread> file_thread_;
171
172 bool created_db_thread_;
173 scoped_ptr<base::Thread> db_thread_;
174
175 bool created_process_launcher_thread_;
176 scoped_ptr<base::Thread> process_launcher_thread_;
177
178 bool created_cache_thread_;
179 scoped_ptr<base::Thread> cache_thread_;
180
181 bool created_watchdog_thread_; 172 bool created_watchdog_thread_;
182 scoped_ptr<WatchDogThread> watchdog_thread_; 173 scoped_ptr<WatchDogThread> watchdog_thread_;
183 174
184 #if defined(OS_CHROMEOS)
185 bool created_web_socket_proxy_thread_;
186 scoped_ptr<base::Thread> web_socket_proxy_thread_;
187 #endif
188
189 bool created_profile_manager_; 175 bool created_profile_manager_;
190 scoped_ptr<ProfileManager> profile_manager_; 176 scoped_ptr<ProfileManager> profile_manager_;
191 177
192 bool created_local_state_; 178 bool created_local_state_;
193 scoped_ptr<PrefService> local_state_; 179 scoped_ptr<PrefService> local_state_;
194 180
195 bool created_icon_manager_; 181 bool created_icon_manager_;
196 scoped_ptr<IconManager> icon_manager_; 182 scoped_ptr<IconManager> icon_manager_;
197 183
198 scoped_refptr<ExtensionEventRouterForwarder> 184 scoped_refptr<ExtensionEventRouterForwarder>
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 scoped_ptr<prerender::PrerenderTracker> prerender_tracker_; 253 scoped_ptr<prerender::PrerenderTracker> prerender_tracker_;
268 254
269 scoped_ptr<ChromeResourceDispatcherHostDelegate> 255 scoped_ptr<ChromeResourceDispatcherHostDelegate>
270 resource_dispatcher_host_delegate_; 256 resource_dispatcher_host_delegate_;
271 257
272 content::NotificationRegistrar notification_registrar_; 258 content::NotificationRegistrar notification_registrar_;
273 259
274 scoped_refptr<MHTMLGenerationManager> mhtml_generation_manager_; 260 scoped_refptr<MHTMLGenerationManager> mhtml_generation_manager_;
275 261
276 // Monitors the state of the 'DisablePluginFinder' policy. 262 // Monitors the state of the 'DisablePluginFinder' policy.
277 BooleanPrefMember plugin_finder_disabled_pref_; 263 scoped_ptr<BooleanPrefMember> plugin_finder_disabled_pref_;
278 264
279 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) 265 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
280 base::RepeatingTimer<BrowserProcessImpl> autoupdate_timer_; 266 base::RepeatingTimer<BrowserProcessImpl> autoupdate_timer_;
281 267
282 // Gets called by autoupdate timer to see if browser needs restart and can be 268 // Gets called by autoupdate timer to see if browser needs restart and can be
283 // restarted, and if that's the case, restarts the browser. 269 // restarted, and if that's the case, restarts the browser.
284 void OnAutoupdateTimer(); 270 void OnAutoupdateTimer();
285 bool CanAutorestartForUpdate() const; 271 bool CanAutorestartForUpdate() const;
286 void RestartBackgroundInstance(); 272 void RestartBackgroundInstance();
287 #endif // defined(OS_WIN) || defined(OS_LINUX) 273 #endif // defined(OS_WIN) || defined(OS_LINUX)
(...skipping 10 matching lines...) Expand all
298 #if !defined(OS_CHROMEOS) 284 #if !defined(OS_CHROMEOS)
299 scoped_ptr<ComponentUpdateService> component_updater_; 285 scoped_ptr<ComponentUpdateService> component_updater_;
300 286
301 scoped_refptr<CRLSetFetcher> crl_set_fetcher_; 287 scoped_refptr<CRLSetFetcher> crl_set_fetcher_;
302 #endif 288 #endif
303 289
304 DISALLOW_COPY_AND_ASSIGN(BrowserProcessImpl); 290 DISALLOW_COPY_AND_ASSIGN(BrowserProcessImpl);
305 }; 291 };
306 292
307 #endif // CHROME_BROWSER_BROWSER_PROCESS_IMPL_H_ 293 #endif // CHROME_BROWSER_BROWSER_PROCESS_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/browser_process_impl.cc » ('j') | content/public/browser/browser_shutdown.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698