[android_webview] Disable AwSettingsTest broken by Blink roll.
[chromium-blink-merge.git] / content / browser / browser_main_loop.h
blob30442a674d919de9d99609777e23f46470368527
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_BROWSER_MAIN_LOOP_H_
6 #define CONTENT_BROWSER_BROWSER_MAIN_LOOP_H_
8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "content/browser/browser_process_sub_thread.h"
12 class CommandLine;
13 class HighResolutionTimerManager;
15 namespace base {
16 class MessageLoop;
17 class PowerMonitor;
18 class SystemMonitor;
21 namespace media {
22 class AudioManager;
25 namespace net {
26 class NetworkChangeNotifier;
29 namespace content {
30 class AudioMirroringManager;
31 class BrowserMainParts;
32 class BrowserOnlineStateObserver;
33 class BrowserShutdownImpl;
34 class BrowserThreadImpl;
35 class MediaStreamManager;
36 class ResourceDispatcherHostImpl;
37 class SpeechRecognitionManagerImpl;
38 class SystemMessageWindowWin;
39 class WebKitThread;
40 struct MainFunctionParams;
42 #if defined(OS_LINUX)
43 class DeviceMonitorLinux;
44 #elif defined(OS_MACOSX)
45 class DeviceMonitorMac;
46 #endif
48 // Implements the main browser loop stages called from BrowserMainRunner.
49 // See comments in browser_main_parts.h for additional info.
50 // All functions are to be called only on the UI thread unless otherwise noted.
51 class BrowserMainLoop {
52 public:
53 class MemoryObserver;
54 explicit BrowserMainLoop(const MainFunctionParams& parameters);
55 virtual ~BrowserMainLoop();
57 void Init();
59 void EarlyInitialization();
60 void InitializeToolkit();
61 void MainMessageLoopStart();
63 // Create all secondary threads.
64 void CreateThreads();
66 // Perform the default message loop run logic.
67 void RunMainMessageLoopParts();
69 // Performs the shutdown sequence, starting with PostMainMessageLoopRun
70 // through stopping threads to PostDestroyThreads.
71 void ShutdownThreadsAndCleanUp();
73 int GetResultCode() const { return result_code_; }
75 // Can be called on any thread.
76 static media::AudioManager* GetAudioManager();
77 static AudioMirroringManager* GetAudioMirroringManager();
78 static MediaStreamManager* GetMediaStreamManager();
80 private:
81 // For ShutdownThreadsAndCleanUp.
82 friend class BrowserShutdownImpl;
84 void InitializeMainThread();
86 // Called right after the browser threads have been started.
87 void BrowserThreadsStarted();
89 void MainMessageLoopRun();
91 // Members initialized on construction ---------------------------------------
92 const MainFunctionParams& parameters_;
93 const CommandLine& parsed_command_line_;
94 int result_code_;
96 // Members initialized in |MainMessageLoopStart()| ---------------------------
97 scoped_ptr<base::MessageLoop> main_message_loop_;
98 scoped_ptr<base::SystemMonitor> system_monitor_;
99 scoped_ptr<base::PowerMonitor> power_monitor_;
100 scoped_ptr<HighResolutionTimerManager> hi_res_timer_manager_;
101 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_;
102 scoped_ptr<media::AudioManager> audio_manager_;
103 scoped_ptr<AudioMirroringManager> audio_mirroring_manager_;
104 scoped_ptr<MediaStreamManager> media_stream_manager_;
105 // Per-process listener for online state changes.
106 scoped_ptr<BrowserOnlineStateObserver> online_state_observer_;
107 #if defined(OS_WIN)
108 scoped_ptr<SystemMessageWindowWin> system_message_window_;
109 #elif defined(OS_LINUX)
110 scoped_ptr<DeviceMonitorLinux> device_monitor_linux_;
111 #elif defined(OS_MACOSX) && !defined(OS_IOS)
112 scoped_ptr<DeviceMonitorMac> device_monitor_mac_;
113 #endif
115 // Destroy parts_ before main_message_loop_ (required) and before other
116 // classes constructed in content (but after main_thread_).
117 scoped_ptr<BrowserMainParts> parts_;
119 // Members initialized in |InitializeMainThread()| ---------------------------
120 // This must get destroyed before other threads that are created in parts_.
121 scoped_ptr<BrowserThreadImpl> main_thread_;
123 // Members initialized in |BrowserThreadsStarted()| --------------------------
124 scoped_ptr<ResourceDispatcherHostImpl> resource_dispatcher_host_;
125 scoped_ptr<SpeechRecognitionManagerImpl> speech_recognition_manager_;
127 // Members initialized in |RunMainMessageLoopParts()| ------------------------
128 scoped_ptr<BrowserProcessSubThread> db_thread_;
129 #if !defined(OS_IOS)
130 scoped_ptr<WebKitThread> webkit_thread_;
131 #endif
132 scoped_ptr<BrowserProcessSubThread> file_user_blocking_thread_;
133 scoped_ptr<BrowserProcessSubThread> file_thread_;
134 scoped_ptr<BrowserProcessSubThread> process_launcher_thread_;
135 scoped_ptr<BrowserProcessSubThread> cache_thread_;
136 scoped_ptr<BrowserProcessSubThread> io_thread_;
137 scoped_ptr<MemoryObserver> memory_observer_;
139 DISALLOW_COPY_AND_ASSIGN(BrowserMainLoop);
142 } // namespace content
144 #endif // CONTENT_BROWSER_BROWSER_MAIN_LOOP_H_