Chromium Code Reviews| Index: mojo/services/view_manager/view_manager_init_service_context.cc |
| diff --git a/mojo/services/view_manager/view_manager_init_service_context.cc b/mojo/services/view_manager/view_manager_init_service_context.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..37b55c44f0f6637fb62edfd549392c6c850c5c32 |
| --- /dev/null |
| +++ b/mojo/services/view_manager/view_manager_init_service_context.cc |
| @@ -0,0 +1,60 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "mojo/services/view_manager/view_manager_init_service_context.h" |
| + |
| +#include "base/bind.h" |
| +#include "mojo/services/view_manager/root_node_manager.h" |
| +#include "mojo/services/view_manager/view_manager_init_service_impl.h" |
| + |
| +namespace mojo { |
| +namespace view_manager { |
| +namespace service { |
| + |
| +ViewManagerInitServiceContext::ViewManagerInitServiceContext() |
| + : is_tree_host_ready_(false) {} |
| +ViewManagerInitServiceContext::~ViewManagerInitServiceContext() {} |
| + |
| +void ViewManagerInitServiceContext::AddConnection( |
| + ViewManagerInitServiceImpl* connection) { |
| + DCHECK(connections_.find(connection) == connections_.end()); |
| + connections_.insert(connection); |
| +} |
| + |
| +void ViewManagerInitServiceContext::RemoveConnection( |
| + ViewManagerInitServiceImpl* connection) { |
| + DCHECK(connections_.find(connection) != connections_.end()); |
| + connections_.erase(connection); |
| +} |
| + |
| +void ViewManagerInitServiceContext::ConfigureIncomingConnection( |
| + ApplicationConnection* connection) { |
| + if (!root_node_manager_.get()) { |
| + root_node_manager_.reset(new RootNodeManager( |
| + connection, |
| + this, |
| + base::Bind(&ViewManagerInitServiceContext::OnNativeViewportDeleted, |
| + base::Unretained(this)))); |
| + } |
| +} |
| + |
| +void ViewManagerInitServiceContext::OnNativeViewportDeleted() { |
| + for (Connections::const_iterator it = connections_.begin(); |
| + it != connections_.end(); ++it) { |
| + (*it)->OnNativeViewportDeleted(); |
| + } |
| +} |
| + |
| +void ViewManagerInitServiceContext::OnRootViewManagerWindowTreeHostCreated() { |
| + DCHECK(!is_tree_host_ready_); |
| + is_tree_host_ready_ = true; |
| + for (Connections::const_iterator it = connections_.begin(); |
| + it != connections_.end(); ++it) { |
| + (*it)->OnRootViewManagerWindowTreeHostCreated(); |
|
sky
2014/07/24 16:43:28
The ordering here feels very fragile. In so far as
|
| + } |
| +} |
| + |
| +} // namespace service |
| +} // namespace view_manager |
| +} // namespace mojo |