| 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 "components/mus/ws/client_connection.h" | 5 #include "components/mus/ws/client_connection.h" |
| 6 | 6 |
| 7 #include "base/bind.h" |
| 7 #include "components/mus/ws/connection_manager.h" | 8 #include "components/mus/ws/connection_manager.h" |
| 8 #include "components/mus/ws/window_tree_impl.h" | 9 #include "components/mus/ws/window_tree_impl.h" |
| 9 | 10 |
| 10 namespace mus { | 11 namespace mus { |
| 11 namespace ws { | 12 namespace ws { |
| 12 | 13 |
| 13 ClientConnection::ClientConnection(scoped_ptr<WindowTreeImpl> service, | 14 ClientConnection::ClientConnection(mojom::WindowTreeClient* client) |
| 14 mojom::WindowTreeClient* client) | 15 : client_(client) {} |
| 15 : service_(std::move(service)), client_(client) {} | |
| 16 | 16 |
| 17 ClientConnection::~ClientConnection() {} | 17 ClientConnection::~ClientConnection() {} |
| 18 | 18 |
| 19 DefaultClientConnection::DefaultClientConnection( | 19 DefaultClientConnection::DefaultClientConnection( |
| 20 scoped_ptr<WindowTreeImpl> service_impl, | 20 WindowTreeImpl* tree, |
| 21 ConnectionManager* connection_manager, | 21 ConnectionManager* connection_manager, |
| 22 mojom::WindowTreeRequest service_request, | 22 mojom::WindowTreeRequest service_request, |
| 23 mojom::WindowTreeClientPtr client) | 23 mojom::WindowTreeClientPtr client) |
| 24 : ClientConnection(std::move(service_impl), client.get()), | 24 : ClientConnection(client.get()), |
| 25 connection_manager_(connection_manager), | 25 connection_manager_(connection_manager), |
| 26 binding_(service(), std::move(service_request)), | 26 binding_(tree, std::move(service_request)), |
| 27 client_(std::move(client)) { | 27 client_(std::move(client)) { |
| 28 // Both |connection_manager| and |tree| outlive us. |
| 28 binding_.set_connection_error_handler( | 29 binding_.set_connection_error_handler( |
| 29 [this]() { connection_manager_->OnConnectionError(this); }); | 30 base::Bind(&ConnectionManager::DestroyTree, |
| 31 base::Unretained(connection_manager), base::Unretained(tree))); |
| 30 } | 32 } |
| 31 | 33 |
| 32 DefaultClientConnection::DefaultClientConnection( | 34 DefaultClientConnection::DefaultClientConnection( |
| 33 scoped_ptr<WindowTreeImpl> service_impl, | 35 WindowTreeImpl* tree, |
| 34 ConnectionManager* connection_manager, | 36 ConnectionManager* connection_manager, |
| 35 mojom::WindowTreeClientPtr client) | 37 mojom::WindowTreeClientPtr client) |
| 36 : ClientConnection(std::move(service_impl), client.get()), | 38 : ClientConnection(client.get()), |
| 37 connection_manager_(connection_manager), | 39 connection_manager_(connection_manager), |
| 38 binding_(service()), | 40 binding_(tree), |
| 39 client_(std::move(client)) {} | 41 client_(std::move(client)) {} |
| 40 | 42 |
| 41 DefaultClientConnection::~DefaultClientConnection() {} | 43 DefaultClientConnection::~DefaultClientConnection() {} |
| 42 | 44 |
| 43 void DefaultClientConnection::SetIncomingMethodCallProcessingPaused( | 45 void DefaultClientConnection::SetIncomingMethodCallProcessingPaused( |
| 44 bool paused) { | 46 bool paused) { |
| 45 if (paused) | 47 if (paused) |
| 46 binding_.PauseIncomingMethodCallProcessing(); | 48 binding_.PauseIncomingMethodCallProcessing(); |
| 47 else | 49 else |
| 48 binding_.ResumeIncomingMethodCallProcessing(); | 50 binding_.ResumeIncomingMethodCallProcessing(); |
| 49 } | 51 } |
| 50 | 52 |
| 51 mojom::WindowTreePtr DefaultClientConnection::CreateInterfacePtrAndBind() { | 53 mojom::WindowTreePtr DefaultClientConnection::CreateInterfacePtrAndBind() { |
| 52 DCHECK(!binding_.is_bound()); | 54 DCHECK(!binding_.is_bound()); |
| 53 return binding_.CreateInterfacePtrAndBind(); | 55 return binding_.CreateInterfacePtrAndBind(); |
| 54 } | 56 } |
| 55 | 57 |
| 56 mojom::WindowManager* DefaultClientConnection::GetWindowManager() { | 58 mojom::WindowManager* DefaultClientConnection::GetWindowManager() { |
| 57 client_->GetWindowManager( | 59 client_->GetWindowManager( |
| 58 GetProxy(&window_manager_internal_, client_.associated_group())); | 60 GetProxy(&window_manager_internal_, client_.associated_group())); |
| 59 return window_manager_internal_.get(); | 61 return window_manager_internal_.get(); |
| 60 } | 62 } |
| 61 | 63 |
| 62 } // namespace ws | 64 } // namespace ws |
| 63 } // namespace mus | 65 } // namespace mus |
| OLD | NEW |