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

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

Issue 1803143002: Replace BrowserProces::AddRefModule/RemoveModule by ScopedKeepAlive (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 4 years, 9 months 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
« no previous file with comments | « chrome/browser/browser_process.h ('k') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 12
13 #include <stdint.h> 13 #include <stdint.h>
14 14
15 #include <string> 15 #include <string>
16 16
17 #include "base/debug/stack_trace.h" 17 #include "base/debug/stack_trace.h"
18 #include "base/macros.h" 18 #include "base/macros.h"
19 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
20 #include "base/memory/scoped_ptr.h" 20 #include "base/memory/scoped_ptr.h"
21 #include "base/threading/non_thread_safe.h" 21 #include "base/threading/non_thread_safe.h"
22 #include "base/timer/timer.h" 22 #include "base/timer/timer.h"
23 #include "build/build_config.h" 23 #include "build/build_config.h"
24 #include "chrome/browser/browser_process.h" 24 #include "chrome/browser/browser_process.h"
25 #include "chrome/browser/lifetime/keep_alive_state_observer.h"
25 #include "chrome/common/features.h" 26 #include "chrome/common/features.h"
26 #include "components/prefs/pref_change_registrar.h" 27 #include "components/prefs/pref_change_registrar.h"
27 28
28 class ChromeChildProcessWatcher; 29 class ChromeChildProcessWatcher;
29 class ChromeDeviceClient; 30 class ChromeDeviceClient;
30 class ChromeResourceDispatcherHostDelegate; 31 class ChromeResourceDispatcherHostDelegate;
31 class DevToolsAutoOpener; 32 class DevToolsAutoOpener;
32 class RemoteDebuggingServer; 33 class RemoteDebuggingServer;
33 class PrefRegistrySimple; 34 class PrefRegistrySimple;
34 35
(...skipping 22 matching lines...) Expand all
57 class BrowserPolicyConnector; 58 class BrowserPolicyConnector;
58 class PolicyService; 59 class PolicyService;
59 }; 60 };
60 61
61 namespace web_resource { 62 namespace web_resource {
62 class PromoResourceService; 63 class PromoResourceService;
63 } 64 }
64 65
65 // Real implementation of BrowserProcess that creates and returns the services. 66 // Real implementation of BrowserProcess that creates and returns the services.
66 class BrowserProcessImpl : public BrowserProcess, 67 class BrowserProcessImpl : public BrowserProcess,
67 public base::NonThreadSafe { 68 public base::NonThreadSafe,
69 public KeepAliveStateObserver {
68 public: 70 public:
69 // |local_state_task_runner| must be a shutdown-blocking task runner. 71 // |local_state_task_runner| must be a shutdown-blocking task runner.
70 BrowserProcessImpl(base::SequencedTaskRunner* local_state_task_runner, 72 BrowserProcessImpl(base::SequencedTaskRunner* local_state_task_runner,
71 const base::CommandLine& command_line); 73 const base::CommandLine& command_line);
72 ~BrowserProcessImpl() override; 74 ~BrowserProcessImpl() override;
73 75
74 // Called before the browser threads are created. 76 // Called before the browser threads are created.
75 void PreCreateThreads(); 77 void PreCreateThreads();
76 78
77 // Called after the threads have been created but before the message loops 79 // Called after the threads have been created but before the message loops
(...skipping 29 matching lines...) Expand all
107 NotificationUIManager* notification_ui_manager() override; 109 NotificationUIManager* notification_ui_manager() override;
108 message_center::MessageCenter* message_center() override; 110 message_center::MessageCenter* message_center() override;
109 policy::BrowserPolicyConnector* browser_policy_connector() override; 111 policy::BrowserPolicyConnector* browser_policy_connector() override;
110 policy::PolicyService* policy_service() override; 112 policy::PolicyService* policy_service() override;
111 IconManager* icon_manager() override; 113 IconManager* icon_manager() override;
112 GLStringManager* gl_string_manager() override; 114 GLStringManager* gl_string_manager() override;
113 GpuModeManager* gpu_mode_manager() override; 115 GpuModeManager* gpu_mode_manager() override;
114 void CreateDevToolsHttpProtocolHandler(const std::string& ip, 116 void CreateDevToolsHttpProtocolHandler(const std::string& ip,
115 uint16_t port) override; 117 uint16_t port) override;
116 void CreateDevToolsAutoOpener() override; 118 void CreateDevToolsAutoOpener() override;
117 unsigned int AddRefModule() override;
118 unsigned int ReleaseModule() override;
119 bool IsShuttingDown() override; 119 bool IsShuttingDown() override;
120 printing::PrintJobManager* print_job_manager() override; 120 printing::PrintJobManager* print_job_manager() override;
121 printing::PrintPreviewDialogController* print_preview_dialog_controller() 121 printing::PrintPreviewDialogController* print_preview_dialog_controller()
122 override; 122 override;
123 printing::BackgroundPrintingManager* background_printing_manager() override; 123 printing::BackgroundPrintingManager* background_printing_manager() override;
124 IntranetRedirectDetector* intranet_redirect_detector() override; 124 IntranetRedirectDetector* intranet_redirect_detector() override;
125 const std::string& GetApplicationLocale() override; 125 const std::string& GetApplicationLocale() override;
126 void SetApplicationLocale(const std::string& locale) override; 126 void SetApplicationLocale(const std::string& locale) override;
127 DownloadStatusUpdater* download_status_updater() override; 127 DownloadStatusUpdater* download_status_updater() override;
128 DownloadRequestLimiter* download_request_limiter() override; 128 DownloadRequestLimiter* download_request_limiter() override;
(...skipping 23 matching lines...) Expand all
152 #endif 152 #endif
153 network_time::NetworkTimeTracker* network_time_tracker() override; 153 network_time::NetworkTimeTracker* network_time_tracker() override;
154 gcm::GCMDriver* gcm_driver() override; 154 gcm::GCMDriver* gcm_driver() override;
155 memory::TabManager* GetTabManager() override; 155 memory::TabManager* GetTabManager() override;
156 shell_integration::DefaultWebClientState CachedDefaultWebClientState() 156 shell_integration::DefaultWebClientState CachedDefaultWebClientState()
157 override; 157 override;
158 158
159 static void RegisterPrefs(PrefRegistrySimple* registry); 159 static void RegisterPrefs(PrefRegistrySimple* registry);
160 160
161 private: 161 private:
162 // KeepAliveStateObserver implementation
163 void OnKeepAliveStateChanged(bool is_keeping_alive) override;
164 void OnKeepAliveRestartStateChanged(bool can_restart) override;
165
162 void CreateWatchdogThread(); 166 void CreateWatchdogThread();
163 void CreateProfileManager(); 167 void CreateProfileManager();
164 void CreateLocalState(); 168 void CreateLocalState();
165 void CreateViewedPageTracker(); 169 void CreateViewedPageTracker();
166 void CreateIconManager(); 170 void CreateIconManager();
167 void CreateIntranetRedirectDetector(); 171 void CreateIntranetRedirectDetector();
168 void CreateNotificationUIManager(); 172 void CreateNotificationUIManager();
169 void CreateStatusTrayManager(); 173 void CreateStatusTrayManager();
170 void CreatePrintPreviewDialogController(); 174 void CreatePrintPreviewDialogController();
171 void CreateBackgroundPrintingManager(); 175 void CreateBackgroundPrintingManager();
172 void CreateSafeBrowsingService(); 176 void CreateSafeBrowsingService();
173 void CreateSafeBrowsingDetectionService(); 177 void CreateSafeBrowsingDetectionService();
174 void CreateStatusTray(); 178 void CreateStatusTray();
175 void CreateBackgroundModeManager(); 179 void CreateBackgroundModeManager();
176 void CreateGCMDriver(); 180 void CreateGCMDriver();
177 181
178 void ApplyAllowCrossOriginAuthPromptPolicy(); 182 void ApplyAllowCrossOriginAuthPromptPolicy();
179 void ApplyDefaultBrowserPolicy(); 183 void ApplyDefaultBrowserPolicy();
180 void ApplyMetricsReportingPolicy(); 184 void ApplyMetricsReportingPolicy();
181 185
182 void CacheDefaultWebClientState(); 186 void CacheDefaultWebClientState();
183 187
188 // Methods called to control our lifetime. The browser process can be "pinned"
189 // to make sure it keeps running.
190 void Pin();
191 void Unpin();
192
184 scoped_ptr<metrics_services_manager::MetricsServicesManager> 193 scoped_ptr<metrics_services_manager::MetricsServicesManager>
185 metrics_services_manager_; 194 metrics_services_manager_;
186 195
187 scoped_ptr<IOThread> io_thread_; 196 scoped_ptr<IOThread> io_thread_;
188 197
189 bool created_watchdog_thread_; 198 bool created_watchdog_thread_;
190 scoped_ptr<WatchDogThread> watchdog_thread_; 199 scoped_ptr<WatchDogThread> watchdog_thread_;
191 200
192 bool created_browser_policy_connector_; 201 bool created_browser_policy_connector_;
193 // Must be destroyed after |local_state_|. 202 // Must be destroyed after |local_state_|.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 244
236 scoped_ptr<StatusTray> status_tray_; 245 scoped_ptr<StatusTray> status_tray_;
237 246
238 #if BUILDFLAG(ENABLE_BACKGROUND) 247 #if BUILDFLAG(ENABLE_BACKGROUND)
239 scoped_ptr<BackgroundModeManager> background_mode_manager_; 248 scoped_ptr<BackgroundModeManager> background_mode_manager_;
240 #endif 249 #endif
241 250
242 bool created_safe_browsing_service_; 251 bool created_safe_browsing_service_;
243 scoped_refptr<safe_browsing::SafeBrowsingService> safe_browsing_service_; 252 scoped_refptr<safe_browsing::SafeBrowsingService> safe_browsing_service_;
244 253
245 unsigned int module_ref_count_; 254 bool shutting_down_;
246 bool did_start_;
247 255
248 bool tearing_down_; 256 bool tearing_down_;
249 257
250 // Ensures that all the print jobs are finished before closing the browser. 258 // Ensures that all the print jobs are finished before closing the browser.
251 scoped_ptr<printing::PrintJobManager> print_job_manager_; 259 scoped_ptr<printing::PrintJobManager> print_job_manager_;
252 260
253 std::string locale_; 261 std::string locale_;
254 262
255 // Download status updates (like a changing application icon on dock/taskbar) 263 // Download status updates (like a changing application icon on dock/taskbar)
256 // are global per-application. DownloadStatusUpdater does no work in the ctor 264 // are global per-application. DownloadStatusUpdater does no work in the ctor
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 // chrome/browser/memory/tab_manager_browsertest.cc 334 // chrome/browser/memory/tab_manager_browsertest.cc
327 scoped_ptr<memory::TabManager> tab_manager_; 335 scoped_ptr<memory::TabManager> tab_manager_;
328 #endif 336 #endif
329 337
330 shell_integration::DefaultWebClientState cached_default_web_client_state_; 338 shell_integration::DefaultWebClientState cached_default_web_client_state_;
331 339
332 DISALLOW_COPY_AND_ASSIGN(BrowserProcessImpl); 340 DISALLOW_COPY_AND_ASSIGN(BrowserProcessImpl);
333 }; 341 };
334 342
335 #endif // CHROME_BROWSER_BROWSER_PROCESS_IMPL_H_ 343 #endif // CHROME_BROWSER_BROWSER_PROCESS_IMPL_H_
OLDNEW
« no previous file with comments | « chrome/browser/browser_process.h ('k') | chrome/browser/browser_process_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698