blob: f0fd524575bf7bbf86e22a08b390f5ca0aabd5ae [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
avie4d7b6f2015-12-26 00:59:1818#include "base/macros.h"
[email protected]80745e32012-05-08 01:22:1219#include "base/memory/ref_counted.h"
gab25894fe2017-05-30 03:40:3620#include "base/sequence_checker.h"
[email protected]4dcb7972013-06-28 15:15:4121#include "base/timer/timer.h"
avie4d7b6f2015-12-26 00:59:1822#include "build/build_config.h"
Yuta Hijikata235fc62b2020-12-08 03:48:3223#include "build/chromeos_buildflags.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"
Xi Han07bad2892018-10-04 15:13:5827#include "components/metrics_services_manager/metrics_services_manager.h"
Scott Violet9ae82892018-03-01 18:38:1228#include "components/nacl/common/buildflags.h"
Xi Handdb1ab12018-08-27 22:18:5429#include "components/prefs/persistent_pref_store.h"
brettwb1fc1b82016-02-02 00:19:0830#include "components/prefs/pref_change_registrar.h"
Scott Violetc8240b02018-03-08 22:03:5931#include "extensions/buildflags/buildflags.h"
Scott Violeta35f9a42018-03-22 22:00:4432#include "media/media_buildflags.h"
Scott Violet02e38b92018-03-27 23:42:1433#include "ppapi/buildflags/buildflags.h"
Scott Violet318a55f2018-03-30 19:08:1934#include "printing/buildflags/buildflags.h"
Tarun Bansal86b39222018-09-21 02:07:3235#include "services/network/public/cpp/network_quality_tracker.h"
Takuto Ikutaaa3b796c2019-02-06 02:54:5636#include "services/network/public/mojom/network_service.mojom-forward.h"
[email protected]b112a4c2009-02-01 20:24:0137
Greg Thompson08451a42020-02-04 23:45:5438#if !defined(OS_ANDROID)
39#include "chrome/browser/upgrade_detector/build_state.h"
40#endif
41
Ryan Sturmf0ad4292019-05-10 00:51:1042class BatteryMetrics;
Scott Violet875789e2018-02-02 07:46:4843class ChromeMetricsServicesManagerClient;
dgozman54cc54e2016-02-23 03:47:3044class DevToolsAutoOpener;
[email protected]4475d232011-07-27 15:29:2045class RemoteDebuggingServer;
[email protected]b1de2c72013-02-06 02:45:4746class PrefRegistrySimple;
Lukasz Anforowicz60d1253d2019-05-08 16:31:3747class SecureOriginPrefsObserver;
Lukasz Anforowicz65c61162019-03-27 20:33:5848class SiteIsolationPrefsObserver;
Toni Barzicb598380e2018-11-26 19:14:1049class SystemNotificationHelper;
Xi Han85079c22019-04-18 21:43:0550class StartupData;
initial.commit09911bf2008-07-26 23:55:2951
bauerbecab4f52017-03-13 20:16:4152#if BUILDFLAG(ENABLE_PLUGINS)
[email protected]2366a3a2012-10-02 20:41:1453class PluginsResourceService;
54#endif
55
[email protected]0de615a2012-11-08 04:40:5956namespace base {
[email protected]2f3b1cc2014-03-17 23:07:1557class CommandLine;
[email protected]0de615a2012-11-08 04:40:5958}
59
[email protected]aa3dd492013-11-05 17:09:0960namespace extensions {
61class ExtensionsBrowserClient;
62}
63
[email protected]c027d6d2014-06-05 15:25:4064namespace gcm {
65class GCMDriver;
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
Elad Alon39b1f6cc2018-08-30 09:52:2173namespace webrtc_event_logging {
74class WebRtcEventLogManager;
75} // namespace webrtc_event_logging
76
initial.commit09911bf2008-07-26 23:55:2977// Real implementation of BrowserProcess that creates and returns the services.
[email protected]6618d1d2010-12-15 21:18:4778class BrowserProcessImpl : public BrowserProcess,
dgnfe075c82016-03-18 11:25:3579 public KeepAliveStateObserver {
initial.commit09911bf2008-07-26 23:55:2980 public:
Xi Han85079c22019-04-18 21:43:0581 // |startup_data| should not be null. The BrowserProcessImpl
Xi Han07bad2892018-10-04 15:13:5882 // will take the PrefService owned by the creator as the Local State instead
83 // of loading the JSON file from disk.
Xi Han85079c22019-04-18 21:43:0584 explicit BrowserProcessImpl(StartupData* startup_data);
Daniel Chenga542fca2014-10-21 09:51:2985 ~BrowserProcessImpl() override;
initial.commit09911bf2008-07-26 23:55:2986
Scott Violet875789e2018-02-02 07:46:4887 // Called to complete initialization.
88 void Init();
89
Wez25fd35f2018-05-25 22:57:4190#if !defined(OS_ANDROID)
Greg Thompson822ab51a2018-09-18 06:45:2991 // Sets a closure to be run to break out of a run loop on browser shutdown
92 // (when the KeepAlive count reaches zero).
93 // TODO(https://crbug.com/845966): This is also used on macOS for the Cocoa
94 // first run dialog so that shutdown can be initiated via a signal while the
95 // first run dialog is showing.
Filip Gorski209a3472018-08-27 23:03:4196 void SetQuitClosure(base::OnceClosure quit_closure);
Wez25fd35f2018-05-25 22:57:4197#endif
98
Avi Drissman2e458df2020-07-29 16:24:3199#if defined(OS_MAC)
Greg Thompson822ab51a2018-09-18 06:45:29100 // Clears the quit closure. Shutdown will not be initiated should the
101 // KeepAlive count reach zero. This function may be called more than once.
102 // TODO(https://crbug.com/845966): Remove this once the Cocoa first run
103 // dialog no longer needs it.
104 void ClearQuitClosure();
Wez25fd35f2018-05-25 22:57:41105#endif
106
[email protected]99907362012-01-11 05:41:40107 // Called before the browser threads are created.
Bernhard Bauer5533f9912017-11-06 17:56:02108 void PreCreateThreads(const base::CommandLine& command_line);
[email protected]2e5b60a22011-11-28 15:56:41109
[email protected]d2caaa22011-12-12 03:04:15110 // Called after the threads have been created but before the message loops
111 // starts running. Allows the browser process to do any initialization that
112 // requires all threads running.
113 void PreMainMessageLoopRun();
114
[email protected]2e5b60a22011-11-28 15:56:41115 // Most cleanup is done by these functions, driven from
116 // ChromeBrowserMain based on notifications from the content
117 // framework, rather than in the destructor, so that we can
118 // interleave cleanup with threads being stopped.
thestigd75ce5532015-10-05 22:08:34119#if !defined(OS_ANDROID)
[email protected]2e5b60a22011-11-28 15:56:41120 void StartTearDown();
[email protected]99907362012-01-11 05:41:40121 void PostDestroyThreads();
thestigd75ce5532015-10-05 22:08:34122#endif
[email protected]2e5b60a22011-11-28 15:56:41