| OLD | NEW |
| 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 "components/mus/ws/window_tree_host_connection.h" | 5 #include "components/mus/ws/window_tree_host_connection.h" |
| 6 | 6 |
| 7 #include "components/mus/ws/connection_manager.h" | 7 #include "components/mus/ws/connection_manager.h" |
| 8 #include "components/mus/ws/window_tree_host_impl.h" | 8 #include "components/mus/ws/window_tree_host_impl.h" |
| 9 #include "components/mus/ws/window_tree_impl.h" | 9 #include "components/mus/ws/window_tree_impl.h" |
| 10 | 10 |
| 11 namespace mus { | 11 namespace mus { |
| 12 | |
| 13 namespace ws { | 12 namespace ws { |
| 14 | 13 |
| 15 WindowTreeHostConnection::WindowTreeHostConnection( | |
| 16 scoped_ptr<WindowTreeHostImpl> host_impl, | |
| 17 ConnectionManager* manager) | |
| 18 : host_(std::move(host_impl)), | |
| 19 tree_(nullptr), | |
| 20 connection_manager_(manager), | |
| 21 connection_closed_(false) {} | |
| 22 | |
| 23 WindowTreeHostConnection::~WindowTreeHostConnection() { | |
| 24 // If this DCHECK fails then something has tried to delete this object without | |
| 25 // calling CloseConnection. | |
| 26 DCHECK(connection_closed_); | |
| 27 } | |
| 28 | |
| 29 void WindowTreeHostConnection::CloseConnection() { | |
| 30 // A connection error will trigger the display to close and so we want to make | |
| 31 // sure we signal the ConnectionManager only once. | |
| 32 if (connection_closed_) | |
| 33 return; | |
| 34 // We have to shut down the focus system for this host before destroying the | |
| 35 // host, as destruction of the window tree will attempt to change focus. | |
| 36 host_->DestroyFocusController(); | |
| 37 connection_manager()->OnHostConnectionClosed(this); | |
| 38 connection_closed_ = true; | |
| 39 delete this; | |
| 40 } | |
| 41 | |
| 42 const WindowTreeImpl* WindowTreeHostConnection::GetWindowTree() const { | |
| 43 return tree_; | |
| 44 } | |
| 45 | |
| 46 void WindowTreeHostConnection::OnDisplayInitialized() {} | |
| 47 | |
| 48 void WindowTreeHostConnection::OnDisplayClosed() { | |
| 49 CloseConnection(); | |
| 50 } | |
| 51 | |
| 52 WindowTreeHostConnectionImpl::WindowTreeHostConnectionImpl( | 14 WindowTreeHostConnectionImpl::WindowTreeHostConnectionImpl( |
| 53 mojo::InterfaceRequest<mojom::WindowTreeHost> request, | 15 mojo::InterfaceRequest<mojom::WindowTreeHost> request, |
| 54 scoped_ptr<WindowTreeHostImpl> host_impl, | 16 WindowTreeHostImpl* host_impl, |
| 55 mojom::WindowTreeClientPtr client, | 17 mojom::WindowTreeClientPtr client, |
| 56 ConnectionManager* manager) | 18 ConnectionManager* manager) |
| 57 : WindowTreeHostConnection(std::move(host_impl), manager), | 19 : connection_manager_(manager), |
| 58 binding_(window_tree_host(), std::move(request)), | 20 binding_(host_impl, std::move(request)), |
| 59 client_(std::move(client)) {} | 21 client_(std::move(client)) {} |
| 60 | 22 |
| 61 WindowTreeHostConnectionImpl::~WindowTreeHostConnectionImpl() {} | 23 WindowTreeHostConnectionImpl::~WindowTreeHostConnectionImpl() {} |
| 62 | 24 |
| 63 void WindowTreeHostConnectionImpl::OnDisplayInitialized() { | 25 WindowTreeImpl* WindowTreeHostConnectionImpl::CreateWindowTree( |
| 64 connection_manager()->AddHost(this); | 26 ServerWindow* root) { |
| 65 WindowTreeImpl* tree = connection_manager()->EmbedAtWindow( | 27 WindowTreeImpl* tree = connection_manager_->EmbedAtWindow( |
| 66 window_tree_host()->root_window(), | 28 root, mojom::WindowTree::kAccessPolicyEmbedRoot, std::move(client_)); |
| 67 mojom::WindowTree::kAccessPolicyEmbedRoot, std::move(client_)); | |
| 68 tree->ConfigureWindowManager(); | 29 tree->ConfigureWindowManager(); |
| 69 set_window_tree(tree); | 30 return tree; |
| 70 } | 31 } |
| 71 | 32 |
| 72 } // namespace ws | 33 } // namespace ws |
| 73 | |
| 74 } // namespace mus | 34 } // namespace mus |
| OLD | NEW |