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

Side by Side Diff: content/renderer/mus/compositor_mus_connection.cc

Issue 2301353003: Changes ownership of WindowTreeClient (Closed)
Patch Set: fix navigation Created 4 years, 3 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 | « content/renderer/mus/compositor_mus_connection.h ('k') | services/navigation/view_impl.h » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "content/renderer/mus/compositor_mus_connection.h" 5 #include "content/renderer/mus/compositor_mus_connection.h"
6 6
7 #include "base/single_thread_task_runner.h" 7 #include "base/single_thread_task_runner.h"
8 #include "content/renderer/input/input_handler_manager.h" 8 #include "content/renderer/input/input_handler_manager.h"
9 #include "content/renderer/mus/render_widget_mus_connection.h" 9 #include "content/renderer/mus/render_widget_mus_connection.h"
10 #include "ui/events/blink/blink_event_util.h" 10 #include "ui/events/blink/blink_event_util.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 void CompositorMusConnection::AttachSurfaceOnMainThread( 49 void CompositorMusConnection::AttachSurfaceOnMainThread(
50 std::unique_ptr<ui::WindowSurfaceBinding> surface_binding) { 50 std::unique_ptr<ui::WindowSurfaceBinding> surface_binding) {
51 DCHECK(main_task_runner_->BelongsToCurrentThread()); 51 DCHECK(main_task_runner_->BelongsToCurrentThread());
52 compositor_task_runner_->PostTask( 52 compositor_task_runner_->PostTask(
53 FROM_HERE, 53 FROM_HERE,
54 base::Bind(&CompositorMusConnection::AttachSurfaceOnCompositorThread, 54 base::Bind(&CompositorMusConnection::AttachSurfaceOnCompositorThread,
55 this, base::Passed(std::move(surface_binding)))); 55 this, base::Passed(std::move(surface_binding))));
56 } 56 }
57 57
58 CompositorMusConnection::~CompositorMusConnection() {} 58 CompositorMusConnection::~CompositorMusConnection() {
59 base::AutoLock auto_lock(window_tree_client_lock_);
60 // Destruction must happen on the compositor task runner.
61 DCHECK(!window_tree_client_);
62 }
59 63
60 void CompositorMusConnection::AttachSurfaceOnCompositorThread( 64 void CompositorMusConnection::AttachSurfaceOnCompositorThread(
61 std::unique_ptr<ui::WindowSurfaceBinding> surface_binding) { 65 std::unique_ptr<ui::WindowSurfaceBinding> surface_binding) {
62 DCHECK(compositor_task_runner_->BelongsToCurrentThread()); 66 DCHECK(compositor_task_runner_->BelongsToCurrentThread());
63 window_surface_binding_ = std::move(surface_binding); 67 window_surface_binding_ = std::move(surface_binding);
64 if (root_) { 68 if (root_) {
65 root_->AttachSurface(ui::mojom::SurfaceType::DEFAULT, 69 root_->AttachSurface(ui::mojom::SurfaceType::DEFAULT,
66 std::move(window_surface_binding_)); 70 std::move(window_surface_binding_));
67 } 71 }
68 } 72 }
69 73
70 void CompositorMusConnection::CreateWindowTreeClientOnCompositorThread( 74 void CompositorMusConnection::CreateWindowTreeClientOnCompositorThread(
71 mojo::InterfaceRequest<ui::mojom::WindowTreeClient> request) { 75 mojo::InterfaceRequest<ui::mojom::WindowTreeClient> request) {
72 DCHECK(compositor_task_runner_->BelongsToCurrentThread()); 76 DCHECK(compositor_task_runner_->BelongsToCurrentThread());
73 new ui::WindowTreeClient(this, nullptr, std::move(request)); 77 DCHECK(!window_tree_client_);
78 std::unique_ptr<ui::WindowTreeClient> window_tree_client =
79 base::MakeUnique<ui::WindowTreeClient>(this, nullptr, std::move(request));
80 base::AutoLock auto_lock(window_tree_client_lock_);
81 window_tree_client_ = std::move(window_tree_client);
74 } 82 }
75 83
76 void CompositorMusConnection::OnConnectionLostOnMainThread() { 84 void CompositorMusConnection::OnConnectionLostOnMainThread() {
77 DCHECK(main_task_runner_->BelongsToCurrentThread()); 85 DCHECK(main_task_runner_->BelongsToCurrentThread());
78 RenderWidgetMusConnection* connection = 86 RenderWidgetMusConnection* connection =
79 RenderWidgetMusConnection::Get(routing_id_); 87 RenderWidgetMusConnection::Get(routing_id_);
80 if (!connection) 88 if (!connection)
81 return; 89 return;
82 connection->OnConnectionLost(); 90 connection->OnConnectionLost();
83 } 91 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 *event.AsMouseWheelEvent(), base::Bind(&GetScreenLocationFromEvent)); 129 *event.AsMouseWheelEvent(), base::Bind(&GetScreenLocationFromEvent));
122 return base::MakeUnique<blink::WebMouseWheelEvent>(blink_event); 130 return base::MakeUnique<blink::WebMouseWheelEvent>(blink_event);
123 } else if (event.IsKeyEvent()) { 131 } else if (event.IsKeyEvent()) {
124 blink::WebKeyboardEvent blink_event = 132 blink::WebKeyboardEvent blink_event =
125 ui::MakeWebKeyboardEvent(*event.AsKeyEvent()); 133 ui::MakeWebKeyboardEvent(*event.AsKeyEvent());
126 return base::MakeUnique<blink::WebKeyboardEvent>(blink_event); 134 return base::MakeUnique<blink::WebKeyboardEvent>(blink_event);
127 } 135 }
128 return nullptr; 136 return nullptr;
129 } 137 }
130 138
131 void CompositorMusConnection::OnDidDestroyClient(ui::WindowTreeClient* client) { 139 void CompositorMusConnection::DeleteWindowTreeClient() {
132 DCHECK(compositor_task_runner_->BelongsToCurrentThread()); 140 DCHECK(compositor_task_runner_->BelongsToCurrentThread());
141 std::unique_ptr<ui::WindowTreeClient> window_tree_client;
142 {
143 base::AutoLock auto_lock(window_tree_client_lock_);
144 window_tree_client = std::move(window_tree_client_);
145 }
133 main_task_runner_->PostTask( 146 main_task_runner_->PostTask(
134 FROM_HERE, 147 FROM_HERE,
135 base::Bind(&CompositorMusConnection::OnConnectionLostOnMainThread, this)); 148 base::Bind(&CompositorMusConnection::OnConnectionLostOnMainThread, this));
136 } 149 }
137 150
138 void CompositorMusConnection::OnEmbed(ui::Window* root) { 151 void CompositorMusConnection::OnEmbed(ui::Window* root) {
139 DCHECK(compositor_task_runner_->BelongsToCurrentThread()); 152 DCHECK(compositor_task_runner_->BelongsToCurrentThread());
140 root_ = root; 153 root_ = root;
141 root_->set_input_event_handler(this); 154 root_->set_input_event_handler(this);
142 if (window_surface_binding_) { 155 if (window_surface_binding_) {
143 root->AttachSurface(ui::mojom::SurfaceType::DEFAULT, 156 root->AttachSurface(ui::mojom::SurfaceType::DEFAULT,
144 std::move(window_surface_binding_)); 157 std::move(window_surface_binding_));
145 } 158 }
146 } 159 }
147 160
161 void CompositorMusConnection::OnEmbedRootDestroyed(ui::Window* window) {
162 DeleteWindowTreeClient();
163 }
164
165 void CompositorMusConnection::OnLostConnection(ui::WindowTreeClient* client) {
166 DeleteWindowTreeClient();
167 }
168
148 void CompositorMusConnection::OnPointerEventObserved( 169 void CompositorMusConnection::OnPointerEventObserved(
149 const ui::PointerEvent& event, 170 const ui::PointerEvent& event,
150 ui::Window* target) { 171 ui::Window* target) {
151 // Compositor does not use StartPointerWatcher(). 172 // Compositor does not use StartPointerWatcher().
152 } 173 }
153 174
154 void CompositorMusConnection::OnWindowInputEvent( 175 void CompositorMusConnection::OnWindowInputEvent(
155 ui::Window* window, 176 ui::Window* window,
156 const ui::Event& event, 177 const ui::Event& event,
157 std::unique_ptr<base::Callback<void(EventResult)>>* ack_callback) { 178 std::unique_ptr<base::Callback<void(EventResult)>>* ack_callback) {
(...skipping 21 matching lines...) Expand all
179 this, *ack_callback->get()); 200 this, *ack_callback->get());
180 ack_callback->reset(); 201 ack_callback->reset();
181 } 202 }
182 main_task_runner_->PostTask( 203 main_task_runner_->PostTask(
183 FROM_HERE, 204 FROM_HERE,
184 base::Bind(&CompositorMusConnection::OnWindowInputEventOnMainThread, this, 205 base::Bind(&CompositorMusConnection::OnWindowInputEventOnMainThread, this,
185 base::Passed(std::move(web_event)), ack)); 206 base::Passed(std::move(web_event)), ack));
186 } 207 }
187 208
188 } // namespace content 209 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/mus/compositor_mus_connection.h ('k') | services/navigation/view_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698