| OLD | NEW |
| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 return static_cast<uint16_t>((id >> 16) & 0xFFFF); | 76 return static_cast<uint16_t>((id >> 16) & 0xFFFF); |
| 75 } | 77 } |
| 76 | 78 |
| 77 struct WindowPortPropertyDataMus : public ui::PropertyData { | 79 struct WindowPortPropertyDataMus : public ui::PropertyData { |
| 78 std::string transport_name; | 80 std::string transport_name; |
| 79 std::unique_ptr<std::vector<uint8_t>> transport_value; | 81 std::unique_ptr<std::vector<uint8_t>> transport_value; |
| 80 }; | 82 }; |
| 81 | 83 |
| 82 // Handles acknowledgment of an input event, either immediately when a nested | 84 // Handles acknowledgment of an input event, either immediately when a nested |
| 83 // message loop starts, or upon destruction. | 85 // message loop starts, or upon destruction. |
| 84 class EventAckHandler : public base::MessageLoop::NestingObserver { | 86 class EventAckHandler : public base::RunLoop::NestingObserver { |
| 85 public: | 87 public: |
| 86 explicit EventAckHandler(std::unique_ptr<EventResultCallback> ack_callback) | 88 explicit EventAckHandler(std::unique_ptr<EventResultCallback> ack_callback) |
| 87 : ack_callback_(std::move(ack_callback)) { | 89 : ack_callback_(std::move(ack_callback)) { |
| 88 DCHECK(ack_callback_); | 90 DCHECK(ack_callback_); |
| 89 base::MessageLoop::current()->AddNestingObserver(this); | 91 base::RunLoop::AddNestingObserverOnCurrentThread(this); |
| 90 } | 92 } |
| 91 | 93 |
| 92 ~EventAckHandler() override { | 94 ~EventAckHandler() override { |
| 93 base::MessageLoop::current()->RemoveNestingObserver(this); | 95 base::RunLoop::RemoveNestingObserverOnCurrentThread(this); |
| 94 if (ack_callback_) { | 96 if (ack_callback_) { |
| 95 ack_callback_->Run(handled_ ? ui::mojom::EventResult::HANDLED | 97 ack_callback_->Run(handled_ ? ui::mojom::EventResult::HANDLED |
| 96 : ui::mojom::EventResult::UNHANDLED); | 98 : ui::mojom::EventResult::UNHANDLED); |
| 97 } | 99 } |
| 98 } | 100 } |
| 99 | 101 |
| 100 void set_handled(bool handled) { handled_ = handled; } | 102 void set_handled(bool handled) { handled_ = handled; } |
| 101 | 103 |
| 102 // base::MessageLoop::NestingObserver: | 104 // base::RunLoop::NestingObserver: |
| 103 void OnBeginNestedMessageLoop() override { | 105 void OnBeginNestedRunLoop() override { |
| 104 // Acknowledge the event immediately if a nested message loop starts. | 106 // Acknowledge the event immediately if a nested message loop starts. |
| 105 // Otherwise we appear unresponsive for the life of the nested message loop. | 107 // Otherwise we appear unresponsive for the life of the nested message loop. |
| 106 if (ack_callback_) { | 108 if (ack_callback_) { |
| 107 ack_callback_->Run(ui::mojom::EventResult::HANDLED); | 109 ack_callback_->Run(ui::mojom::EventResult::HANDLED); |
| 108 ack_callback_.reset(); | 110 ack_callback_.reset(); |
| 109 } | 111 } |
| 110 } | 112 } |
| 111 | 113 |
| 112 private: | 114 private: |
| 113 std::unique_ptr<EventResultCallback> ack_callback_; | 115 std::unique_ptr<EventResultCallback> ack_callback_; |
| (...skipping 1856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1970 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( | 1972 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( |
| 1971 this, capture_synchronizer_.get(), window)); | 1973 this, capture_synchronizer_.get(), window)); |
| 1972 } | 1974 } |
| 1973 | 1975 |
| 1974 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { | 1976 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { |
| 1975 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( | 1977 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( |
| 1976 this, focus_synchronizer_.get(), window)); | 1978 this, focus_synchronizer_.get(), window)); |
| 1977 } | 1979 } |
| 1978 | 1980 |
| 1979 } // namespace aura | 1981 } // namespace aura |
| OLD | NEW |