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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 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.
4
5 #include "mojo/services/view_manager/view_manager_init_service_context.h"
6
7 #include "base/bind.h"
8 #include "mojo/services/view_manager/root_node_manager.h"
9 #include "mojo/services/view_manager/view_manager_init_service_impl.h"
10
11 namespace mojo {
12 namespace view_manager {
13 namespace service {
14
15 ViewManagerInitServiceContext::ViewManagerInitServiceContext()
16 : is_tree_host_ready_(false) {}
17 ViewManagerInitServiceContext::~ViewManagerInitServiceContext() {}
18
19 void ViewManagerInitServiceContext::AddConnection(
20 ViewManagerInitServiceImpl* connection) {
21 DCHECK(std::find(connections_.begin(), connections_.end(), connection) ==
22 connections_.end());
23 connections_.push_back(connection);
24 }
25
26 void ViewManagerInitServiceContext::RemoveConnection(
27 ViewManagerInitServiceImpl* connection) {
28 Connections::iterator it =
29 std::find(connections_.begin(), connections_.end(), connection);
30 DCHECK(it != connections_.end());
31 connections_.erase(it);
32
33 // This object is owned by an object that outlives the current thread's
34 // message loop, so we need to destroy the RootNodeManager earlier, as it may
35 // attempt to post tasks during its destruction.
36 if (connections_.empty())
37 root_node_manager_.reset();
38 }
39
40 void ViewManagerInitServiceContext::ConfigureIncomingConnection(
41 ApplicationConnection* connection) {
42 if (!root_node_manager_.get()) {
43 root_node_manager_.reset(new RootNodeManager(
44 connection,
45 this,
46 base::Bind(&ViewManagerInitServiceContext::OnNativeViewportDeleted,
47 base::Unretained(this))));
48 }
49 }
50
51 void ViewManagerInitServiceContext::OnNativeViewportDeleted() {
52 for (Connections::const_iterator it = connections_.begin();
53 it != connections_.end(); ++it) {
54 (*it)->OnNativeViewportDeleted();
55 }
56 }
57
58 void ViewManagerInitServiceContext::OnRootViewManagerWindowTreeHostCreated() {
59 DCHECK(!is_tree_host_ready_);
60 is_tree_host_ready_ = true;
61 for (Connections::const_iterator it = connections_.begin();
62 it != connections_.end(); ++it) {
63 (*it)->OnRootViewManagerWindowTreeHostCreated();
64 }
65 }
66
67 } // namespace service
68 } // namespace view_manager
69 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698