blob: 697a8ff25e323cf0377cc363cf3272e05c182723 [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"
dgnfe075c82016-03-18 11:25:3525#include "chrome/browser/lifetime/keep_alive_state_observer.h"
brettw3224f3c2016-02-25 20:07:4526#include "chrome/common/features.h"
brettwb1fc1b82016-02-02 00:19:0827#include "components/prefs/pref_change_registrar.h"
brettw00899e62016-11-12 02:10:1728#include "extensions/features/features.h"
Brett Wilson0748bf412016-11-22 17:55:4629#include "media/media_features.h"
bauerbecab4f52017-03-13 20:16:4130#include "ppapi/features/features.h"
Brett Wilson65f951c2016-11-03 22:06:1231#include "printing/features/features.h"
[email protected]b112a4c2009-02-01 20:24:0132
wfh22e2f4a22015-04-28 22:39:2133class ChromeChildProcessWatcher;
reillyge471fab2014-08-29 01:58:4334class ChromeDeviceClient;
[email protected]8bcdf072011-06-03 16:52:1535class ChromeResourceDispatcherHostDelegate;
dgozman54cc54e2016-02-23 03:47:3036class DevToolsAutoOpener;
[email protected]4475d232011-07-27 15:29:2037class RemoteDebuggingServer;
[email protected]b1de2c72013-02-06 02:45:4738class PrefRegistrySimple;
initial.commit09911bf2008-07-26 23:55:2939
bauerbecab4f52017-03-13 20:16:4140#if BUILDFLAG(ENABLE_PLUGINS)
[email protected]2366a3a2012-10-02 20:41:1441class PluginsResourceService;
42#endif
43
[email protected]0de615a2012-11-08 04:40:5944namespace base {
[email protected]2f3b1cc2014-03-17 23:07:1545class CommandLine;
[email protected]0de615a2012-11-08 04:40:5946class SequencedTaskRunner;
47}
48
[email protected]aa3dd492013-11-05 17:09:0949namespace extensions {
50class ExtensionsBrowserClient;
51}
52
[email protected]c027d6d2014-06-05 15:25:4053namespace gcm {
54class GCMDriver;
55}
56
drogerc690e8802015-09-21 14:29:1657namespace net_log {
58class ChromeNetLog;
59}
60
[email protected]5b869962011-09-20 19:49:3361namespace policy {
[email protected]fcf53572011-06-29 15:44:3762class BrowserPolicyConnector;
[email protected]a4179c2a2012-02-09 18:14:2163class PolicyService;
[email protected]fcf53572011-06-29 15:44:3764};
65
initial.commit09911bf2008-07-26 23:55:2966// Real implementation of BrowserProcess that creates and returns the services.
[email protected]6618d1d2010-12-15 21:18:4767class BrowserProcessImpl : public BrowserProcess,
dgnfe075c82016-03-18 11:25:3568 public KeepAliveStateObserver {
initial.commit09911bf2008-07-26 23:55:2969 public:
[email protected]0de615a2012-11-08 04:40:5970 // |local_state_task_runner| must be a shutdown-blocking task runner.
71 BrowserProcessImpl(base::SequencedTaskRunner* local_state_task_runner,
[email protected]2f3b1cc2014-03-17 23:07:1572 const base::CommandLine& command_line);
Daniel Chenga542fca2014-10-21 09:51:2973 ~BrowserProcessImpl() override;
initial.commit09911bf2008-07-26 23:55:2974
[email protected]99907362012-01-11 05:41:4075 // Called before the browser threads are created.
76 void PreCreateThreads();
[email protected]2e5b60a22011-11-28 15:56:4177
[email protected]d2caaa22011-12-12 03:04:1578 // Called after the threads have been created but before the message loops
79 // starts running. Allows the browser process to do any initialization that
80 // requires all threads running.
81 void PreMainMessageLoopRun();
82
[email protected]2e5b60a22011-11-28 15:56:4183 // Most cleanup is done by these functions, driven from
84 // ChromeBrowserMain based on notifications from the content
85 // framework, rather than in the destructor, so that we can
86 // interleave cleanup with threads being stopped.
thestigd75ce5532015-10-05 22:08:3487#if !defined(OS_ANDROID)
[email protected]2e5b60a22011-11-28 15:56:4188 void StartTearDown();
[email protected]99907362012-01-11 05:41:4089 void PostDestroyThreads();
thestigd75ce5532015-10-05 22:08:3490#endif
[email protected]2e5b60a22011-11-28 15:56:4191
[email protected]80745e32012-05-08 01:22:1292 // BrowserProcess implementation.
Daniel Chenga542fca2014-10-21 09:51:2993 void ResourceDispatcherHostCreated() override;
94 void EndSession() override;
Gabriel Charetteb1af7ffb2017-07-27 06:10:3595 void FlushLocalStateAndReply(base::OnceClosure reply) override;
blundell695d61f2015-10-21 11:25:5396 metrics_services_manager::MetricsServicesManager* GetMetricsServicesManager()
97 override;
Daniel Chenga542fca2014-10-21 09:51:2998 metrics::MetricsService* metrics_service() override;
nzolghadrd87a308d2016-12-07 15:45:5699 rappor::RapporServiceImpl* rappor_service() override;
oysteineb068f272017-05-23 00:14:01100 ukm::UkmRecorder* ukm_recorder() override;
Daniel Chenga542fca2014-10-21 09:51:29101 IOThread* io_thread() override;
102 WatchDogThread* watchdog_thread() override;
103 ProfileManager* profile_manager() override;
104 PrefService* local_state() override;
105 net::URLRequestContextGetter* system_request_context() override;
blundell57bcfed2015-09-04 08:44:45106 variations::VariationsService* variations_service() override;
Daniel Chenga542fca2014-10-21 09:51:29107 BrowserProcessPlatformPart* platform_part() override;
108 extensions::EventRouterForwarder* extension_event_router_forwarder() override;
109 NotificationUIManager* notification_ui_manager() override;
miguelg23cd2dd72016-04-21 15:24:03110 NotificationPlatformBridge* notification_platform_bridge() override;
Daniel Chenga542fca2014-10-21 09:51:29111 message_center::MessageCenter* message_center() override;
112 policy::BrowserPolicyConnector* browser_policy_connector() override;
113 policy::PolicyService* policy_service() override;
114 IconManager* icon_manager() override;
Daniel Chenga542fca2014-10-21 09:51:29115 GpuModeManager* gpu_mode_manager() override;
qinmin9899e492016-08-05 19:03:26116 GpuProfileCache* gpu_profile_cache() override;
scottmg9ed5c142016-02-16 03:37:49117 void CreateDevToolsHttpProtocolHandler(const std::string& ip,
118 uint16_t port) override;
dgozman54cc54e2016-02-23 03:47:30119 void CreateDevToolsAutoOpener() override;
Daniel Chenga542fca2014-10-21 09:51:29120 bool IsShuttingDown() override;
121 printing::PrintJobManager* print_job_manager() override;
122 printing::PrintPreviewDialogController* print_preview_dialog_controller()
123 override;
124 printing::BackgroundPrintingManager* background_printing_manager() override;
125 IntranetRedirectDetector* intranet_redirect_detector() override;
126 const std::string& GetApplicationLocale() override;
127 void SetApplicationLocale(const std::string& locale) override;
128 DownloadStatusUpdater* download_status_updater() override;
129 DownloadRequestLimiter* download_request_limiter() override;
130 BackgroundModeManager* background_mode_manager() override;
131 void set_background_mode_manager_for_test(
dcheng4af48582016-04-19 00:29:35132 std::unique_ptr<BackgroundModeManager> manager) override;
Daniel Chenga542fca2014-10-21 09:51:29133 StatusTray* status_tray() override;
vakh9a474d832015-11-13 01:43:09134 safe_browsing::SafeBrowsingService* safe_browsing_service() override;
Daniel Chenga542fca2014-10-21 09:51:29135 safe_browsing::ClientSideDetectionService* safe_browsing_detection_service()
136 override;
csharrison8a923d62017-03-10 15:42:13137 subresource_filter::ContentRulesetService*
138 subresource_filter_ruleset_service() override;
[email protected]6641bf662009-08-21 00:34:09139
Michael Giuffridadc8030c2017-08-02 13:22:44140#if defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS))
dchenge1bc7982014-10-30 00:32:40141 void StartAutoupdateTimer() override;
[email protected]3cdacd42010-04-30 18:55:53142#endif
[email protected]bd48c2b02010-04-09 20:32:42143
drogerc690e8802015-09-21 14:29:16144 net_log::ChromeNetLog* net_log() override;
Daniel Chenga542fca2014-10-21 09:51:29145 component_updater::ComponentUpdateService* component_updater() override;
146 CRLSetFetcher* crl_set_fetcher() override;
147 component_updater::PnaclComponentInstaller* pnacl_component_installer()
148 override;
bauerb22951c32015-02-12 13:18:17149 component_updater::SupervisedUserWhitelistInstaller*
150 supervised_user_whitelist_installer() override;
Daniel Chenga542fca2014-10-21 09:51:29151 MediaFileSystemRegistry* media_file_system_registry() override;
Brett Wilson0748bf412016-11-22 17:55:46152#if BUILDFLAG(ENABLE_WEBRTC)
Daniel Chenga542fca2014-10-21 09:51:29153 WebRtcLogUploader* webrtc_log_uploader() override;
[email protected]bbf32c52013-06-03 14:05:52154#endif
Daniel Chenga542fca2014-10-21 09:51:29155 network_time::NetworkTimeTracker* network_time_tracker() override;
156 gcm::GCMDriver* gcm_driver() override;
lpyfedf65a2017-06-01 01:41:24157 resource_coordinator::TabManager* GetTabManager() override;
pmonette9fa59e882016-02-10 00:12:19158 shell_integration::DefaultWebClientState CachedDefaultWebClientState()
grtf14398c2015-07-14 15:11:44159 override;
vitaliiiee920542016-11-25 15:20:23160 physical_web::PhysicalWebDataSource* GetPhysicalWebDataSource() override;
Sam McNallye36abbc2017-07-20 01:04:28161 prefs::InProcessPrefServiceFactory* pref_service_factory() const override;
[email protected]ca167a32011-09-30 15:19:11162
[email protected]b1de2c72013-02-06 02:45:47163 static void RegisterPrefs(PrefRegistrySimple* registry);
164
initial.commit09911bf2008-07-26 23:55:29165 private:
dgnfe075c82016-03-18 11:25:35166 // KeepAliveStateObserver implementation
167 void OnKeepAliveStateChanged(bool is_keeping_alive) override;
168 void OnKeepAliveRestartStateChanged(bool can_restart) override;
169