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