Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(655)

Side by Side Diff: ui/aura/mus/window_tree_client.cc

Issue 2818533003: Make nesting/running states a RunLoop rather than a MessageLoop concept. (Closed)
Patch Set: still need to check MessageLoop::current() in Mojo's RunLoopNestingObserver::GetForThread() Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/aura/mus/mus_mouse_location_updater.cc ('k') | ui/aura/window_event_dispatcher_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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/aura/mus/window_tree_client.h" 5 #include "ui/aura/mus/window_tree_client.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/auto_reset.h" 13 #include "base/auto_reset.h"
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/memory/ptr_util.h" 16 #include "base/memory/ptr_util.h"
17 #include "base/message_loop/message_loop.h"
18 #include "base/run_loop.h"
17 #include "base/threading/thread.h" 19 #include "base/threading/thread.h"
18 #include "cc/base/switches.h" 20 #include "cc/base/switches.h"
19 #include "components/discardable_memory/client/client_discardable_shared_memory_ manager.h" 21 #include "components/discardable_memory/client/client_discardable_shared_memory_ manager.h"
20 #include "mojo/public/cpp/bindings/map.h" 22 #include "mojo/public/cpp/bindings/map.h"
21 #include "services/service_manager/public/cpp/connector.h" 23 #include "services/service_manager/public/cpp/connector.h"
22 #include "services/ui/common/accelerator_util.h" 24 #include "services/ui/common/accelerator_util.h"
23 #include "services/ui/public/cpp/gpu/gpu.h" 25 #include "services/ui/public/cpp/gpu/gpu.h"
24 #include "services/ui/public/cpp/property_type_converters.h" 26 #include "services/ui/public/cpp/property_type_converters.h"
25 #include "services/ui/public/interfaces/constants.mojom.h" 27 #include "services/ui/public/interfaces/constants.mojom.h"
26 #include "services/ui/public/interfaces/window_manager.mojom.h" 28 #include "services/ui/public/interfaces/window_manager.mojom.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 return static_cast<uint16_t>((id >> 16) & 0xFFFF); 81 return static_cast<uint16_t>((id >> 16) & 0xFFFF);
80 } 82 }
81 83
82 struct WindowPortPropertyDataMus : public ui::PropertyData { 84 struct WindowPortPropertyDataMus : public ui::PropertyData {
83 std::string transport_name; 85 std::string transport_name;
84 std::unique_ptr<std::vector<uint8_t>> transport_value; 86 std::unique_ptr<std::vector<uint8_t>> transport_value;
85 }; 87 };
86 88
87 // Handles acknowledgment of an input event, either immediately when a nested 89 // Handles acknowledgment of an input event, either immediately when a nested
88 // message loop starts, or upon destruction. 90 // message loop starts, or upon destruction.
89 class EventAckHandler : public base::MessageLoop::NestingObserver { 91 class EventAckHandler : public base::RunLoop::NestingObserver {
90 public: 92 public:
91 explicit EventAckHandler(std::unique_ptr<EventResultCallback> ack_callback) 93 explicit EventAckHandler(std::unique_ptr<EventResultCallback> ack_callback)
92 : ack_callback_(std::move(ack_callback)) { 94 : ack_callback_(std::move(ack_callback)) {
93 DCHECK(ack_callback_); 95 DCHECK(ack_callback_);
94 base::MessageLoop::current()->AddNestingObserver(this); 96 base::RunLoop::AddNestingObserverOnCurrentThread(this);
95 } 97 }
96 98
97 ~EventAckHandler() override { 99 ~EventAckHandler() override {
98 base::MessageLoop::current()->RemoveNestingObserver(this); 100 base::RunLoop::RemoveNestingObserverOnCurrentThread(this);
99 if (ack_callback_) { 101 if (ack_callback_) {
100 ack_callback_->Run(handled_ ? ui::mojom::EventResult::HANDLED 102 ack_callback_->Run(handled_ ? ui::mojom::EventResult::HANDLED
101 : ui::mojom::EventResult::UNHANDLED); 103 : ui::mojom::EventResult::UNHANDLED);
102 } 104 }
103 } 105 }
104 106
105 void set_handled(bool handled) { handled_ = handled; } 107 void set_handled(bool handled) { handled_ = handled; }
106 108
107 // base::MessageLoop::NestingObserver: 109 // base::RunLoop::NestingObserver:
108 void OnBeginNestedMessageLoop() override { 110 void OnBeginNestedRunLoop() override {
109 // Acknowledge the event immediately if a nested message loop starts. 111 // Acknowledge the event immediately if a nested message loop starts.
110 // Otherwise we appear unresponsive for the life of the nested message loop. 112 // Otherwise we appear unresponsive for the life of the nested message loop.
111 if (ack_callback_) { 113 if (ack_callback_) {
112 ack_callback_->Run(ui::mojom::EventResult::HANDLED); 114 ack_callback_->Run(ui::mojom::EventResult::HANDLED);
113 ack_callback_.reset(); 115 ack_callback_.reset();
114 } 116 }
115 } 117 }
116 118
117 private: 119 private:
118 std::unique_ptr<EventResultCallback> ack_callback_; 120 std::unique_ptr<EventResultCallback> ack_callback_;
(...skipping 1917 matching lines...) Expand 10 before | Expand all | Expand 10 after
2036 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( 2038 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>(
2037 this, capture_synchronizer_.get(), window)); 2039 this, capture_synchronizer_.get(), window));
2038 } 2040 }
2039 2041
2040 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { 2042 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) {
2041 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( 2043 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>(
2042 this, focus_synchronizer_.get(), window)); 2044 this, focus_synchronizer_.get(), window));
2043 } 2045 }
2044 2046
2045 } // namespace aura 2047 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/mus/mus_mouse_location_updater.cc ('k') | ui/aura/window_event_dispatcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698