blob: 3e4e38847c4d62cbe6ca4b0b707767e2c3ce5fc8 [file] [log] [blame]
[email protected]3a80ea332012-01-09 19:53:291// Copyright (c) 2012 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit09911bf2008-07-26 23:55:294
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
7// if we tried to create a service, and not try creating it over and over if
8// the creation failed.
9
[email protected]58dca552009-06-17 00:35:0210#ifndef CHROME_BROWSER_BROWSER_PROCESS_IMPL_H_
11#define CHROME_BROWSER_BROWSER_PROCESS_IMPL_H_
initial.commit09911bf2008-07-26 23:55:2912
avie4d7b6f2015-12-26 00:59:1813#include <stdint.h>
14
dcheng4af48582016-04-19 00:29:3515#include <memory>
initial.commit09911bf2008-07-26 23:55:2916#include <string>
17
[email protected]6b4e6852012-02-14 04:02:4818#include "base/debug/stack_trace.h"
avie4d7b6f2015-12-26 00:59:1819#include "base/macros.h"
[email protected]80745e32012-05-08 01:22:1220#include "base/memory/ref_counted.h"
gab25894fe2017-05-30 03:40:3621#include "base/sequence_checker.h"
[email protected]4dcb7972013-06-28 15:15:4122#include "base/timer/timer.h"
avie4d7b6f2015-12-26 00:59:1823#include "build/build_config.h"
initial.commit09911bf2008-07-26 23:55:2924#include "chrome/browser/browser_process.h"
Scott Violet6200d332018-02-23 21:29:2325#include "chrome/common/buildflags.h"
Michael Giuffrida2dbce0d12017-09-02 03:30:5926#include "components/keep_alive_registry/keep_alive_state_observer.h"
Scott Violet9ae82892018-03-01 18:38:1227#include "components/nacl/common/buildflags.h"
brettwb1fc1b82016-02-02 00:19:0828#include "components/prefs/pref_change_registrar.h"
Scott Violetc8240b02018-03-08 22:03:5929#include "extensions/buildflags/buildflags.h"
Scott Violeta35f9a42018-03-22 22:00:4430#include "media/media_buildflags.h"
Scott Violet02e38b92018-03-27 23:42:1431#include "ppapi/buildflags/buildflags.h"
Scott Violet318a55f2018-03-30 19:08:1932#include "printing/buildflags/buildflags.h"
Ken Rockot54311e62018-02-10 19:01:5233#include "services/network/public/mojom/network_service.mojom.h"
[email protected]b112a4c2009-02-01 20:24:0134
wfh22e2f4a22015-04-28 22:39:2135class ChromeChildProcessWatcher;
reillyge471fab2014-08-29 01:58:4336class ChromeDeviceClient;
Scott Violet875789e2018-02-02 07:46:4837class ChromeMetricsServicesManagerClient;
[email protected]8bcdf072011-06-03 16:52:1538class ChromeResourceDispatcherHostDelegate;
dgozman54cc54e2016-02-23 03:47:3039class DevToolsAutoOpener;
[email protected]4475d232011-07-27 15:29:2040class RemoteDebuggingServer;
[email protected]b1de2c72013-02-06 02:45:4741class PrefRegistrySimple;
initial.commit09911bf2008-07-26 23:55:2942
bauerbecab4f52017-03-13 20:16:4143#if BUILDFLAG(ENABLE_PLUGINS)
[email protected]2366a3a2012-10-02 20:41:1444class PluginsResourceService;
45#endif
46
Elad Alon7264d6a2018-03-21 15:06:2647#if BUILDFLAG(ENABLE_WEBRTC)
48class WebRtcEventLogManager;
49#endif
50
[email protected]0de615a2012-11-08 04:40:5951namespace base {
[email protected]2f3b1cc2014-03-17 23:07:1552class CommandLine;
[email protected]0de615a2012-11-08 04:40:5953class SequencedTaskRunner;
54}
55
[email protected]aa3dd492013-11-05 17:09:0956namespace extensions {
57class ExtensionsBrowserClient;
58}
59
[email protected]c027d6d2014-06-05 15:25:4060namespace gcm {
61class GCMDriver;
62}
63
drogerc690e8802015-09-21 14:29:1664namespace net_log {
65class ChromeNetLog;
66}
67
[email protected]5b869962011-09-20 19:49:3368namespace policy {
Scott Violetfdd6f352018-01-12 19:12:2969class ChromeBrowserPolicyConnector;
[email protected]a4179c2a2012-02-09 18:14:2170class PolicyService;
Scott Violetfdd6f352018-01-12 19:12:2971} // namespace policy
[email protected]fcf53572011-06-29 15:44:3772
initial.commit09911bf2008-07-26 23:55:2973// Real implementation of BrowserProcess that creates and returns the services.
[email protected]6618d1d2010-12-15 21:18:4774class BrowserProcessImpl : public BrowserProcess,
dgnfe075c82016-03-18 11:25:3575 public KeepAliveStateObserver {
initial.commit09911bf2008-07-26 23:55:2976 public:
[email protected]0de615a2012-11-08 04:40:5977 // |local_state_task_runner| must be a shutdown-blocking task runner.
Bernhard Bauer5533f9912017-11-06 17:56:0278 explicit BrowserProcessImpl(
79 base::SequencedTaskRunner* local_state_task_runner);
Daniel Chenga542fca2014-10-21 09:51:2980 ~BrowserProcessImpl() override;
initial.commit09911bf2008-07-26 23:55:2981
Scott Violet875789e2018-02-02 07:46:4882 // Called to complete initialization.
83 void Init();
84
[email protected]99907362012-01-11 05:41:4085 // Called before the browser threads are created.
Bernhard Bauer5533f9912017-11-06 17:56:0286 void PreCreateThreads(const base::CommandLine& command_line);
[email protected]2e5b60a22011-11-28 15:56:4187
[email protected]d2caaa22011-12-12 03:04:1588 // Called after the threads have been created but before the message loops
89 // starts running. Allows the browser process to do any initialization that
90 // requires all threads running.
91 void PreMainMessageLoopRun();
92
[email protected]2e5b60a22011-11-28 15:56:4193 // Most cleanup is done by these functions, driven from
94 // ChromeBrowserMain based on notifications from the content
95 // framework, rather than in the destructor, so that we can
96 // interleave cleanup with threads being stopped.
thestigd75ce5532015-10-05 22:08:3497#if !defined(OS_ANDROID)
[email protected]2e5b60a22011-11-28 15:56:4198 void StartTearDown();
[email protected]99907362012-01-11 05:41:4099 void PostDestroyThreads();
thestigd75ce5532015-10-05 22:08:34100#endif
[email protected]2e5b60a22011-11-28 15:56:41101
[email protected]80745e32012-05-08 01:22:12102 // BrowserProcess implementation.
Daniel Chenga542fca2014-10-21 09:51:29103 void ResourceDispatcherHostCreated() override;
104 void EndSession() override;
Gabriel Charetteb1af7ffb2017-07-27 06:10:35105 void FlushLocalStateAndReply(base::OnceClosure reply) override;
blundell695d61f2015-10-21 11:25:53106 metrics_services_manager::MetricsServicesManager* GetMetricsServicesManager()
107 override;
Daniel Chenga542fca2014-10-21 09:51:29108 metrics::MetricsService* metrics_service() override;
nzolghadrd87a308d2016-12-07 15:45:56109 rappor::RapporServiceImpl* rappor_service() override;
Daniel Chenga542fca2014-10-21 09:51:29110 IOThread* io_thread() override;
Matt Menke21b9cc62017-08-23 15:45:45111 SystemNetworkContextManager* system_network_context_manager() override;
Helen Li72c87ae42017-11-06 18:31:56112 content::NetworkConnectionTracker* network_connection_tracker() override;
Daniel Chenga542fca2014-10-21 09:51:29113 WatchDogThread* watchdog_thread() override;
114 ProfileManager* profile_manager() override;
115 PrefService* local_state() override;
116 net::URLRequestContextGetter* system_request_context() override;
blundell57bcfed2015-09-04 08:44:45117 variations::VariationsService* variations_service() override;
Daniel Chenga542fca2014-10-21 09:51:29118 BrowserProcessPlatformPart* platform_part() override;
119 extensions::EventRouterForwarder* extension_event_router_forwarder() override;
120 NotificationUIManager* notification_ui_manager() override;
miguelg23cd2dd72016-04-21 15:24:03121 NotificationPlatformBridge* notification_platform_bridge() override;
Scott Violetfdd6f352018-01-12 19:12:29122 policy::ChromeBrowserPolicyConnector* browser_policy_connector() override;
Daniel Chenga542fca2014-10-21 09:51:29123 policy::PolicyService* policy_service() override;
124 IconManager* icon_manager() override;
Daniel Chenga542fca2014-10-21 09:51:29125 GpuModeManager* gpu_mode_manager() override;
Pavel Feldmanc9ae59c2018-02-13 16:15:15126 void CreateDevToolsProtocolHandler() override;
dgozman54cc54e2016-02-23 03:47:30127 void CreateDevToolsAutoOpener() override;
Daniel Chenga542fca2014-10-21 09:51:29128 bool IsShuttingDown() override;
129 printing::PrintJobManager* print_job_manager() override;
130 printing::PrintPreviewDialogController* print_preview_dialog_controller()
131 override;
132 printing::BackgroundPrintingManager* background_printing_manager() override;
133 IntranetRedirectDetector* intranet_redirect_detector() override;
134 const std::string& GetApplicationLocale() override;
135 void SetApplicationLocale(const std::string& locale) override;
136 DownloadStatusUpdater* download_status_updater() override;
137 DownloadRequestLimiter* download_request_limiter() override;
138 BackgroundModeManager* background_mode_manager() override;
139 void set_background_mode_manager_for_test(
dcheng4af48582016-04-19 00:29:35140 std::unique_ptr<BackgroundModeManager> manager) override;
Daniel Chenga542fca2014-10-21 09:51:29141 StatusTray* status_tray() override;
vakh9a474d832015-11-13 01:43:09142 safe_browsing::SafeBrowsingService* safe_browsing_service() override;
Daniel Chenga542fca2014-10-21 09:51:29143 safe_browsing::ClientSideDetectionService* safe_browsing_detection_service()
144 override;
csharrison8a923d62017-03-10 15:42:13145 subresource_filter::ContentRulesetService*
146 subresource_filter_ruleset_service() override;
Sophie Changf453c0522017-11-03 06:33:49147 optimization_guide::OptimizationGuideService* optimization_guide_service()
148 override;
[email protected]6641bf662009-08-21 00:34:09149
Michael Giuffridadc8030c2017-08-02 13:22:44150#if defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS))
dchenge1bc7982014-10-30 00:32:40151 void StartAutoupdateTimer() override;
[email protected]3cdacd42010-04-30 18:55:53152#endif
[email protected]bd48c2b02010-04-09 20:32:42153
drogerc690e8802015-09-21 14:29:16154 net_log::ChromeNetLog* net_log() override;
Daniel Chenga542fca2014-10-21 09:51:29155 component_updater::ComponentUpdateService* component_updater() override;
bauerb22951c32015-02-12 13:18:17156 component_updater::SupervisedUserWhitelistInstaller*
157 supervised_user_whitelist_installer() override;
Daniel Chenga542fca2014-10-21 09:51:29158 MediaFileSystemRegistry* media_file_system_registry() override;
Brett Wilson0748bf412016-11-22 17:55:46159#if BUILDFLAG(ENABLE_WEBRTC)
Daniel Chenga542fca2014-10-21 09:51:29160 WebRtcLogUploader* webrtc_log_uploader() override;
[email protected]bbf32c52013-06-03 14:05:52161#endif
Daniel Chenga542fca2014-10-21 09:51:29162 network_time::NetworkTimeTracker* network_time_tracker() override;
163 gcm::GCMDriver* gcm_driver() override;
lpyfedf65a2017-06-01 01:41:24164 resource_coordinator::TabManager* GetTabManager() override;
pmonette9fa59e882016-02-10 00:12:19165 shell_integration::DefaultWebClientState CachedDefaultWebClientState()
grtf14398c2015-07-14 15:11:44166 override;
vitaliiiee920542016-11-25 15:20:23167 physical_web::PhysicalWebDataSource* GetPhysicalWebDataSource() override;
Sam McNallye36abbc2017-07-20 01:04:28168 prefs::InProcessPrefServiceFactory* pref_service_factory() const override;
[email protected]ca167a32011-09-30 15:19:11169
[email protected]b1de2c72013-02-06 02:45:47170 static void RegisterPrefs(PrefRegistrySimple* registry);
171
initial.commit09911bf2008-07-26 23:55:29172 private:
dgnfe075c82016-03-18 11:25:35173 // KeepAliveStateObserver implementation
174 void OnKeepAliveStateChanged(bool is_keeping_alive) override;
175 void OnKeepAliveRestartStateChanged(bool can_restart) override;
176
[email protected]0b565182011-03-02 18:11:15177 void CreateWatchdogThread();
initial.commit09911bf2008-07-26 23:55:29178 void CreateProfileManager();
initial.commit09911bf2008-07-26 23:55:29179 void CreateLocalState();
initial.commit09911bf2008-07-26 23:55:29180 void CreateIconManager();
[email protected]c4ff4952010-01-08 19:12:47181 void CreateIntranetRedirectDetector();
miguelg23cd2dd72016-04-21 15:24:03182 void CreateNotificationPlatformBridge();
[email protected]29672ab2009-10-30 03:44:03183 void CreateNotificationUIManager();
[email protected]d8ce31e2012-12-19 05:09:21184 void CreatePrintPreviewDialogController();
[email protected]68f88b992011-05-07 02:01:39185 void CreateBackgroundPrintingManager();
[email protected]462a0ff2011-06-02 17:15:34186 void CreateSafeBrowsingService();
engedyc5ef21ad2016-06-17 20:22:27187 void CreateSubresourceFilterRulesetService();
Sophie Changf453c0522017-11-03 06:33:49188 void CreateOptimizationGuideService();
[email protected]9e7f015f2011-05-28 00:24:25189 void CreateStatusTray();
190 void CreateBackgroundModeManager();
[email protected]c027d6d2014-06-05 15:25:40191 void CreateGCMDriver();
mattreynoldsf1aab392016-10-07 00:17:07192 void CreatePhysicalWebDataSource();
[email protected]a7a5e992010-12-09 23:39:51193
[email protected]40850a52011-05-26 22:07:35194 void ApplyAllowCrossOriginAuthPromptPolicy();
[email protected]b61f62a2011-11-01 02:02:10195 void ApplyDefaultBrowserPolicy();
Lei Zhang4736dd22017-07-07 01:38:17196#if !defined(OS_ANDROID)
[email protected]459158c2013-11-14 00:25:15197 void ApplyMetricsReportingPolicy();
Lei Zhang4736dd22017-07-07 01:38:17198#endif
[email protected]419a0572011-04-18 22:21:46199
grtf14398c2015-07-14 15:11:44200 void CacheDefaultWebClientState();
201
dgnfe075c82016-03-18 11:25:35202 // Methods called to control our lifetime. The browser process can be "pinned"
203 // to make sure it keeps running.
204 void Pin();
205 void Unpin();
206
Scott Violet875789e2018-02-02 07:46:48207 // |metrics_services_manager_| owns this.
208 ChromeMetricsServicesManagerClient* metrics_services_manager_client_ =
209 nullptr;
210
dcheng4af48582016-04-19 00:29:35211 std::unique_ptr<metrics_services_manager::MetricsServicesManager>
blundell695d61f2015-10-21 11:25:53212 metrics_services_manager_;
[email protected]