OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_BROWSER_MAIN_LOOP_H_ | 5 #ifndef CONTENT_BROWSER_BROWSER_MAIN_LOOP_H_ |
6 #define CONTENT_BROWSER_BROWSER_MAIN_LOOP_H_ | 6 #define CONTENT_BROWSER_BROWSER_MAIN_LOOP_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "content/browser/browser_process_sub_thread.h" | 11 #include "content/browser/browser_process_sub_thread.h" |
12 | 12 |
| 13 class AudioManager; |
13 class CommandLine; | 14 class CommandLine; |
14 class HighResolutionTimerManager; | 15 class HighResolutionTimerManager; |
15 class MessageLoop; | 16 class MessageLoop; |
16 class ResourceDispatcherHost; | 17 class ResourceDispatcherHost; |
17 class SystemMessageWindowWin; | 18 class SystemMessageWindowWin; |
18 | 19 |
19 namespace base { | 20 namespace base { |
20 class SystemMonitor; | 21 class SystemMonitor; |
21 } | 22 } |
22 | 23 |
23 namespace net { | 24 namespace net { |
24 class NetworkChangeNotifier; | 25 class NetworkChangeNotifier; |
25 } | 26 } |
26 | 27 |
27 namespace content { | 28 namespace content { |
28 | 29 |
29 class BrowserMainParts; | 30 class BrowserMainParts; |
30 class BrowserShutdownImpl; | 31 class BrowserShutdownImpl; |
31 class BrowserThreadImpl; | 32 class BrowserThreadImpl; |
32 struct MainFunctionParams; | 33 struct MainFunctionParams; |
33 class WebKitThread; | 34 class WebKitThread; |
34 | 35 |
35 // Implements the main browser loop stages called from |BrowserMain()|. | 36 // Implements the main browser loop stages called from |BrowserMain()|. |
36 // See comments in browser_main_parts.h for additional info. | 37 // See comments in browser_main_parts.h for additional info. |
| 38 // All functions are to be called only on the UI thread unless otherwise noted. |
37 class BrowserMainLoop { | 39 class BrowserMainLoop { |
38 public: | 40 public: |
39 explicit BrowserMainLoop(const content::MainFunctionParams& parameters); | 41 explicit BrowserMainLoop(const content::MainFunctionParams& parameters); |
40 virtual ~BrowserMainLoop(); | 42 virtual ~BrowserMainLoop(); |
41 | 43 |
42 void Init(); | 44 void Init(); |
43 | 45 |
44 void EarlyInitialization(); | 46 void EarlyInitialization(); |
45 void InitializeToolkit(); | 47 void InitializeToolkit(); |
46 void MainMessageLoopStart(); | 48 void MainMessageLoopStart(); |
47 | 49 |
48 // Create all secondary threads. | 50 // Create all secondary threads. |
49 void CreateThreads(); | 51 void CreateThreads(); |
50 | 52 |
51 // Perform the default message loop run logic. | 53 // Perform the default message loop run logic. |
52 void RunMainMessageLoopParts(); | 54 void RunMainMessageLoopParts(); |
53 | 55 |
54 // Performs the shutdown sequence, starting with PostMainMessageLoopRun | 56 // Performs the shutdown sequence, starting with PostMainMessageLoopRun |
55 // through stopping threads to PostDestroyThreads. | 57 // through stopping threads to PostDestroyThreads. |
56 void ShutdownThreadsAndCleanUp(); | 58 void ShutdownThreadsAndCleanUp(); |
57 | 59 |
58 int GetResultCode() const { return result_code_; } | 60 int GetResultCode() const { return result_code_; } |
59 | 61 |
| 62 // Can be called on any thread. |
| 63 static AudioManager* GetAudioManager(); |
| 64 |
60 private: | 65 private: |
61 // For ShutdownThreadsAndCleanUp. | 66 // For ShutdownThreadsAndCleanUp. |
62 friend class BrowserShutdownImpl; | 67 friend class BrowserShutdownImpl; |
63 | 68 |
64 void InitializeMainThread(); | 69 void InitializeMainThread(); |
65 | 70 |
66 // Called right after the browser threads have been started. | 71 // Called right after the browser threads have been started. |
67 void BrowserThreadsStarted(); | 72 void BrowserThreadsStarted(); |
68 | 73 |
69 void MainMessageLoopRun(); | 74 void MainMessageLoopRun(); |
70 | 75 |
71 // Members initialized on construction --------------------------------------- | 76 // Members initialized on construction --------------------------------------- |
72 const content::MainFunctionParams& parameters_; | 77 const content::MainFunctionParams& parameters_; |
73 const CommandLine& parsed_command_line_; | 78 const CommandLine& parsed_command_line_; |
74 int result_code_; | 79 int result_code_; |
75 | 80 |
76 // Members initialized in |MainMessageLoopStart()| --------------------------- | 81 // Members initialized in |MainMessageLoopStart()| --------------------------- |
77 scoped_ptr<MessageLoop> main_message_loop_; | 82 scoped_ptr<MessageLoop> main_message_loop_; |
78 scoped_ptr<base::SystemMonitor> system_monitor_; | 83 scoped_ptr<base::SystemMonitor> system_monitor_; |
79 scoped_ptr<HighResolutionTimerManager> hi_res_timer_manager_; | 84 scoped_ptr<HighResolutionTimerManager> hi_res_timer_manager_; |
80 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; | 85 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; |
| 86 scoped_ptr<AudioManager> audio_manager_; |
81 #if defined(OS_WIN) | 87 #if defined(OS_WIN) |
82 scoped_ptr<SystemMessageWindowWin> system_message_window_; | 88 scoped_ptr<SystemMessageWindowWin> system_message_window_; |
83 #endif | 89 #endif |
84 | 90 |
85 // Destroy parts_ before main_message_loop_ (required) and before other | 91 // Destroy parts_ before main_message_loop_ (required) and before other |
86 // classes constructed in content (but after main_thread_). | 92 // classes constructed in content (but after main_thread_). |
87 scoped_ptr<BrowserMainParts> parts_; | 93 scoped_ptr<BrowserMainParts> parts_; |
88 | 94 |
89 // Members initialized in |InitializeMainThread()| --------------------------- | 95 // Members initialized in |InitializeMainThread()| --------------------------- |
90 // This must get destroyed before other threads that are created in parts_. | 96 // This must get destroyed before other threads that are created in parts_. |
(...skipping 10 matching lines...) Expand all Loading... |
101 scoped_ptr<BrowserProcessSubThread> process_launcher_thread_; | 107 scoped_ptr<BrowserProcessSubThread> process_launcher_thread_; |
102 scoped_ptr<BrowserProcessSubThread> cache_thread_; | 108 scoped_ptr<BrowserProcessSubThread> cache_thread_; |
103 scoped_ptr<BrowserProcessSubThread> io_thread_; | 109 scoped_ptr<BrowserProcessSubThread> io_thread_; |
104 | 110 |
105 DISALLOW_COPY_AND_ASSIGN(BrowserMainLoop); | 111 DISALLOW_COPY_AND_ASSIGN(BrowserMainLoop); |
106 }; | 112 }; |
107 | 113 |
108 } // namespace content | 114 } // namespace content |
109 | 115 |
110 #endif // CONTENT_BROWSER_BROWSER_MAIN_LOOP_H_ | 116 #endif // CONTENT_BROWSER_BROWSER_MAIN_LOOP_H_ |
OLD | NEW |