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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/mus/compositor_mus_connection.cc
diff --git a/content/renderer/mus/compositor_mus_connection.cc b/content/renderer/mus/compositor_mus_connection.cc
index be3998c185111c2ff4fea9940c9445952485b73d..dc2ed00ebc29432b88cb82059206e50cd901ea48 100644
--- a/content/renderer/mus/compositor_mus_connection.cc
+++ b/content/renderer/mus/compositor_mus_connection.cc
@@ -55,7 +55,11 @@ void CompositorMusConnection::AttachSurfaceOnMainThread(
this, base::Passed(std::move(surface_binding))));
}
-CompositorMusConnection::~CompositorMusConnection() {}
+CompositorMusConnection::~CompositorMusConnection() {
+ base::AutoLock auto_lock(window_tree_client_lock_);
+ // Destruction must happen on the compositor task runner.
+ DCHECK(!window_tree_client_);
+}
void CompositorMusConnection::AttachSurfaceOnCompositorThread(
std::unique_ptr<ui::WindowSurfaceBinding> surface_binding) {
@@ -70,7 +74,11 @@ void CompositorMusConnection::AttachSurfaceOnCompositorThread(
void CompositorMusConnection::CreateWindowTreeClientOnCompositorThread(
mojo::InterfaceRequest<ui::mojom::WindowTreeClient> request) {
DCHECK(compositor_task_runner_->BelongsToCurrentThread());
- new ui::WindowTreeClient(this, nullptr, std::move(request));
+ DCHECK(!window_tree_client_);
+ std::unique_ptr<ui::WindowTreeClient> window_tree_client =
+ base::MakeUnique<ui::WindowTreeClient>(this, nullptr, std::move(request));
+ base::AutoLock auto_lock(window_tree_client_lock_);
+ window_tree_client_ = std::move(window_tree_client);
}
void CompositorMusConnection::OnConnectionLostOnMainThread() {
@@ -128,8 +136,13 @@ std::unique_ptr<blink::WebInputEvent> CompositorMusConnection::Convert(
return nullptr;
}
-void CompositorMusConnection::OnDidDestroyClient(ui::WindowTreeClient* client) {
+void CompositorMusConnection::DeleteWindowTreeClient() {
DCHECK(compositor_task_runner_->BelongsToCurrentThread());
+ std::unique_ptr<ui::WindowTreeClient> window_tree_client;
+ {
+ base::AutoLock auto_lock(window_tree_client_lock_);
+ window_tree_client = std::move(window_tree_client_);
+ }
main_task_runner_->PostTask(
FROM_HERE,
base::Bind(&CompositorMusConnection::OnConnectionLostOnMainThread, this));
@@ -145,6 +158,14 @@ void CompositorMusConnection::OnEmbed(ui::Window* root) {
}
}
+void CompositorMusConnection::OnEmbedRootDestroyed(ui::Window* window) {
+ DeleteWindowTreeClient();
+}
+
+void CompositorMusConnection::OnLostConnection(ui::WindowTreeClient* client) {
+ DeleteWindowTreeClient();
+}
+
void CompositorMusConnection::OnPointerEventObserved(
const ui::PointerEvent& event,
ui::Window* target) {
« 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