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

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

Powered by Google App Engine
This is Rietveld 408576698