[email protected] | 3a80ea33 | 2012-01-09 19:53:29 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4 | |
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] | 58dca55 | 2009-06-17 00:35:02 | [diff] [blame] | 10 | #ifndef CHROME_BROWSER_BROWSER_PROCESS_IMPL_H_ |
11 | #define CHROME_BROWSER_BROWSER_PROCESS_IMPL_H_ | ||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 12 | |
avi | e4d7b6f | 2015-12-26 00:59:18 | [diff] [blame] | 13 | #include <stdint.h> |
14 | |||||
dcheng | 4af4858 | 2016-04-19 00:29:35 | [diff] [blame] | 15 | #include <memory> |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 16 | #include <string> |
17 | |||||
avi | e4d7b6f | 2015-12-26 00:59:18 | [diff] [blame] | 18 | #include "base/macros.h" |
[email protected] | 80745e3 | 2012-05-08 01:22:12 | [diff] [blame] | 19 | #include "base/memory/ref_counted.h" |
gab | 25894fe | 2017-05-30 03:40:36 | [diff] [blame] | 20 | #include "base/sequence_checker.h" |
[email protected] | 4dcb797 | 2013-06-28 15:15:41 | [diff] [blame] | 21 | #include "base/timer/timer.h" |
avi | e4d7b6f | 2015-12-26 00:59:18 | [diff] [blame] | 22 | #include "build/build_config.h" |
Yuta Hijikata | 235fc62b | 2020-12-08 03:48:32 | [diff] [blame] | 23 | #include "build/chromeos_buildflags.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 24 | #include "chrome/browser/browser_process.h" |
Scott Violet | 6200d33 | 2018-02-23 21:29:23 | [diff] [blame] | 25 | #include "chrome/common/buildflags.h" |
Michael Giuffrida | 2dbce0d1 | 2017-09-02 03:30:59 | [diff] [blame] | 26 | #include "components/keep_alive_registry/keep_alive_state_observer.h" |
Xi Han | 07bad289 | 2018-10-04 15:13:58 | [diff] [blame] | 27 | #include "components/metrics_services_manager/metrics_services_manager.h" |
Scott Violet | 9ae8289 | 2018-03-01 18:38:12 | [diff] [blame] | 28 | #include "components/nacl/common/buildflags.h" |
Xi Han | ddb1ab1 | 2018-08-27 22:18:54 | [diff] [blame] | 29 | #include "components/prefs/persistent_pref_store.h" |
brettw | b1fc1b8 | 2016-02-02 00:19:08 | [diff] [blame] | 30 | #include "components/prefs/pref_change_registrar.h" |
Scott Violet | c8240b0 | 2018-03-08 22:03:59 | [diff] [blame] | 31 | #include "extensions/buildflags/buildflags.h" |
Scott Violet | a35f9a4 | 2018-03-22 22:00:44 | [diff] [blame] | 32 | #include "media/media_buildflags.h" |
Scott Violet | 02e38b9 | 2018-03-27 23:42:14 | [diff] [blame] | 33 | #include "ppapi/buildflags/buildflags.h" |
Scott Violet | 318a55f | 2018-03-30 19:08:19 | [diff] [blame] | 34 | #include "printing/buildflags/buildflags.h" |
Tarun Bansal | 86b3922 | 2018-09-21 02:07:32 | [diff] [blame] | 35 | #include "services/network/public/cpp/network_quality_tracker.h" |
Takuto Ikuta | aa3b796c | 2019-02-06 02:54:56 | [diff] [blame] | 36 | #include "services/network/public/mojom/network_service.mojom-forward.h" |
[email protected] | b112a4c | 2009-02-01 20:24:01 | [diff] [blame] | 37 | |
Greg Thompson | 08451a4 | 2020-02-04 23:45:54 | [diff] [blame] | 38 | #if !defined(OS_ANDROID) |
39 | #include "chrome/browser/upgrade_detector/build_state.h" | ||||
40 | #endif | ||||
41 | |||||
Ryan Sturm | f0ad429 | 2019-05-10 00:51:10 | [diff] [blame] | 42 | class BatteryMetrics; |
Scott Violet | 875789e | 2018-02-02 07:46:48 | [diff] [blame] | 43 | class ChromeMetricsServicesManagerClient; |
dgozman | 54cc54e | 2016-02-23 03:47:30 | [diff] [blame] | 44 | class DevToolsAutoOpener; |
[email protected] | 4475d23 | 2011-07-27 15:29:20 | [diff] [blame] | 45 | class RemoteDebuggingServer; |
[email protected] | b1de2c7 | 2013-02-06 02:45:47 | [diff] [blame] | 46 | class PrefRegistrySimple; |
Lukasz Anforowicz | 60d1253d | 2019-05-08 16:31:37 | [diff] [blame] | 47 | class SecureOriginPrefsObserver; |
Lukasz Anforowicz | 65c6116 | 2019-03-27 20:33:58 | [diff] [blame] | 48 | class SiteIsolationPrefsObserver; |
Toni Barzic | b598380e | 2018-11-26 19:14:10 | [diff] [blame] | 49 | class SystemNotificationHelper; |
Xi Han | 85079c2 | 2019-04-18 21:43:05 | [diff] [blame] | 50 | class StartupData; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 51 | |
bauerb | ecab4f5 | 2017-03-13 20:16:41 | [diff] [blame] | 52 | #if BUILDFLAG(ENABLE_PLUGINS) |
[email protected] | 2366a3a | 2012-10-02 20:41:14 | [diff] [blame] | 53 | class PluginsResourceService; |
54 | #endif | ||||
55 | |||||
[email protected] | 0de615a | 2012-11-08 04:40:59 | [diff] [blame] | 56 | namespace base { |
[email protected] | 2f3b1cc | 2014-03-17 23:07:15 | [diff] [blame] | 57 | class CommandLine; |
[email protected] | 0de615a | 2012-11-08 04:40:59 | [diff] [blame] | 58 | } |
59 | |||||
[email protected] | aa3dd49 | 2013-11-05 17:09:09 | [diff] [blame] | 60 | namespace extensions { |
61 | class ExtensionsBrowserClient; | ||||
62 | } | ||||
63 | |||||
[email protected] | c027d6d | 2014-06-05 15:25:40 | [diff] [blame] | 64 | namespace gcm { |
65 | class GCMDriver; | ||||
66 | } | ||||
67 | |||||
[email protected] | 5b86996 | 2011-09-20 19:49:33 | [diff] [blame] | 68 | namespace policy { |
Scott Violet | fdd6f35 | 2018-01-12 19:12:29 | [diff] [blame] | 69 | class ChromeBrowserPolicyConnector; |
[email protected] | a4179c2a | 2012-02-09 18:14:21 | [diff] [blame] | 70 | class PolicyService; |
Scott Violet | fdd6f35 | 2018-01-12 19:12:29 | [diff] [blame] | 71 | } // namespace policy |
[email protected] | fcf5357 | 2011-06-29 15:44:37 | [diff] [blame] | 72 | |
Elad Alon | 39b1f6cc | 2018-08-30 09:52:21 | [diff] [blame] | 73 | namespace webrtc_event_logging { |
74 | class WebRtcEventLogManager; | ||||
75 | } // namespace webrtc_event_logging | ||||
76 | |||||
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 77 | // Real implementation of BrowserProcess that creates and returns the services. |
[email protected] | 6618d1d | 2010-12-15 21:18:47 | [diff] [blame] | 78 | class BrowserProcessImpl : public BrowserProcess, |
dgn | fe075c8 | 2016-03-18 11:25:35 | [diff] [blame] | 79 | public KeepAliveStateObserver { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 80 | public: |
Xi Han | 85079c2 | 2019-04-18 21:43:05 | [diff] [blame] | 81 | // |startup_data| should not be null. The BrowserProcessImpl |
Xi Han | 07bad289 | 2018-10-04 15:13:58 | [diff] [blame] | 82 | // will take the PrefService owned by the creator as the Local State instead |
83 | // of loading the JSON file from disk. | ||||
Xi Han | 85079c2 | 2019-04-18 21:43:05 | [diff] [blame] | 84 | explicit BrowserProcessImpl(StartupData* startup_data); |
Daniel Cheng | a542fca | 2014-10-21 09:51:29 | [diff] [blame] | 85 | ~BrowserProcessImpl() override; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 86 | |
Scott Violet | 875789e | 2018-02-02 07:46:48 | [diff] [blame] | 87 | // Called to complete initialization. |
88 | void Init(); | ||||
89 | |||||
Wez | 25fd35f | 2018-05-25 22:57:41 | [diff] [blame] | 90 | #if !defined(OS_ANDROID) |
Greg Thompson | 822ab51a | 2018-09-18 06:45:29 | [diff] [blame] | 91 | // 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 Gorski | 209a347 | 2018-08-27 23:03:41 | [diff] [blame] | 96 | void SetQuitClosure(base::OnceClosure quit_closure); |
Wez | 25fd35f | 2018-05-25 22:57:41 | [diff] [blame] | 97 | #endif |
98 | |||||
Avi Drissman | 2e458df | 2020-07-29 16:24:31 | [diff] [blame] | 99 | #if defined(OS_MAC) |
Greg Thompson | 822ab51a | 2018-09-18 06:45:29 | [diff] [blame] | 100 | // 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(); | ||||
Wez | 25fd35f | 2018-05-25 22:57:41 | [diff] [blame] | 105 | #endif |
106 | |||||
[email protected] | 9990736 | 2012-01-11 05:41:40 | [diff] [blame] | 107 | // Called before the browser threads are created. |
Bernhard Bauer | 5533f991 | 2017-11-06 17:56:02 | [diff] [blame] | 108 | void PreCreateThreads(const base::CommandLine& command_line); |
[email protected] | 2e5b60a2 | 2011-11-28 15:56:41 | [diff] [blame] | 109 | |
[email protected] | d2caaa2 | 2011-12-12 03:04:15 | [diff] [blame] | 110 | // 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] | 2e5b60a2 | 2011-11-28 15:56:41 | [diff] [blame] | 115 | // 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. | ||||
thestig | d75ce553 | 2015-10-05 22:08:34 | [diff] [blame] | 119 | #if !defined(OS_ANDROID) |
[email protected] | 2e5b60a2 | 2011-11-28 15:56:41 | [diff] [blame] | 120 | void StartTearDown(); |
[email protected] | 9990736 | 2012-01-11 05:41:40 | [diff] [blame] | 121 | void PostDestroyThreads(); |
thestig | d75ce553 | 2015-10-05 22:08:34 | [diff] [blame] | 122 | #endif |
[email protected] | 2e5b60a2 | 2011-11-28 15:56:41 | [ |