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

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

Issue 307003004: Fixes bug where IViewManagerClient could be messaged unnecessarily (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup 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_manager_connection.h" 9 #include "mojo/services/view_manager/view_manager_connection.h"
10 #include "ui/aura/env.h" 10 #include "ui/aura/env.h"
11 11
12 namespace mojo { 12 namespace mojo {
13 namespace view_manager { 13 namespace view_manager {
14 namespace service { 14 namespace service {
15 15
16 RootNodeManager::ScopedChange::ScopedChange( 16 RootNodeManager::ScopedChange::ScopedChange(
17 ViewManagerConnection* connection, 17 ViewManagerConnection* connection,
18 RootNodeManager* root, 18 RootNodeManager* root,
19 RootNodeManager::ChangeType change_type, 19 RootNodeManager::ChangeType change_type,
20 bool is_delete_node) 20 bool is_delete_node)
21 : root_(root), 21 : root_(root),
22 change_type_(change_type) { 22 connection_id_(connection->id()),
23 root_->PrepareForChange(connection, is_delete_node); 23 change_type_(change_type),
24 is_delete_node_(is_delete_node) {
25 root_->PrepareForChange(this);
24 } 26 }
25 27
26 RootNodeManager::ScopedChange::~ScopedChange() { 28 RootNodeManager::ScopedChange::~ScopedChange() {
27 root_->FinishChange(change_type_); 29 root_->FinishChange();
28 } 30 }
29 31
30 RootNodeManager::Context::Context() { 32 RootNodeManager::Context::Context() {
31 // Pass in false as native viewport creates the PlatformEventSource. 33 // Pass in false as native viewport creates the PlatformEventSource.
32 aura::Env::CreateInstance(false); 34 aura::Env::CreateInstance(false);
33 } 35 }
34 36
35 RootNodeManager::Context::~Context() { 37 RootNodeManager::Context::~Context() {
36 aura::Env::DeleteInstance(); 38 aura::Env::DeleteInstance();
37 } 39 }
38 40
39 RootNodeManager::RootNodeManager(ServiceProvider* service_provider, 41 RootNodeManager::RootNodeManager(ServiceProvider* service_provider,
40 RootViewManagerDelegate* view_manager_delegate) 42 RootViewManagerDelegate* view_manager_delegate)
41 : service_provider_(service_provider), 43 : service_provider_(service_provider),
42 next_connection_id_(1), 44 next_connection_id_(1),
43 next_server_change_id_(1), 45 next_server_change_id_(1),
44 change_source_(kRootConnection),
45 is_processing_delete_node_(false),
46 root_view_manager_(service_provider, this, view_manager_delegate), 46 root_view_manager_(service_provider, this, view_manager_delegate),
47 root_(this, RootNodeId()) { 47 root_(this, RootNodeId()),
48 current_change_(NULL) {
48 } 49 }
49 50
50 RootNodeManager::~RootNodeManager() { 51 RootNodeManager::~RootNodeManager() {
51 while (!connections_created_by_connect_.empty()) 52 while (!connections_created_by_connect_.empty())
52 delete *(connections_created_by_connect_.begin()); 53 delete *(connections_created_by_connect_.begin());
53 // All the connections should have been destroyed. 54 // All the connections should have been destroyed.
54 DCHECK(connection_map_.empty()); 55 DCHECK(connection_map_.empty());
55 } 56 }
56 57
57 TransportConnectionId RootNodeManager::GetAndAdvanceNextConnectionId() { 58 TransportConnectionId RootNodeManager::GetAndAdvanceNextConnectionId() {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 return &root_; 94 return &root_;
94 ConnectionMap::iterator i = connection_map_.find(id.connection_id); 95 ConnectionMap::iterator i = connection_map_.find(id.connection_id);
95 return i == connection_map_.end() ? NULL : i->second->GetNode(id); 96 return i == connection_map_.end() ? NULL : i->second->GetNode(id);
96 } 97 }
97 98
98 View* RootNodeManager::GetView(const ViewId& id) { 99 View* RootNodeManager::GetView(const ViewId& id) {
99 ConnectionMap::iterator i = connection_map_.find(id.connection_id); 100 ConnectionMap::iterator i = connection_map_.find(id.connection_id);
100 return i == connection_map_.end() ? NULL : i->second->GetView(id); 101 return i == connection_map_.end() ? NULL : i->second->GetView(id);
101 } 102 }
102 103
104 void RootNodeManager::OnConnectionMessagedClient(TransportConnectionId id) {
105 if (current_change_)
106 current_change_->MarkConnectionAsMessaged(id);
107 }
108
109 bool RootNodeManager::DidConnectionMessageClient(
110 TransportConnectionId id) const {
111 return current_change_ && current_change_->DidMessageConnection(id);
112 }
113
103 void RootNodeManager::ProcessNodeBoundsChanged(const Node* node, 114 void RootNodeManager::ProcessNodeBoundsChanged(const Node* node,
104 const gfx::Rect& old_bounds, 115 const gfx::Rect& old_bounds,
105 const gfx::Rect& new_bounds) { 116 const gfx::Rect& new_bounds) {
106 for (ConnectionMap::iterator i = connection_map_.begin(); 117 for (ConnectionMap::iterator i = connection_map_.begin();
107 i != connection_map_.end(); ++i) { 118 i != connection_map_.end(); ++i) {
108 i->second->ProcessNodeBoundsChanged(node, old_bounds, new_bounds, 119 i->second->ProcessNodeBoundsChanged(node, old_bounds, new_bounds,
109 IsChangeSource(i->first)); 120 IsChangeSource(i->first));
110 } 121 }
111 } 122 }
112 123
(...skipping 26 matching lines...) Expand all
139 } 150 }
140 } 151 }
141 152
142 void RootNodeManager::ProcessViewDeleted(const ViewId& view) { 153 void RootNodeManager::ProcessViewDeleted(const ViewId& view) {
143 for (ConnectionMap::iterator i = connection_map_.begin(); 154 for (ConnectionMap::iterator i = connection_map_.begin();
144 i != connection_map_.end(); ++i) { 155 i != connection_map_.end(); ++i) {
145 i->second->ProcessViewDeleted(view, IsChangeSource(i->first)); 156 i->second->ProcessViewDeleted(view, IsChangeSource(i->first));
146 } 157 }
147 } 158 }
148 159
149 void RootNodeManager::PrepareForChange(ViewManagerConnection* connection, 160 void RootNodeManager::PrepareForChange(ScopedChange* change) {
150 bool is_delete_node) {
151 // Should only ever have one change in flight. 161 // Should only ever have one change in flight.
152 DCHECK_EQ(kRootConnection, change_source_); 162 CHECK(!current_change_);
153 change_source_ = connection->id(); 163 current_change_ = change;
154 is_processing_delete_node_ = is_delete_node;
155 } 164 }
156 165
157 void RootNodeManager::FinishChange(ChangeType change_type) { 166 void RootNodeManager::FinishChange() {
158 // PrepareForChange/FinishChange should be balanced. 167 // PrepareForChange/FinishChange should be balanced.
159 DCHECK_NE(kRootConnection, change_source_); 168 CHECK(current_change_);
160 change_source_ = 0; 169 if (current_change_->change_type() == CHANGE_TYPE_ADVANCE_SERVER_CHANGE_ID)
161 is_processing_delete_node_ = false;
162 if (change_type == CHANGE_TYPE_ADVANCE_SERVER_CHANGE_ID)
163 next_server_change_id_++; 170 next_server_change_id_++;
171 current_change_ = NULL;
164 } 172 }
165 173
166 ViewManagerConnection* RootNodeManager::ConnectImpl( 174 ViewManagerConnection* RootNodeManager::ConnectImpl(
167 const String& url, 175 const String& url,
168 const Array<TransportNodeId>& node_ids) { 176 const Array<TransportNodeId>& node_ids) {
169 MessagePipe pipe; 177 MessagePipe pipe;
170 service_provider_->ConnectToService(url, pipe.handle1.Pass()); 178 service_provider_->ConnectToService(url, pipe.handle1.Pass());
171 ViewManagerConnection* connection = new ViewManagerConnection(this); 179 ViewManagerConnection* connection = new ViewManagerConnection(this);
172 connection->SetRoots(node_ids); 180 connection->SetRoots(node_ids);
173 BindToPipe(connection, pipe.handle0.Pass()); 181 BindToPipe(connection, pipe.handle0.Pass());
(...skipping 10 matching lines...) Expand all
184 192
185 void RootNodeManager::OnNodeViewReplaced(const Node* node, 193 void RootNodeManager::OnNodeViewReplaced(const Node* node,
186 const View* new_view, 194 const View* new_view,
187 const View* old_view) { 195 const View* old_view) {
188 ProcessNodeViewReplaced(node, new_view, old_view); 196 ProcessNodeViewReplaced(node, new_view, old_view);
189 } 197 }
190 198
191 } // namespace service 199 } // namespace service
192 } // namespace view_manager 200 } // namespace view_manager
193 } // namespace mojo 201 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/view_manager/root_node_manager.h ('k') | mojo/services/view_manager/view_manager_connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698