OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "mojo/services/view_manager/root_node_manager.h" | 5 #include "mojo/services/view_manager/root_node_manager.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" | 8 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" |
9 #include "mojo/services/view_manager/view.h" | 9 #include "mojo/services/view_manager/view.h" |
10 #include "mojo/services/view_manager/view_manager_connection.h" | 10 #include "mojo/services/view_manager/view_manager_connection.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 connection_map_.erase(connection->id()); | 71 connection_map_.erase(connection->id()); |
72 connections_created_by_connect_.erase(connection); | 72 connections_created_by_connect_.erase(connection); |
73 | 73 |
74 // Notify remaining connections so that they can cleanup. | 74 // Notify remaining connections so that they can cleanup. |
75 for (ConnectionMap::const_iterator i = connection_map_.begin(); | 75 for (ConnectionMap::const_iterator i = connection_map_.begin(); |
76 i != connection_map_.end(); ++i) { | 76 i != connection_map_.end(); ++i) { |
77 i->second->OnViewManagerConnectionDestroyed(connection->id()); | 77 i->second->OnViewManagerConnectionDestroyed(connection->id()); |
78 } | 78 } |
79 } | 79 } |
80 | 80 |
81 void RootNodeManager::InitialConnect(const std::string& url) { | 81 void RootNodeManager::EmbedRoot(const std::string& url) { |
82 CHECK(connection_map_.empty()); | 82 CHECK(connection_map_.empty()); |
83 Array<Id> roots(0); | 83 Array<Id> roots(0); |
84 ConnectImpl(kRootConnection, String::From(url), roots); | 84 EmbedImpl(kRootConnection, String::From(url), roots); |
85 } | 85 } |
86 | 86 |
87 void RootNodeManager::Connect(ConnectionSpecificId creator_id, | 87 void RootNodeManager::Embed(ConnectionSpecificId creator_id, |
88 const String& url, | 88 const String& url, |
89 const Array<Id>& node_ids) { | 89 const Array<Id>& node_ids) { |
90 CHECK_GT(node_ids.size(), 0u); | 90 CHECK_GT(node_ids.size(), 0u); |
91 ConnectImpl(creator_id, url, node_ids)->set_delete_on_connection_error(); | 91 EmbedImpl(creator_id, url, node_ids)->set_delete_on_connection_error(); |
92 } | 92 } |
93 | 93 |
94 ViewManagerConnection* RootNodeManager::GetConnection( | 94 ViewManagerConnection* RootNodeManager::GetConnection( |
95 ConnectionSpecificId connection_id) { | 95 ConnectionSpecificId connection_id) { |
96 ConnectionMap::iterator i = connection_map_.find(connection_id); | 96 ConnectionMap::iterator i = connection_map_.find(connection_id); |
97 return i == connection_map_.end() ? NULL : i->second; | 97 return i == connection_map_.end() ? NULL : i->second; |
98 } | 98 } |
99 | 99 |
100 Node* RootNodeManager::GetNode(const NodeId& id) { | 100 Node* RootNodeManager::GetNode(const NodeId& id) { |
101 if (id == root_.id()) | 101 if (id == root_.id()) |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 } | 183 } |
184 | 184 |
185 void RootNodeManager::FinishChange() { | 185 void RootNodeManager::FinishChange() { |
186 // PrepareForChange/FinishChange should be balanced. | 186 // PrepareForChange/FinishChange should be balanced. |
187 CHECK(current_change_); | 187 CHECK(current_change_); |
188 if (current_change_->change_type() == CHANGE_TYPE_ADVANCE_SERVER_CHANGE_ID) | 188 if (current_change_->change_type() == CHANGE_TYPE_ADVANCE_SERVER_CHANGE_ID) |
189 next_server_change_id_++; | 189 next_server_change_id_++; |
190 current_change_ = NULL; | 190 current_change_ = NULL; |
191 } | 191 } |
192 | 192 |
193 ViewManagerConnection* RootNodeManager::ConnectImpl( | 193 ViewManagerConnection* RootNodeManager::EmbedImpl( |
194 const ConnectionSpecificId creator_id, | 194 const ConnectionSpecificId creator_id, |
195 const String& url, | 195 const String& url, |
196 const Array<Id>& node_ids) { | 196 const Array<Id>& node_ids) { |
197 MessagePipe pipe; | 197 MessagePipe pipe; |
198 service_provider_->ConnectToService( | 198 service_provider_->ConnectToService( |
199 url, | 199 url, |
200 ViewManagerConnection::Client::Name_, | 200 ViewManagerConnection::Client::Name_, |
201 pipe.handle1.Pass(), | 201 pipe.handle1.Pass(), |
202 String()); | 202 String()); |
203 ViewManagerConnection* connection = | 203 ViewManagerConnection* connection = |
(...skipping 18 matching lines...) Expand all Loading... |
222 } | 222 } |
223 | 223 |
224 void RootNodeManager::OnViewInputEvent(const View* view, | 224 void RootNodeManager::OnViewInputEvent(const View* view, |
225 const ui::Event* event) { | 225 const ui::Event* event) { |
226 GetConnection(view->id().connection_id)->ProcessViewInputEvent(view, event); | 226 GetConnection(view->id().connection_id)->ProcessViewInputEvent(view, event); |
227 } | 227 } |
228 | 228 |
229 } // namespace service | 229 } // namespace service |
230 } // namespace view_manager | 230 } // namespace view_manager |
231 } // namespace mojo | 231 } // namespace mojo |
OLD | NEW |