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 UI_WM_PUBLIC_DISPATCHER_CLIENT_H_ | 5 #ifndef UI_WM_PUBLIC_DISPATCHER_CLIENT_H_ |
6 #define UI_WM_PUBLIC_DISPATCHER_CLIENT_H_ | 6 #define UI_WM_PUBLIC_DISPATCHER_CLIENT_H_ |
7 | 7 |
| 8 #include "base/callback.h" |
| 9 #include "base/macros.h" |
8 #include "base/message_loop/message_pump_dispatcher.h" | 10 #include "base/message_loop/message_pump_dispatcher.h" |
9 #include "ui/aura/aura_export.h" | 11 #include "ui/aura/aura_export.h" |
10 | 12 |
11 namespace aura { | 13 namespace aura { |
12 class Window; | 14 class Window; |
13 namespace client { | 15 namespace client { |
14 | 16 |
| 17 class DispatcherClient; |
| 18 |
| 19 // A base::RunLoop like object for running a nested message-loop with a |
| 20 // specified DispatcherClient and a MessagePumpDispatcher. |
| 21 class AURA_EXPORT DispatcherRunLoop { |
| 22 public: |
| 23 DispatcherRunLoop(DispatcherClient* client, |
| 24 base::MessagePumpDispatcher* dispatcher); |
| 25 ~DispatcherRunLoop(); |
| 26 |
| 27 void Run(); |
| 28 base::Closure QuitClosure(); |
| 29 void Quit(); |
| 30 |
| 31 private: |
| 32 base::Closure run_closure_; |
| 33 base::Closure quit_closure_; |
| 34 |
| 35 DISALLOW_COPY_AND_ASSIGN(DispatcherRunLoop); |
| 36 }; |
| 37 |
15 // An interface implemented by an object which handles nested dispatchers. | 38 // An interface implemented by an object which handles nested dispatchers. |
16 class AURA_EXPORT DispatcherClient { | 39 class AURA_EXPORT DispatcherClient { |
17 public: | 40 public: |
18 virtual void RunWithDispatcher(base::MessagePumpDispatcher* dispatcher) = 0; | 41 virtual ~DispatcherClient() {} |
19 | 42 |
20 virtual void QuitNestedMessageLoop() = 0; | 43 protected: |
| 44 friend class DispatcherRunLoop; |
| 45 |
| 46 virtual void PrepareNestedLoopClosures( |
| 47 base::MessagePumpDispatcher* dispatcher, |
| 48 base::Closure* run_closure, |
| 49 base::Closure* quit_closure) = 0; |
21 }; | 50 }; |
22 | 51 |
23 AURA_EXPORT void SetDispatcherClient(Window* root_window, | 52 AURA_EXPORT void SetDispatcherClient(Window* root_window, |
24 DispatcherClient* client); | 53 DispatcherClient* client); |
25 AURA_EXPORT DispatcherClient* GetDispatcherClient(Window* root_window); | 54 AURA_EXPORT DispatcherClient* GetDispatcherClient(Window* root_window); |
26 | 55 |
27 } // namespace client | 56 } // namespace client |
28 } // namespace aura | 57 } // namespace aura |
29 | 58 |
30 #endif // UI_WM_PUBLIC_DISPATCHER_CLIENT_H_ | 59 #endif // UI_WM_PUBLIC_DISPATCHER_CLIENT_H_ |
OLD | NEW |