Revert "Reland c91b178b07b0d - Delete dead signin code (SigninGlobalError)"
[chromium-blink-merge.git] / components / view_manager / view_manager_root_connection.cc
blob017ccbe0a58cf8450e3797644a7534cdc2610617
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()),
16 service_(nullptr),
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_)
32 return;
33 connection_manager()->OnRootConnectionClosed(this);
34 connection_closed_ = true;
35 delete this;
38 ViewManagerServiceImpl* ViewManagerRootConnection::GetViewManagerService() {
39 return service_;
42 void ViewManagerRootConnection::OnDisplayInitialized() {
45 void ViewManagerRootConnection::OnDisplayClosed() {
46 CloseConnection();
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(),
66 client_.Pass()));
69 } // namespace view_manager