Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1643)

Unified Diff: mojo/services/view_manager/view_manager_init_service_context.cc

Issue 400113005: A new WM bootstrap flow (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..d0a6fdc830cb2e0f49a77755136d2ae6740aaef0
--- /dev/null
+++ b/mojo/services/view_manager/view_manager_init_service_context.cc
@@ -0,0 +1,69 @@
+// 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(std::find(connections_.begin(), connections_.end(), connection) ==
+ connections_.end());
+ connections_.push_back(connection);
+}
+
+void ViewManagerInitServiceContext::RemoveConnection(
+ ViewManagerInitServiceImpl* connection) {
+ Connections::iterator it =
+ std::find(connections_.begin(), connections_.end(), connection);
+ DCHECK(it != connections_.end());
+ connections_.erase(it);
+
+ // This object is owned by an object that outlives the current thread's
+ // message loop, so we need to destroy the RootNodeManager earlier, as it may
+ // attempt to post tasks during its destruction.
+ if (connections_.empty())
+ root_node_manager_.reset();
+}
+
+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();
+ }
+}
+
+} // namespace service
+} // namespace view_manager
+} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698