| 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) {
|
|
|