| 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/view_manager/view_manager_root_connection.h" | 5 #include "components/view_manager/view_manager_root_connection.h" |
| 6 | 6 |
| 7 #include "components/view_manager/connection_manager.h" | 7 #include "components/view_manager/connection_manager.h" |
| 8 #include "components/view_manager/view_manager_root_impl.h" | 8 #include "components/view_manager/view_manager_root_impl.h" |
| 9 | 9 |
| 10 namespace view_manager { | 10 namespace view_manager { |
| 11 | 11 |
| 12 ViewManagerRootConnection::ViewManagerRootConnection( | 12 ViewManagerRootConnection::ViewManagerRootConnection( |
| 13 scoped_ptr<ViewManagerRootImpl> view_manager_root, | 13 scoped_ptr<ViewManagerRootImpl> view_manager_root, |
| 14 ConnectionManager* manager) | 14 ConnectionManager* manager) |
| 15 : root_(view_manager_root.Pass()), | 15 : root_(view_manager_root.Pass()), |
| 16 service_(nullptr), | 16 tree_(nullptr), |
| 17 connection_manager_(manager), | 17 connection_manager_(manager), |
| 18 connection_closed_(false) { | 18 connection_closed_(false) { |
| 19 } | 19 } |
| 20 | 20 |
| 21 ViewManagerRootConnection::~ViewManagerRootConnection() { | 21 ViewManagerRootConnection::~ViewManagerRootConnection() { |
| 22 // If this DCHECK fails then something has tried to delete this object without | 22 // If this DCHECK fails then something has tried to delete this object without |
| 23 // calling CloseConnection. | 23 // calling CloseConnection. |
| 24 DCHECK(connection_closed_); | 24 DCHECK(connection_closed_); |
| 25 } | 25 } |
| 26 | 26 |
| 27 | 27 |
| 28 void ViewManagerRootConnection::CloseConnection() { | 28 void ViewManagerRootConnection::CloseConnection() { |
| 29 // A connection error will trigger the display to close and so we want to make | 29 // A connection error will trigger the display to close and so we want to make |
| 30 // sure we signal the ConnectionManager only once. | 30 // sure we signal the ConnectionManager only once. |
| 31 if (connection_closed_) | 31 if (connection_closed_) |
| 32 return; | 32 return; |
| 33 connection_manager()->OnRootConnectionClosed(this); | 33 connection_manager()->OnRootConnectionClosed(this); |
| 34 connection_closed_ = true; | 34 connection_closed_ = true; |
| 35 delete this; | 35 delete this; |
| 36 } | 36 } |
| 37 | 37 |
| 38 ViewManagerServiceImpl* ViewManagerRootConnection::GetViewManagerService() { | 38 ViewTreeImpl* ViewManagerRootConnection::GetViewTree() { |
| 39 return service_; | 39 return tree_; |
| 40 } | 40 } |
| 41 | 41 |
| 42 void ViewManagerRootConnection::OnDisplayInitialized() { | 42 void ViewManagerRootConnection::OnDisplayInitialized() { |
| 43 } | 43 } |
| 44 | 44 |
| 45 void ViewManagerRootConnection::OnDisplayClosed() { | 45 void ViewManagerRootConnection::OnDisplayClosed() { |
| 46 CloseConnection(); | 46 CloseConnection(); |
| 47 } | 47 } |
| 48 | 48 |
| 49 ViewManagerRootConnectionImpl::ViewManagerRootConnectionImpl( | 49 ViewManagerRootConnectionImpl::ViewManagerRootConnectionImpl( |
| 50 mojo::InterfaceRequest<mojo::ViewManagerRoot> request, | 50 mojo::InterfaceRequest<mojo::ViewManagerRoot> request, |
| 51 scoped_ptr<ViewManagerRootImpl> root, | 51 scoped_ptr<ViewManagerRootImpl> root, |
| 52 mojo::ViewManagerClientPtr client, | 52 mojo::ViewTreeClientPtr client, |
| 53 ConnectionManager* manager) | 53 ConnectionManager* manager) |
| 54 : ViewManagerRootConnection(root.Pass(), manager), | 54 : ViewManagerRootConnection(root.Pass(), manager), |
| 55 binding_(view_manager_root(), request.Pass()), | 55 binding_(view_manager_root(), request.Pass()), |
| 56 client_(client.Pass()) { | 56 client_(client.Pass()) { |
| 57 } | 57 } |
| 58 | 58 |
| 59 ViewManagerRootConnectionImpl::~ViewManagerRootConnectionImpl() { | 59 ViewManagerRootConnectionImpl::~ViewManagerRootConnectionImpl() { |
| 60 } | 60 } |
| 61 | 61 |
| 62 void ViewManagerRootConnectionImpl::OnDisplayInitialized() { | 62 void ViewManagerRootConnectionImpl::OnDisplayInitialized() { |
| 63 connection_manager()->AddRoot(this); | 63 connection_manager()->AddRoot(this); |
| 64 set_view_manager_service(connection_manager()->EmbedAtView( | 64 set_view_tree(connection_manager()->EmbedAtView( |
| 65 kInvalidConnectionId, view_manager_root()->root_view()->id(), | 65 kInvalidConnectionId, view_manager_root()->root_view()->id(), |
| 66 client_.Pass())); | 66 client_.Pass())); |
| 67 } | 67 } |
| 68 | 68 |
| 69 } // namespace view_manager | 69 } // namespace view_manager |
| OLD | NEW |