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

Side by Side Diff: mojo/services/view_manager/root_node_manager.cc

Issue 320193002: Consolidates view_manager typedefs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: formatting Created 6 years, 6 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
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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 current_change_(NULL) { 49 current_change_(NULL) {
50 } 50 }
51 51
52 RootNodeManager::~RootNodeManager() { 52 RootNodeManager::~RootNodeManager() {
53 while (!connections_created_by_connect_.empty()) 53 while (!connections_created_by_connect_.empty())
54 delete *(connections_created_by_connect_.begin()); 54 delete *(connections_created_by_connect_.begin());
55 // All the connections should have been destroyed. 55 // All the connections should have been destroyed.
56 DCHECK(connection_map_.empty()); 56 DCHECK(connection_map_.empty());
57 } 57 }
58 58
59 TransportConnectionId RootNodeManager::GetAndAdvanceNextConnectionId() { 59 ConnectionSpecificId RootNodeManager::GetAndAdvanceNextConnectionId() {
60 const TransportConnectionId id = next_connection_id_++; 60 const ConnectionSpecificId id = next_connection_id_++;
61 DCHECK_LT(id, next_connection_id_); 61 DCHECK_LT(id, next_connection_id_);
62 return id; 62 return id;
63 } 63 }
64 64
65 void RootNodeManager::AddConnection(ViewManagerConnection* connection) { 65 void RootNodeManager::AddConnection(ViewManagerConnection* connection) {
66 DCHECK_EQ(0u, connection_map_.count(connection->id())); 66 DCHECK_EQ(0u, connection_map_.count(connection->id()));
67 connection_map_[connection->id()] = connection; 67 connection_map_[connection->id()] = connection;
68 } 68 }
69 69
70 void RootNodeManager::RemoveConnection(ViewManagerConnection* connection) { 70 void RootNodeManager::RemoveConnection(ViewManagerConnection* connection) {
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::InitialConnect(const std::string& url) {
82 CHECK(connection_map_.empty()); 82 CHECK(connection_map_.empty());
83 Array<TransportNodeId> roots(0); 83 Array<Id> roots(0);
84 ConnectImpl(kRootConnection, String::From(url), roots); 84 ConnectImpl(kRootConnection, String::From(url), roots);
85 } 85 }
86 86
87 void RootNodeManager::Connect(TransportConnectionId creator_id, 87 void RootNodeManager::Connect(ConnectionSpecificId creator_id,
88 const String& url, 88 const String& url,
89 const Array<TransportNodeId>& 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 ConnectImpl(creator_id, url, node_ids)->set_delete_on_connection_error();
92 } 92 }
93 93
94 ViewManagerConnection* RootNodeManager::GetConnection( 94 ViewManagerConnection* RootNodeManager::GetConnection(
95 TransportConnectionId 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())
102 return &root_; 102 return &root_;
103 ConnectionMap::iterator i = connection_map_.find(id.connection_id); 103 ConnectionMap::iterator i = connection_map_.find(id.connection_id);
104 return i == connection_map_.end() ? NULL : i->second->GetNode(id); 104 return i == connection_map_.end() ? NULL : i->second->GetNode(id);
105 } 105 }
106 106
107 View* RootNodeManager::GetView(const ViewId& id) { 107 View* RootNodeManager::GetView(const ViewId& id) {
108 ConnectionMap::iterator i = connection_map_.find(id.connection_id); 108 ConnectionMap::iterator i = connection_map_.find(id.connection_id);
109 return i == connection_map_.end() ? NULL : i->second->GetView(id); 109 return i == connection_map_.end() ? NULL : i->second->GetView(id);
110 } 110 }
111 111
112 void RootNodeManager::OnConnectionMessagedClient(TransportConnectionId id) { 112 void RootNodeManager::OnConnectionMessagedClient(ConnectionSpecificId id) {
113 if (current_change_) 113 if (current_change_)
114 current_change_->MarkConnectionAsMessaged(id); 114 current_change_->MarkConnectionAsMessaged(id);
115 } 115 }
116 116
117 bool RootNodeManager::DidConnectionMessageClient( 117 bool RootNodeManager::DidConnectionMessageClient(
118 TransportConnectionId id) const { 118 ConnectionSpecificId id) const {
119 return current_change_ && current_change_->DidMessageConnection(id); 119 return current_change_ && current_change_->DidMessageConnection(id);
120 } 120 }
121 121
122 ViewManagerConnection* RootNodeManager::GetConnectionByCreator( 122 ViewManagerConnection* RootNodeManager::GetConnectionByCreator(
123 TransportConnectionId creator_id, 123 ConnectionSpecificId creator_id,
124 const std::string& url) const { 124 const std::string& url) const {
125 for (ConnectionMap::const_iterator i = connection_map_.begin(); 125 for (ConnectionMap::const_iterator i = connection_map_.begin();
126 i != connection_map_.end(); ++i) { 126 i != connection_map_.end(); ++i) {
127 if (i->second->creator_id() == creator_id && i->second->url() == url) 127 if (i->second->creator_id() == creator_id && i->second->url() == url)
128 return i->second; 128 return i->second;
129 } 129 }
130 return NULL; 130 return NULL;
131 } 131 }
132 132
133 void RootNodeManager::ProcessNodeBoundsChanged(const Node* node, 133 void RootNodeManager::ProcessNodeBoundsChanged(const Node* node,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
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::ConnectImpl(
194 const TransportConnectionId creator_id, 194 const ConnectionSpecificId creator_id,
195 const String& url, 195 const String& url,
196 const Array<TransportNodeId>& 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 =
204 new ViewManagerConnection(this, creator_id, url.To<std::string>()); 204 new ViewManagerConnection(this, creator_id, url.To<std::string>());
205 connection->SetRoots(node_ids); 205 connection->SetRoots(node_ids);
206 BindToPipe(connection, pipe.handle0.Pass()); 206 BindToPipe(connection, pipe.handle0.Pass());
(...skipping 15 matching lines...) Expand all
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
OLDNEW
« no previous file with comments | « mojo/services/view_manager/root_node_manager.h ('k') | mojo/services/view_manager/test_change_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698