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 #include "ui/wm/public/dispatcher_client.h" | 5 #include "ui/wm/public/dispatcher_client.h" |
6 | 6 |
| 7 #include "base/callback.h" |
7 #include "ui/aura/window.h" | 8 #include "ui/aura/window.h" |
8 #include "ui/aura/window_property.h" | 9 #include "ui/aura/window_property.h" |
9 | 10 |
10 DECLARE_WINDOW_PROPERTY_TYPE(aura::client::DispatcherClient*); | 11 DECLARE_WINDOW_PROPERTY_TYPE(aura::client::DispatcherClient*); |
11 | 12 |
12 namespace aura { | 13 namespace aura { |
13 namespace client { | 14 namespace client { |
14 | 15 |
| 16 DispatcherRunLoop::DispatcherRunLoop(DispatcherClient* client, |
| 17 base::MessagePumpDispatcher* dispatcher) { |
| 18 client->PrepareNestedLoopClosures(dispatcher, &run_closure_, &quit_closure_); |
| 19 } |
| 20 |
| 21 DispatcherRunLoop::~DispatcherRunLoop() { |
| 22 } |
| 23 |
| 24 void DispatcherRunLoop::Run() { |
| 25 base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); |
| 26 base::MessageLoopForUI::ScopedNestableTaskAllower allow_nested(loop); |
| 27 run_closure_.Run(); |
| 28 } |
| 29 |
| 30 base::Closure DispatcherRunLoop::QuitClosure() { |
| 31 return quit_closure_; |
| 32 } |
| 33 |
| 34 void DispatcherRunLoop::Quit() { |
| 35 quit_closure_.Run(); |
| 36 } |
| 37 |
15 DEFINE_LOCAL_WINDOW_PROPERTY_KEY(DispatcherClient*, kDispatcherClientKey, NULL); | 38 DEFINE_LOCAL_WINDOW_PROPERTY_KEY(DispatcherClient*, kDispatcherClientKey, NULL); |
16 | 39 |
17 void SetDispatcherClient(Window* root_window, DispatcherClient* client) { | 40 void SetDispatcherClient(Window* root_window, DispatcherClient* client) { |
18 DCHECK_EQ(root_window->GetRootWindow(), root_window); | 41 DCHECK_EQ(root_window->GetRootWindow(), root_window); |
19 root_window->SetProperty(kDispatcherClientKey, client); | 42 root_window->SetProperty(kDispatcherClientKey, client); |
20 } | 43 } |
21 | 44 |
22 DispatcherClient* GetDispatcherClient(Window* root_window) { | 45 DispatcherClient* GetDispatcherClient(Window* root_window) { |
23 if (root_window) | 46 if (root_window) |
24 DCHECK_EQ(root_window->GetRootWindow(), root_window); | 47 DCHECK_EQ(root_window->GetRootWindow(), root_window); |
25 return root_window ? root_window->GetProperty(kDispatcherClientKey) : NULL; | 48 return root_window ? root_window->GetProperty(kDispatcherClientKey) : NULL; |
26 } | 49 } |
27 | 50 |
28 } // namespace client | 51 } // namespace client |
29 } // namespace aura | 52 } // namespace aura |
OLD | NEW |