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
3 // found in the LICENSE file.
5 #include "components/view_manager/view_manager_root_connection.h"
7 #include "components/view_manager/connection_manager.h"
8 #include "components/view_manager/view_manager_root_impl.h"
10 namespace view_manager
{
12 ViewManagerRootConnection::ViewManagerRootConnection(
13 scoped_ptr
<ViewManagerRootImpl
> view_manager_root
,
14 ConnectionManager
* manager
)
15 : root_(view_manager_root
.Pass()),
17 connection_manager_(manager
),
18 connection_closed_(false) {
21 ViewManagerRootConnection::~ViewManagerRootConnection() {
22 // If this DCHECK fails then something has tried to delete this object without
23 // calling CloseConnection.
24 DCHECK(connection_closed_
);
28 void ViewManagerRootConnection::CloseConnection() {
29 // A connection error will trigger the display to close and so we want to make
30 // sure we signal the ConnectionManager only once.
31 if (connection_closed_
)
33 connection_manager()->OnRootConnectionClosed(this);
34 connection_closed_
= true;
38 ViewManagerServiceImpl
* ViewManagerRootConnection::GetViewManagerService() {
42 void ViewManagerRootConnection::OnDisplayInitialized() {
45 void ViewManagerRootConnection::OnDisplayClosed() {
49 ViewManagerRootConnectionImpl::ViewManagerRootConnectionImpl(
50 mojo::InterfaceRequest
<mojo::ViewManagerRoot
> request
,
51 scoped_ptr
<ViewManagerRootImpl
> root
,
52 mojo::ViewManagerClientPtr client
,
53 ConnectionManager
* manager
)
54 : ViewManagerRootConnection(root
.Pass(), manager
),
55 binding_(view_manager_root(), request
.Pass()),
56 client_(client
.Pass()) {
59 ViewManagerRootConnectionImpl::~ViewManagerRootConnectionImpl() {
62 void ViewManagerRootConnectionImpl::OnDisplayInitialized() {
63 connection_manager()->AddRoot(this);
64 set_view_manager_service(connection_manager()->EmbedAtView(
65 kInvalidConnectionId
, view_manager_root()->root_view()->id(),
69 } // namespace view_manager