OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 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. |
| 4 |
| 5 #ifndef IOS_WEB_APP_WEB_MAIN_LOOP_H_ |
| 6 #define IOS_WEB_APP_WEB_MAIN_LOOP_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" |
| 11 |
| 12 namespace base { |
| 13 class CommandLine; |
| 14 class FilePath; |
| 15 class MessageLoop; |
| 16 class PowerMonitor; |
| 17 class SystemMonitor; |
| 18 } // namespace base |
| 19 |
| 20 namespace net { |
| 21 class NetworkChangeNotifier; |
| 22 } // namespace net |
| 23 |
| 24 namespace web { |
| 25 class CookieNotificationBridge; |
| 26 class WebMainParts; |
| 27 class WebThreadImpl; |
| 28 |
| 29 // Implements the main web loop stages called from WebMainRunner. |
| 30 // See comments in web_main_parts.h for additional info. |
| 31 class WebMainLoop { |
| 32 public: |
| 33 explicit WebMainLoop(); |
| 34 virtual ~WebMainLoop(); |
| 35 |
| 36 void Init(); |
| 37 |
| 38 void EarlyInitialization(); |
| 39 void MainMessageLoopStart(); |
| 40 |
| 41 // Creates and starts running the tasks needed to complete startup. |
| 42 void CreateStartupTasks(); |
| 43 |
| 44 // Performs the shutdown sequence, starting with PostMainMessageLoopRun |
| 45 // through stopping threads to PostDestroyThreads. |
| 46 void ShutdownThreadsAndCleanUp(); |
| 47 |
| 48 int GetResultCode() const { return result_code_; } |
| 49 |
| 50 private: |
| 51 void InitializeMainThread(); |
| 52 |
| 53 // Called just before creating the threads |
| 54 int PreCreateThreads(); |
| 55 |
| 56 // Creates all secondary threads. |
| 57 int CreateThreads(); |
| 58 |
| 59 // Called right after the web threads have been started. |
| 60 int WebThreadsStarted(); |
| 61 |
| 62 // Called just before attaching to the main message loop. |
| 63 int PreMainMessageLoopRun(); |
| 64 |
| 65 // Members initialized on construction --------------------------------------- |
| 66 int result_code_; |
| 67 // True if the non-UI threads were created. |
| 68 bool created_threads_; |
| 69 |
| 70 // Members initialized in |MainMessageLoopStart()| --------------------------- |
| 71 scoped_ptr<base::MessageLoop> main_message_loop_; |
| 72 scoped_ptr<base::SystemMonitor> system_monitor_; |
| 73 scoped_ptr<base::PowerMonitor> power_monitor_; |
| 74 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; |
| 75 |
| 76 // Destroy parts_ before main_message_loop_ (required) and before other |
| 77 // classes constructed in web (but after main_thread_). |
| 78 scoped_ptr<WebMainParts> parts_; |
| 79 |
| 80 // Members initialized in |InitializeMainThread()| --------------------------- |
| 81 // This must get destroyed before other threads that are created in parts_. |
| 82 scoped_ptr<WebThreadImpl> main_thread_; |
| 83 |
| 84 // Members initialized in |RunMainMessageLoopParts()| ------------------------ |
| 85 scoped_ptr<WebThreadImpl> db_thread_; |
| 86 scoped_ptr<WebThreadImpl> file_user_blocking_thread_; |
| 87 scoped_ptr<WebThreadImpl> file_thread_; |
| 88 scoped_ptr<WebThreadImpl> cache_thread_; |
| 89 scoped_ptr<WebThreadImpl> io_thread_; |
| 90 |
| 91 // Members initialized in |WebThreadsStarted()| -------------------------- |
| 92 scoped_ptr<CookieNotificationBridge> cookie_notification_bridge_; |
| 93 |
| 94 DISALLOW_COPY_AND_ASSIGN(WebMainLoop); |
| 95 }; |
| 96 |
| 97 } // namespace web |
| 98 |
| 99 #endif // IOS_WEB_APP_WEB_MAIN_LOOP_H_ |
OLD | NEW |