OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 | 12 |
12 class CommandLine; | 13 class CommandLine; |
13 class HighResolutionTimerManager; | 14 class HighResolutionTimerManager; |
14 class MessageLoop; | 15 class MessageLoop; |
15 class SystemMessageWindowWin; | 16 class SystemMessageWindowWin; |
16 | 17 |
17 namespace base { | 18 namespace base { |
18 class SystemMonitor; | 19 class SystemMonitor; |
19 } | 20 } |
20 | 21 |
21 namespace net { | 22 namespace net { |
22 class NetworkChangeNotifier; | 23 class NetworkChangeNotifier; |
23 } | 24 } |
24 | 25 |
25 namespace content { | 26 namespace content { |
26 | 27 |
27 class BrowserMainParts; | 28 class BrowserMainParts; |
| 29 class BrowserShutdownImpl; |
28 class BrowserThreadImpl; | 30 class BrowserThreadImpl; |
29 struct MainFunctionParams; | 31 struct MainFunctionParams; |
30 | 32 |
31 // Implements the main browser loop stages called from |BrowserMain()|. | 33 // Implements the main browser loop stages called from |BrowserMain()|. |
32 // See comments in browser_main_parts.h for additional info. | 34 // See comments in browser_main_parts.h for additional info. |
33 class BrowserMainLoop { | 35 class BrowserMainLoop { |
34 public: | 36 public: |
35 explicit BrowserMainLoop(const content::MainFunctionParams& parameters); | 37 explicit BrowserMainLoop(const content::MainFunctionParams& parameters); |
36 virtual ~BrowserMainLoop(); | 38 virtual ~BrowserMainLoop(); |
37 | 39 |
38 void Init(); | 40 void Init(); |
39 | 41 |
40 void EarlyInitialization(); | 42 void EarlyInitialization(); |
41 void InitializeToolkit(); | 43 void InitializeToolkit(); |
42 void MainMessageLoopStart(); | 44 void MainMessageLoopStart(); |
43 void RunMainMessageLoopParts(bool* completed_main_message_loop); | 45 void RunMainMessageLoopParts(bool* completed_main_message_loop); |
44 void MainMessageLoopRun(); | 46 void MainMessageLoopRun(); |
45 | 47 |
46 int GetResultCode() const { return result_code_; } | 48 int GetResultCode() const { return result_code_; } |
47 | 49 |
48 private: | 50 private: |
| 51 // For ShutdownThreadsAndCleanUp. |
| 52 friend class BrowserShutdownImpl; |
| 53 |
| 54 // Performs the shutdown sequence, starting with PostMainMessageLoopRun |
| 55 // through stopping threads to PostDestroyThreads. |
| 56 void ShutdownThreadsAndCleanUp(); |
| 57 |
49 void InitializeMainThread(); | 58 void InitializeMainThread(); |
50 | 59 |
51 // Members initialized on construction --------------------------------------- | 60 // Members initialized on construction --------------------------------------- |
52 const content::MainFunctionParams& parameters_; | 61 const content::MainFunctionParams& parameters_; |
53 const CommandLine& parsed_command_line_; | 62 const CommandLine& parsed_command_line_; |
54 int result_code_; | 63 int result_code_; |
55 | 64 |
56 // Members initialized in |MainMessageLoopStart()| --------------------------- | 65 // Members initialized in |MainMessageLoopStart()| --------------------------- |
57 scoped_ptr<MessageLoop> main_message_loop_; | 66 scoped_ptr<MessageLoop> main_message_loop_; |
58 scoped_ptr<base::SystemMonitor> system_monitor_; | 67 scoped_ptr<base::SystemMonitor> system_monitor_; |
59 scoped_ptr<HighResolutionTimerManager> hi_res_timer_manager_; | 68 scoped_ptr<HighResolutionTimerManager> hi_res_timer_manager_; |
60 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; | 69 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; |
61 #if defined(OS_WIN) | 70 #if defined(OS_WIN) |
62 scoped_ptr<SystemMessageWindowWin> system_message_window_; | 71 scoped_ptr<SystemMessageWindowWin> system_message_window_; |
63 #endif | 72 #endif |
64 | 73 |
65 // Destroy parts_ before main_message_loop_ (required) and before other | 74 // Destroy parts_ before main_message_loop_ (required) and before other |
66 // classes constructed in content (but after main_thread_). | 75 // classes constructed in content (but after main_thread_). |
67 scoped_ptr<BrowserMainParts> parts_; | 76 scoped_ptr<BrowserMainParts> parts_; |
68 | 77 |
69 // Members initialized in |InitializeMainThread()| --------------------------- | 78 // Members initialized in |InitializeMainThread()| --------------------------- |
70 // This must get destroyed before other threads that are created in parts_. | 79 // This must get destroyed before other threads that are created in parts_. |
71 scoped_ptr<BrowserThreadImpl> main_thread_; | 80 scoped_ptr<BrowserThreadImpl> main_thread_; |
| 81 scoped_ptr<BrowserProcessSubThread> io_thread_; |
| 82 scoped_ptr<BrowserProcessSubThread> file_thread_; |
| 83 scoped_ptr<BrowserProcessSubThread> db_thread_; |
| 84 scoped_ptr<BrowserProcessSubThread> process_launcher_thread_; |
| 85 scoped_ptr<BrowserProcessSubThread> cache_thread_; |
| 86 #if defined(OS_CHROMEOS) |
| 87 scoped_ptr<BrowserProcessSubThread> web_socket_proxy_thread_; |
| 88 #endif |
72 | 89 |
73 DISALLOW_COPY_AND_ASSIGN(BrowserMainLoop); | 90 DISALLOW_COPY_AND_ASSIGN(BrowserMainLoop); |
74 }; | 91 }; |
75 | 92 |
76 } // namespace content | 93 } // namespace content |
77 | 94 |
78 #endif // CONTENT_BROWSER_BROWSER_MAIN_LOOP_H_ | 95 #endif // CONTENT_BROWSER_BROWSER_MAIN_LOOP_H_ |
OLD | NEW |