[email protected] | 60b122d | 2012-01-09 23:00:07 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
5 | #ifndef CONTENT_BROWSER_BROWSER_MAIN_LOOP_H_ | ||||
6 | #define CONTENT_BROWSER_BROWSER_MAIN_LOOP_H_ | ||||
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 7 | |
dcheng | 5971627 | 2016-04-09 05:19:08 | [diff] [blame] | 8 | #include <memory> |
9 | |||||
[email protected] | cec9563 | 2014-07-02 18:01:50 | [diff] [blame] | 10 | #include "base/files/file_path.h" |
Francois Doray | 6d3c64969 | 2017-06-16 19:20:25 | [diff] [blame] | 11 | #include "base/gtest_prod_util.h" |
avi | b734894 | 2015-12-25 20:57:10 | [diff] [blame] | 12 | #include "base/macros.h" |
[email protected] | 57624ab | 2013-08-01 16:01:51 | [diff] [blame] | 13 | #include "base/memory/ref_counted.h" |
[email protected] | cec9563 | 2014-07-02 18:01:50 | [diff] [blame] | 14 | #include "base/timer/timer.h" |
avi | b734894 | 2015-12-25 20:57:10 | [diff] [blame] | 15 | #include "build/build_config.h" |
[email protected] | 2e5b60a2 | 2011-11-28 15:56:41 | [diff] [blame] | 16 | #include "content/browser/browser_process_sub_thread.h" |
[email protected] | 57624ab | 2013-08-01 16:01:51 | [diff] [blame] | 17 | #include "content/public/browser/browser_main_runner.h" |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 18 | |
sadrul | 578205fa | 2016-04-11 22:43:56 | [diff] [blame] | 19 | #if defined(USE_AURA) |
20 | namespace aura { | ||||
21 | class Env; | ||||
22 | } | ||||
23 | #endif | ||||
24 | |||||
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 25 | namespace base { |
[email protected] | 2f3b1cc | 2014-03-17 23:07:15 | [diff] [blame] | 26 | class CommandLine; |
[email protected] | 1eb1461 | 2013-11-21 01:04:58 | [diff] [blame] | 27 | class FilePath; |
[email protected] | 89bf27e | 2013-06-27 18:04:56 | [diff] [blame] | 28 | class HighResolutionTimerManager; |
gab | 3ee0e44 | 2016-12-16 17:43:11 | [diff] [blame] | 29 | class MemoryPressureMonitor; |
[email protected] | 5e9e96a | 2013-03-31 02:29:20 | [diff] [blame] | 30 | class MessageLoop; |
[email protected] | ed3bf8a6 | 2014-04-05 18:55:57 | [diff] [blame] | 31 | class PowerMonitor; |
kylechar | ee7cefd | 2017-07-13 16:05:03 | [diff] [blame] | 32 | class SingleThreadTaskRunner; |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 33 | class SystemMonitor; |
primiano | 1596043 | 2015-02-05 14:20:26 | [diff] [blame] | 34 | namespace trace_event { |
[email protected] | e5a631a | 2013-09-18 07:33:27 | [diff] [blame] | 35 | class TraceEventSystemStatsMonitor; |
primiano | 1596043 | 2015-02-05 14:20:26 | [diff] [blame] | 36 | } // namespace trace_event |
[email protected] | 111494e | 2013-07-24 18:38:29 | [diff] [blame] | 37 | } // namespace base |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 38 | |
penghuang | cf82397 | 2016-12-21 16:01:13 | [diff] [blame] | 39 | namespace discardable_memory { |
40 | class DiscardableSharedMemoryManager; | ||||
41 | } | ||||
42 | |||||
sadrul | 059bc53 | 2017-07-05 21:22:16 | [diff] [blame] | 43 | namespace gpu { |
44 | class GpuChannelEstablishFactory; | ||||
45 | } | ||||
46 | |||||
[email protected] | 67dfea90 | 2012-04-03 01:49:09 | [diff] [blame] | 47 | namespace media { |
alokp | 2cbd4fc | 2017-05-13 04:13:24 | [diff] [blame] | 48 | class AudioManager; |
olka | ef762c9 | 2017-02-06 16:45:16 | [diff] [blame] | 49 | class AudioSystem; |
mcasas | 96388e9 | 2016-03-02 02:18:07 | [diff] [blame] | 50 | #if defined(OS_WIN) |
51 | class SystemMessageWindowWin; | ||||
52 | #elif defined(OS_LINUX) && defined(USE_UDEV) | ||||
mcasas | 9d206368 | 2016-02-11 22:12:39 | [diff] [blame] | 53 | class DeviceMonitorLinux; |
54 | #endif | ||||
[email protected] | 61f697f | 2013-08-15 22:02:40 | [diff] [blame] | 55 | class UserInputMonitor; |
mcasas | 9d03ac2e | 2016-02-24 17:10:02 | [diff] [blame] | 56 | #if defined(OS_MACOSX) |
57 | class DeviceMonitorMac; | ||||
58 | #endif | ||||
toyoshim | 59e31971 | 2016-10-13 06:43:29 | [diff] [blame] | 59 | } // namespace media |
60 | |||||
primiano | aca468f8 | 2017-05-22 13:30:32 | [diff] [blame] | 61 | namespace memory_instrumentation { |
62 | class CoordinatorImpl; | ||||
63 | } // memory_instrumentation | ||||
64 | |||||
toyoshim | 78b9d63 | 2015-05-08 04:58:31 | [diff] [blame] | 65 | namespace midi { |
toyoshim | 967340a | 2016-12-15 06:18:29 | [diff] [blame] | 66 | class MidiService; |
toyoshim | 78b9d63 | 2015-05-08 04:58:31 | [diff] [blame] | 67 | } // namespace midi |
[email protected] | 67dfea90 | 2012-04-03 01:49:09 | [diff] [blame] | 68 | |
amistry | cafcdff | 2016-06-17 03:33:48 | [diff] [blame] | 69 | namespace mojo { |
70 | namespace edk { | ||||
71 | class ScopedIPCSupport; | ||||
72 | } // namespace edk | ||||
73 | } // namespace mojo | ||||
74 | |||||
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 75 | namespace net { |
76 | class NetworkChangeNotifier; | ||||
[email protected] | 111494e | 2013-07-24 18:38:29 | [diff] [blame] | 77 | } // namespace net |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 78 | |
dongseong.hwang | 16f5a8a4 | 2015-08-06 11:00:30 | [diff] [blame] | 79 | #if defined(USE_OZONE) |
julien.isorce | f09c313 | 2017-03-24 21:06:14 | [diff] [blame] | 80 | namespace gfx { |
dongseong.hwang | 16f5a8a4 | 2015-08-06 11:00:30 | [diff] [blame] | 81 | class ClientNativePixmapFactory; |
julien.isorce | f09c313 | 2017-03-24 21:06:14 | [diff] [blame] | 82 | } // namespace gfx |
dongseong.hwang | 16f5a8a4 | 2015-08-06 11:00:30 | [diff] [blame] | 83 | #endif |
84 | |||||
fsamuel | ea696982 | 2017-06-12 21:14:32 | [diff] [blame] | 85 | namespace viz { |
danakj | 4def4a24 | 2017-06-24 01:18:37 | [diff] [blame] | 86 | class FrameSinkManagerImpl; |
Fady Samuel | dea5e8f | 2017-07-19 21:41:33 | [diff] [blame] | 87 | class HostFrameSinkManager; |
fsamuel | ea696982 | 2017-06-12 21:14:32 | [diff] [blame] | 88 | } |
89 | |||||
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 90 | namespace content { |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 91 | class BrowserMainParts; |
[email protected] | 2208a74d | 2012-10-29 17:09:44 | [diff] [blame] | 92 | class BrowserOnlineStateObserver; |
[email protected] | c38831a1 | 2011-10-28 12:44:49 | [diff] [blame] | 93 | class BrowserThreadImpl; |
scottmg | 5cbd1cf | 2016-06-29 02:34:52 | [diff] [blame] | 94 | class LoaderDelegateImpl; |
[email protected] | 1d232b9 | 2012-10-29 17:39:07 | [diff] [blame] | 95 | class MediaStreamManager; |
[email protected] | ea11472 | 2012-03-12 01:11:25 | [diff] [blame] | 96 | class ResourceDispatcherHostImpl; |
ananta | 73296c57 | 2016-08-15 21:58:25 | [diff] [blame] | 97 | class SaveFileManager; |
ben | ff46163 | 2016-10-06 14:27:33 | [diff] [blame] | 98 | class ServiceManagerContext; |
[email protected] | fcb8e021 | 2012-10-29 11:57:18 | [diff] [blame] | 99 | class SpeechRecognitionManagerImpl; |
[email protected] | 232e09d | 2013-08-27 15:29:56 | [diff] [blame] | 100 | class StartupTaskRunner; |
Scott Haseley | 7a02fce | 2017-08-01 21:55:01 | [diff] [blame] | 101 | class SwapMetricsDriver; |
[email protected] | 97646c9 | 2012-07-31 20:30:08 | [diff] [blame] | 102 | struct MainFunctionParams; |
103 | |||||
jonross | 3698029 | 2014-10-08 15:55:10 | [diff] [blame] | 104 | #if defined(OS_ANDROID) |
105 | class ScreenOrientationDelegate; | ||||
[email protected] | 97646c9 | 2012-07-31 20:30:08 | [diff] [blame] | 106 | #endif |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 107 | |
thomasanderson | 62ba78ff | 2016-10-01 02:03:42 | [diff] [blame] | 108 | #if defined(USE_X11) && !defined(OS_CHROMEOS) |
109 | namespace internal { | ||||
110 | class GpuDataManagerVisualProxy; | ||||
111 | } | ||||
112 | #endif | ||||
113 | |||||
[email protected] | 53ab480 | 2012-04-12 22:14:35 | [diff] [blame] | 114 | // Implements the main browser loop stages called from BrowserMainRunner. |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 115 | // See comments in browser_main_parts.h for additional info. |
[email protected] | 89acda8 | 2013-06-25 20:52:50 | [diff] [blame] | 116 | class CONTENT_EXPORT BrowserMainLoop { |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 117 | public: |
[email protected] | aa44546 | 2013-06-21 17:12:36 | [diff] [blame] | 118 | // Returns the current instance. This is used to get access to the getters |
119 | // that return objects which are owned by this class. | ||||
120 | static BrowserMainLoop* GetInstance(); | ||||
121 | |||||
[email protected] | 4648832 | 2012-10-30 03:22:20 | [diff] [blame] | 122 | explicit BrowserMainLoop(const MainFunctionParams& parameters); |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 123 | virtual ~BrowserMainLoop(); |
124 | |||||
125 | void Init(); | ||||
126 | |||||
127 | void EarlyInitialization(); | ||||
thestig | 7e202d1a | 2015-05-27 21:54:55 | [diff] [blame] | 128 | |
[email protected] | d957b10 | 2014-04-25 20:17:19 | [diff] [blame] | 129 | // Initializes the toolkit. Returns whether the toolkit initialization was |
130 | // successful or not. | ||||
131 | bool InitializeToolkit(); | ||||
thestig | 7e202d1a | 2015-05-27 21:54:55 | [diff] [blame] | 132 | |
133 | void PreMainMessageLoopStart(); | ||||
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 134 | void MainMessageLoopStart(); |
thestig | 7e202d1a | 2015-05-27 21:54:55 | [diff] [blame] | 135 | void PostMainMessageLoopStart(); |
bcwhite | da097d3 | 2017-01-12 23:55:03 | [diff] [blame] | 136 | void PreShutdown(); |
[email protected] | f573ed6b | 2012-02-10 15:58:52 | [diff] [blame] | 137 | |
[email protected] | 232e09d | 2013-08-27 15:29:56 | [diff] [blame] | 138 | // Create and start running the tasks we need to complete startup. Note that |
139 | // this can be called more than once (currently only on Android) if we get a | ||||
140 | // request for synchronous startup while the tasks created by asynchronous | ||||
141 | // startup are still running. | ||||
[email protected] | 57624ab | 2013-08-01 16:01:51 | [diff] [blame] | 142 | void CreateStartupTasks(); |
[email protected] | f573ed6b | 2012-02-10 15:58:52 | [diff] [blame] | 143 | |
144 | // Perform the default message loop run logic. | ||||
145 | void RunMainMessageLoopParts(); | ||||
146 | |||||
147 | // Performs the shutdown sequence, starting with PostMainMessageLoopRun | ||||
148 | // through stopping threads to PostDestroyThreads. | ||||
149 | void ShutdownThreadsAndCleanUp(); | ||||
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 150 | |
151 | int GetResultCode() const { return result_code_; } | ||||
152 | |||||
[email protected] | aa44546 | 2013-06-21 17:12:36 | [diff] [blame] | 153 | media::AudioManager* audio_manager() const { return audio_manager_.get(); } |
olka | ef762c9 | 2017-02-06 16:45:16 | [diff] [blame] | 154 | media::AudioSystem* audio_system() const { return audio_system_.get(); } |
[email protected] | aa44546 | 2013-06-21 17:12:36 | [diff] [blame] | 155 | MediaStreamManager* media_stream_manager() const { |
156 | return media_stream_manager_.get(); | ||||
157 | } | ||||
[email protected] | 61f697f | 2013-08-15 22:02:40 | [diff] [blame] | 158 | media::UserInputMonitor* user_input_monitor() const { |
159 | return user_input_monitor_.get(); | ||||
160 | } | ||||
penghuang | cf82397 | 2016-12-21 16:01:13 | [diff] [blame] | 161 | discardable_memory::DiscardableSharedMemoryManager* |
162 | discardable_shared_memory_manager() const { | ||||
163 | return discardable_shared_memory_manager_.get(); | ||||
164 | } | ||||
toyoshim | 967340a | 2016-12-15 06:18:29 | [diff] [blame] | 165 | midi::MidiService* midi_service() const { return midi_service_.get(); } |
[email protected] | 52e456b9 | 2012-02-23 17:13:18 | [diff] [blame] | 166 | |
zhenw | c074d28 | 2015-08-31 17:28:17 | [diff] [blame] | 167 | bool is_tracing_startup_for_duration() const { |
168 | return is_tracing_startup_for_duration_; | ||||
169 | } | ||||
[email protected] | 1eb1461 | 2013-11-21 01:04:58 | [diff] [blame] | 170 | |
[email protected] | cec9563 | 2014-07-02 18:01:50 | [diff] [blame] | 171 | const base::FilePath& startup_trace_file() const { |
172 | return startup_trace_file_; | ||||
173 | } | ||||
174 | |||||
kylechar | ee7cefd | 2017-07-13 16:05:03 | [diff] [blame] | 175 | // Returns the task runner for tasks that that are critical to producing a new |
176 | // CompositorFrame on resize. On Mac this will be the task runner provided by | ||||
177 | // WindowResizeHelperMac, on other platforms it will just be the thread task | ||||
178 | // runner. | ||||
179 | scoped_refptr<base::SingleThreadTaskRunner> GetResizeTaskRunner(); | ||||
180 | |||||
sadrul | 059bc53 | 2017-07-05 21:22:16 | [diff] [blame] | 181 | gpu::GpuChannelEstablishFactory* gpu_channel_establish_factory() const; |
182 | |||||
Bo Liu | 79c92c3b | 2017-06-28 18:52:25 | [diff] [blame] | 183 | #if defined(OS_ANDROID) |
184 | void SynchronouslyFlushStartupTasks(); | ||||
185 | #endif // OS_ANDROID | ||||
186 | |||||
fsamuel | ea696982 | 2017-06-12 21:14:32 | [diff] [blame] | 187 | #if !defined(OS_ANDROID) |
danakj | 4def4a24 | 2017-06-24 01:18:37 | [diff] [blame] | 188 | // TODO(fsamuel): We should find an object to own HostFrameSinkManager on all |
fsamuel | ea696982 | 2017-06-12 21:14:32 | [diff] [blame] | 189 | // platforms including Android. See http://crbug.com/732507. |
danakj | 4def4a24 | 2017-06-24 01:18:37 | [diff] [blame] | 190 | viz::HostFrameSinkManager* host_frame_sink_manager() const { |
191 | return host_frame_sink_manager_.get(); | ||||
fsamuel | ea696982 | 2017-06-12 21:14:32 | [diff] [blame] | 192 | } |
danakj | aee6717 | 2017-06-13 16:37:02 | [diff] [blame] | 193 | |
194 | // TODO(crbug.com/657959): This will be removed once there are no users, as | ||||
195 | // SurfaceManager is being moved out of process. | ||||
Fady Samuel | dea5e8f | 2017-07-19 21:41:33 | [diff] [blame] | 196 | viz::FrameSinkManagerImpl* GetFrameSinkManager() const; |
fsamuel | ea696982 | 2017-06-12 21:14:32 | [diff] [blame] | 197 | #endif |
198 | |||||
[email protected] | cec9563 | 2014-07-02 18:01:50 | [diff] [blame] | 199 | void StopStartupTracingTimer(); |
200 | |||||
[email protected] | 08f2c54c | 2014-03-12 09:27:25 | [diff] [blame] | 201 | #if defined(OS_MACOSX) && !defined(OS_IOS) |
mcasas | 9d03ac2e | 2016-02-24 17:10:02 | [diff] [blame] | 202 | media::DeviceMonitorMac* device_monitor_mac() const { |
[email protected] | 08f2c54c | 2014-03-12 09:27:25 | [diff] [blame] | 203 | return device_monitor_mac_.get(); |
204 | } | ||||
205 | #endif | ||||
206 | |||||
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 207 | private: |
Francois Doray | 6d3c64969 | 2017-06-16 19:20:25 | [diff] [blame] | 208 | FRIEND_TEST_ALL_PREFIXES(BrowserMainLoopTest, CreateThreadsInSingleProcess); |
209 | |||||
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 210 | void InitializeMainThread(); |
211 | |||||
[email protected] | 57624ab | 2013-08-01 16:01:51 | [diff] [blame] | 212 | // Called just before creating the threads |
213 | int PreCreateThreads(); | ||||
214 | |||||
215 | // Create all secondary threads. | ||||
216 | int CreateThreads(); | ||||
217 | |||||
[email protected] | 9990736 | 2012-01-11 05:41:40 | [diff] [blame] | 218 | // Called right after the browser threads have been started. |
[email protected] | 57624ab | 2013-08-01 16:01:51 | [diff] [blame] | 219 | int BrowserThreadsStarted(); |
220 | |||||
221 | int PreMainMessageLoopRun(); | ||||
[email protected] | 9990736 | 2012-01-11 05:41:40 | [diff] [blame] | 222 | |
[email protected] | f573ed6b | 2012-02-10 15:58:52 | [diff] [blame] | 223 | void MainMessageLoopRun(); |
224 | |||||
sadrul | a15cfccb | 2016-08-08 18:04:07 | [diff] [blame] | 225 | void InitializeMojo(); |
[email protected] | cec9563 | 2014-07-02 18:01:50 | [diff] [blame] | 226 | base::FilePath GetStartupTraceFileName( |
227 | const base::CommandLine& command_line) const; | ||||
zhenw | c074d28 | 2015-08-31 17:28:17 | [diff] [blame] | 228 | void InitStartupTracingForDuration(const base::CommandLine& command_line); |
[email protected] | cec9563 | 2014-07-02 18:01:50 | [diff] [blame] | 229 | void EndStartupTracing(); |
[email protected] | 1eb1461 | 2013-11-21 01:04:58 | [diff] [blame] | 230 | |
alokp | 1f49967 | 2016-04-19 15:26:28 | [diff] [blame] | 231 | void CreateAudioManager(); |
alokp | 2cbd4fc | 2017-05-13 04:13:24 | [diff] [blame] | 232 | |
boliu | 7439d04 | 2015-01-27 22:51:11 | [diff] [blame] | 233 | bool UsingInProcessGpu() const; |
thestig | 7e202d1a | 2015-05-27 21:54:55 | [diff] [blame] | 234 | |
bashi | 58dd2fa | 2016-10-17 00:01:07 | [diff] [blame] | 235 | void InitializeMemoryManagementComponent(); |
236 | |||||
thestig | 7e202d1a | 2015-05-27 21:54:55 | [diff] [blame] | 237 | // Quick reference for initialization order: |
238 | // Constructor | ||||
239 | // Init() | ||||
240 | // EarlyInitialization() | ||||
241 | // InitializeToolkit() | ||||
242 | // PreMainMessageLoopStart() | ||||
243 | // MainMessageLoopStart() | ||||
244 | // InitializeMainThread() | ||||
245 | // PostMainMessageLoopStart() | ||||
zhenw | c074d28 | 2015-08-31 17:28:17 | [diff] [blame] | 246 | // InitStartupTracingForDuration() |
thestig | 7e202d1a | 2015-05-27 21:54:55 | [diff] [blame] | 247 | // CreateStartupTasks() |
248 | // PreCreateThreads() | ||||
249 | // CreateThreads() | ||||
250 | // BrowserThreadsStarted() | ||||
mfomitchev | 202f333b | 2016-05-26 01:15:45 | [diff] [blame] | 251 | // PreMainMessageLoopRun() |
boliu | 7439d04 | 2015-01-27 22:51:11 | [diff] [blame] | 252 | |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 253 | // Members initialized on construction --------------------------------------- |
[email protected] | 4648832 | 2012-10-30 03:22:20 | [diff] [blame] | 254 | const MainFunctionParams& parameters_; |
[email protected] | 2f3b1cc | 2014-03-17 23:07:15 | [diff] [blame] | 255 | const base::CommandLine& parsed_command_line_; |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 256 | int result_code_; |
thestig | 7e202d1a | 2015-05-27 21:54:55 | [diff] [blame] | 257 | bool created_threads_; // True if the non-UI threads were created. |
zhenw | c074d28 | 2015-08-31 17:28:17 | [diff] [blame] | 258 | bool is_tracing_startup_for_duration_; |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 259 | |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 260 | // Members initialized in |MainMessageLoopStart()| --------------------------- |
dcheng | 5971627 | 2016-04-09 05:19:08 | [diff] [blame] | 261 | std::unique_ptr<base::MessageLoop> main_message_loop_; |
thestig | 7e202d1a | 2015-05-27 21:54:55 | [diff] [blame] | 262 | |
263 | // Members initialized in |PostMainMessageLoopStart()| ----------------------- | ||||
dcheng | 5971627 | 2016-04-09 05:19:08 | [diff] [blame] | 264 | std::unique_ptr<base::SystemMonitor> system_monitor_; |
265 | std::unique_ptr<base::PowerMonitor> power_monitor_; | ||||
266 | std::unique_ptr<base::HighResolutionTimerManager> hi_res_timer_manager_; | ||||
267 | std::unique_ptr<net::NetworkChangeNotifier> network_change_notifier_; | ||||
thestig | 7e202d1a | 2015-05-27 21:54:55 | [diff] [blame] | 268 | |
[email protected] | bff327f | 2012-03-11 22:17:19 | [diff] [blame] | 269 | // Per-process listener for online state changes. |
dcheng | 5971627 | 2016-04-09 05:19:08 | [diff] [blame] | 270 | std::unique_ptr<BrowserOnlineStateObserver> online_state_observer_; |
thestig | 7e202d1a | 2015-05-27 21:54:55 | [diff] [blame] | 271 | |
dcheng | 5971627 | 2016-04-09 05:19:08 | [diff] [blame] | 272 | std::unique_ptr<base::trace_event::TraceEventSystemStatsMonitor> |
thestig | 7e202d1a | 2015-05-27 21:54:55 | [diff] [blame] | 273 | system_stats_monitor_; |
274 | |||||
sadrul | 578205fa | 2016-04-11 22:43:56 | [diff] [blame] | 275 | #if defined(USE_AURA) |
276 | std::unique_ptr<aura::Env> env_; | ||||
277 | #endif | ||||
278 | |||||
jonross | 3698029 | 2014-10-08 15:55:10 | [diff] [blame] | 279 | #if defined(OS_ANDROID) |
280 | // Android implementation of ScreenOrientationDelegate | ||||
dcheng | 5971627 | 2016-04-09 05:19:08 | [diff] [blame] | 281 | std::unique_ptr<ScreenOrientationDelegate> screen_orientation_delegate_; |
jonross | 3698029 | 2014-10-08 15:55:10 | [diff] [blame] | 282 | #endif |
chrisha | dc837f5 | 2015-05-15 03:09:06 | [diff] [blame] | 283 | |
zhenw | c074d28 | 2015-08-31 17:28:17 | [diff] [blame] | 284 | // Members initialized in |InitStartupTracingForDuration()| ------------------ |
thestig | 7e202d1a | 2015-05-27 21:54:55 | [diff] [blame] | 285 | base::FilePath startup_trace_file_; |
[email protected] | 50462bf0 | 2011-11-21 19:13:31 | [diff] [blame] | 286 | |
thestig | 7e202d1a | 2015-05-27 21:54:55 | [diff] [blame] | 287 | // This timer initiates trace file saving. |
danakj | 8c3eb80 | 2015-09-24 07:53:00 | [diff] [blame] | 288 | base::OneShotTimer startup_trace_timer_; |
thestig | 7e202d1a | 2015-05-27 21:54:55 | [diff] [blame] | 289 | |
290 | // Members initialized in |Init()| ------------------------------------------- | ||||
291 | // Destroy |parts_| before |main_message_loop_| (required) and before other | ||||
292 | // classes constructed in content (but after |main_thread_|). | ||||
dcheng | 5971627 | 2016-04-09 05:19:08 | [diff] [blame] | 293 | std::unique_ptr<BrowserMainParts> parts_; |
[email protected] | 50462bf0 | 2011-11-21 19:13:31 | [diff] [blame] | 294 | |
295 | // Members initialized in |InitializeMainThread()| --------------------------- | ||||
thestig | 7e202d1a | 2015-05-27 21:54:55 | [diff] [blame] | 296 | // This must get destroyed before other threads that are created in |parts_|. |
dcheng | 5971627 | 2016-04-09 05:19:08 | [diff] [blame] | 297 | std::unique_ptr<BrowserThreadImpl> main_thread_; |
[email protected] | 60b122d | 2012-01-09 23:00:07 | [diff] [blame] | 298 | |
thestig | 7e202d1a | 2015-05-27 21:54:55 | [diff] [blame] | 299 | // Members initialized in |CreateStartupTasks()| ----------------------------- |
dcheng | 5971627 | 2016-04-09 05:19:08 | [diff] [blame] | 300 | std::unique_ptr<StartupTaskRunner> startup_task_runner_; |
[email protected] | 9990736 | 2012-01-11 05:41:40 | [diff] [blame] | 301 | |
thestig | 7e202d1a | 2015-05-27 21:54:55 | [diff] [blame] | 302 | // Members initialized in |PreCreateThreads()| ------------------------------- |
303 | // Torn down in ShutdownThreadsAndCleanUp. | ||||
dcheng | 5971627 | 2016-04-09 05:19:08 | [diff] [blame] | 304 | std::unique_ptr<base::MemoryPressureMonitor> memory_pressure_monitor_; |
Scott Haseley | 7a02fce | 2017-08-01 21:55:01 | [diff] [blame] | 305 | std::unique_ptr<SwapMetricsDriver> swap_metrics_driver_; |
thomasanderson | 62ba78ff | 2016-10-01 02:03:42 | [diff] [blame] | 306 | #if defined(USE_X11) && !(OS_CHROMEOS) |
307 | std::unique_ptr<internal::GpuDataManagerVisualProxy> | ||||
308 | gpu_data_manager_visual_proxy_; | ||||
309 | #endif | ||||
thestig | 7e202d1a | 2015-05-27 21:54:55 | [diff] [blame] | 310 | |
311 | // Members initialized in |CreateThreads()| ---------------------------------- | ||||
Gabriel Charette | c0cdb67 | 2017-06-13 17:24:42 | [diff] [blame] | 312 | // Only the IO thread is a real thread by default, other BrowserThreads are |
313 | // redirected to TaskScheduler under the hood. | ||||
dcheng | 5971627 | 2016-04-09 05:19:08 | [diff] [blame] | 314 | std::unique_ptr<BrowserProcessSubThread> io_thread_; |
Gabriel Charette | c0cdb67 | 2017-06-13 17:24:42 | [diff] [blame] | 315 | #if defined(OS_ANDROID) |
316 | // On Android, the PROCESS_LAUNCHER thread is handled by Java, | ||||
317 | // |process_launcher_thread_| is merely a proxy to the real message loop. | ||||
318 | std::unique_ptr<BrowserProcessSubThread> process_launcher_thread_; | ||||
319 | #elif defined(OS_WIN) | ||||
320 | // TaskScheduler doesn't support async I/O on Windows as CACHE thread is | ||||
321 | // the only user and this use case is going away in | ||||
322 | // https://codereview.chromium.org/2216583003/. | ||||
323 | // TODO(gavinp): Remove this (and thus enable redirection of the CACHE thread | ||||
324 | // on Windows) once that CL lands. | ||||
325 | std::unique_ptr<BrowserProcessSubThread> cache_thread_; | ||||
326 | #endif | ||||
thestig | 7e202d1a | 2015-05-27 21:54:55 | [diff] [blame] | 327 | |
328 | // Members initialized in |BrowserThreadsStarted()| -------------------------- | ||||
ben | ff46163 | 2016-10-06 14:27:33 | [diff] [blame] | 329 | std::unique_ptr<ServiceManagerContext> service_manager_context_; |
amistry | cafcdff | 2016-06-17 03:33:48 | [diff] [blame] | 330 | std::unique_ptr<mojo::edk::ScopedIPCSupport> mojo_ipc_support_; |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 331 | |
thestig | 7e202d1a | 2015-05-27 21:54:55 | [diff] [blame] | 332 | // |user_input_monitor_| has to outlive |audio_manager_|, so declared first. |
dcheng | 5971627 | 2016-04-09 05:19:08 | [diff] [blame] | 333 | std::unique_ptr<media::UserInputMonitor> user_input_monitor_; |
alokp | 2cbd4fc | 2017-05-13 04:13:24 | [diff] [blame] | 334 | std::unique_ptr<media::AudioManager> audio_manager_; |
olka | ef762c9 | 2017-02-06 16:45:16 | [diff] [blame] | 335 | // Calls to |audio_system_| must not be posted to the audio thread if it |
olka | 3dfb4cf | 2017-04-11 15:43:28 | [diff] [blame] | 336 | // differs from the UI one. See http://crbug.com/705455. |
olka | ef762c9 | 2017-02-06 16:45:16 | [diff] [blame] | 337 | std::unique_ptr<media::AudioSystem> audio_system_; |
[email protected] | cec9563 | 2014-07-02 18:01:50 | [diff] [blame] | 338 | |
toyoshim | 967340a | 2016-12-15 06:18:29 | [diff] [blame] | 339 | std::unique_ptr<midi::MidiService> midi_service_; |
thestig | 7e202d1a | 2015-05-27 21:54:55 | [diff] [blame] | 340 | |
Kevin Marshall | f788237 | 2017-06-06 00:14:34 | [diff] [blame] | 341 | // Must be deleted on the IO thread. |
342 | std::unique_ptr<SpeechRecognitionManagerImpl> speech_recognition_manager_; | ||||
343 | |||||
mcasas | 96388e9 | 2016-03-02 02:18:07 | [diff] [blame] | 344 | #if defined(OS_WIN) |
dcheng | 5971627 | 2016-04-09 05:19:08 | [diff] [blame] | 345 | std::unique_ptr<media::SystemMessageWindowWin> system_message_window_; |
mcasas | 96388e9 | 2016-03-02 02:18:07 | [diff] [blame] | 346 | #elif defined(OS_LINUX) && defined(USE_UDEV) |
dcheng | 5971627 | 2016-04-09 05:19:08 | [diff] [blame] | 347 | std::unique_ptr<media::DeviceMonitorLinux> device_monitor_linux_; |
thestig | 7e202d1a | 2015-05-27 21:54:55 | [diff] [blame] | 348 | #elif defined(OS_MACOSX) && !defined(OS_IOS) |
dcheng | 5971627 | 2016-04-09 05:19:08 | [diff] [blame] | 349 | std::unique_ptr<media::DeviceMonitorMac> device_monitor_mac_; |
thestig | 7e202d1a | 2015-05-27 21:54:55 | [diff] [blame] | 350 | #endif |
dongseong.hwang | 16f5a8a4 | 2015-08-06 11:00:30 | [diff] [blame] | 351 | #if defined(USE_OZONE) |
julien.isorce | f09c313 | 2017-03-24 21:06:14 | [diff] [blame] | 352 | std::unique_ptr<gfx::ClientNativePixmapFactory> client_native_pixmap_factory_; |
dongseong.hwang | 16f5a8a4 | 2015-08-06 11:00:30 | [diff] [blame] | 353 | #endif |
thestig | 7e202d1a | 2015-05-27 21:54:55 | [diff] [blame] | 354 | |
scottmg | 5cbd1cf | 2016-06-29 02:34:52 | [diff] [blame] | 355 | std::unique_ptr<LoaderDelegateImpl> loader_delegate_; |
dcheng | 5971627 | 2016-04-09 05:19:08 | [diff] [blame] | 356 | std::unique_ptr<ResourceDispatcherHostImpl> resource_dispatcher_host_; |
357 | std::unique_ptr<MediaStreamManager> media_stream_manager_; | ||||
penghuang | cf82397 | 2016-12-21 16:01:13 | [diff] [blame] | 358 | std::unique_ptr<discardable_memory::DiscardableSharedMemoryManager> |
359 | discardable_shared_memory_manager_; | ||||
ananta | 73296c57 | 2016-08-15 21:58:25 | [diff] [blame] | 360 | scoped_refptr<SaveFileManager> save_file_manager_; |
chiniforooshan | 6e4c507 | 2017-03-17 07:56:56 | [diff] [blame] | 361 | std::unique_ptr<memory_instrumentation::CoordinatorImpl> |
362 | memory_instrumentation_coordinator_; | ||||
fsamuel | ea696982 | 2017-06-12 21:14:32 | [diff] [blame] | 363 | #if !defined(OS_ANDROID) |
danakj | 4def4a24 | 2017-06-24 01:18:37 | [diff] [blame] | 364 | std::unique_ptr<viz::HostFrameSinkManager> host_frame_sink_manager_; |
danakj | aee6717 | 2017-06-13 16:37:02 | [diff] [blame] | 365 | // This is owned here so that SurfaceManager will be accessible in process |
366 | // when display is in the same process. Other than using SurfaceManager, | ||||
367 | // access to |in_process_frame_sink_manager_| should happen via | ||||
danakj | 4def4a24 | 2017-06-24 01:18:37 | [diff] [blame] | 368 | // |host_frame_sink_manager_| instead which uses Mojo. See |
danakj | aee6717 | 2017-06-13 16:37:02 | [diff] [blame] | 369 | // http://crbug.com/657959. |
Alex Zhang | 96cb9e71 | 2017-07-07 21:03:47 | [diff] [blame] | 370 | std::unique_ptr<viz::FrameSinkManagerImpl> frame_sink_manager_impl_; |
fsamuel | ea696982 | 2017-06-12 21:14:32 | [diff] [blame] | 371 | #endif |
thestig | 7e202d1a | 2015-05-27 21:54:55 | [diff] [blame] | 372 | |
373 | // DO NOT add members here. Add them to the right categories above. | ||||
[email protected] | 1eb1461 | 2013-11-21 01:04:58 | [diff] [blame] | 374 | |
[email protected] | b48c918 | 2011-10-26 18:03:30 | [diff] [blame] | 375 | DISALLOW_COPY_AND_ASSIGN(BrowserMainLoop); |
376 | }; | ||||
377 | |||||
378 | } // namespace content | ||||
379 | |||||
380 | #endif // CONTENT_BROWSER_BROWSER_MAIN_LOOP_H_ |