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.
5 #ifndef IOS_WEB_APP_WEB_MAIN_LOOP_H_
6 #define IOS_WEB_APP_WEB_MAIN_LOOP_H_
8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
21 class NetworkChangeNotifier
;
25 class CookieNotificationBridge
;
29 // Implements the main web loop stages called from WebMainRunner.
30 // See comments in web_main_parts.h for additional info.
33 explicit WebMainLoop();
34 virtual ~WebMainLoop();
38 void EarlyInitialization();
39 void MainMessageLoopStart();
41 // Creates and starts running the tasks needed to complete startup.
42 void CreateStartupTasks();
44 // Performs the shutdown sequence, starting with PostMainMessageLoopRun
45 // through stopping threads to PostDestroyThreads.
46 void ShutdownThreadsAndCleanUp();
48 int GetResultCode() const { return result_code_
; }
51 void InitializeMainThread();
53 // Called just before creating the threads
54 int PreCreateThreads();
56 // Creates all secondary threads.
59 // Called right after the web threads have been started.
60 int WebThreadsStarted();
62 // Called just before attaching to the main message loop.
63 int PreMainMessageLoopRun();
65 // Members initialized on construction ---------------------------------------
67 // True if the non-UI threads were created.
68 bool created_threads_
;
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_
;
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_
;
80 // Members initialized in |InitializeMainThread()| ---------------------------
81 // This must get destroyed before other threads that are created in parts_.
82 scoped_ptr
<WebThreadImpl
> main_thread_
;
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_
;
91 // Members initialized in |WebThreadsStarted()| --------------------------
92 scoped_ptr
<CookieNotificationBridge
> cookie_notification_bridge_
;
94 DISALLOW_COPY_AND_ASSIGN(WebMainLoop
);
99 #endif // IOS_WEB_APP_WEB_MAIN_LOOP_H_