1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
|
// 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_connection.h"
#include "base/stl_util.h"
#include "mojo/geometry/geometry_type_converters.h"
#include "mojo/public/cpp/bindings/allocation_scope.h"
#include "mojo/services/view_manager/node.h"
#include "mojo/services/view_manager/root_node_manager.h"
#include "mojo/services/view_manager/view.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/aura/window.h"
#include "ui/gfx/codec/png_codec.h"
namespace mojo {
namespace view_manager {
namespace service {
namespace {
// Places |node| in |nodes| and recurses through the children.
void GetDescendants(const Node* node, std::vector<const Node*>* nodes) {
if (!node)
return;
nodes->push_back(node);
std::vector<const Node*> children(node->GetChildren());
for (size_t i = 0 ; i < children.size(); ++i)
GetDescendants(children[i], nodes);
}
} // namespace
ViewManagerConnection::ViewManagerConnection(RootNodeManager* root_node_manager)
: root_node_manager_(root_node_manager),
id_(0) {
}
ViewManagerConnection::~ViewManagerConnection() {
// Delete any views we own.
while (!view_map_.empty()) {
bool result = DeleteViewImpl(this, view_map_.begin()->second->id());
DCHECK(result);
}
// We're about to destroy all our nodes. Detach any views from them.
for (NodeMap::iterator i = node_map_.begin(); i != node_map_.end(); ++i) {
if (i->second->view()) {
bool result = SetViewImpl(i->second, ViewId());
DCHECK(result);
}
}
if (!node_map_.empty()) {
RootNodeManager::ScopedChange change(
this, root_node_manager_,
RootNodeManager::CHANGE_TYPE_ADVANCE_SERVER_CHANGE_ID, true);
while (!node_map_.empty()) {
Node* node = node_map_.begin()->second;
Node* parent = node->GetParent();
const NodeId node_id(node->id());
if (parent)
parent->Remove(node);
root_node_manager_->ProcessNodeDeleted(node_id);
node_map_.erase(NodeIdToTransportId(node_id));
}
}
root_node_manager_->RemoveConnection(this);
}
const Node* ViewManagerConnection::GetNode(const NodeId& id) const {
if (id_ == id.connection_id) {
NodeMap::const_iterator i = node_map_.find(id.node_id);
return i == node_map_.end() ? NULL : i->second;
}
return root_node_manager_->GetNode(id);
}
const View* ViewManagerConnection::GetView(const ViewId& id) const {
if (id_ == id.connection_id) {
ViewMap::const_iterator i = view_map_.find(id.view_id);
return i == view_map_.end() ? NULL : i->second;
}
return root_node_manager_->GetView(id);
}
void ViewManagerConnection::ProcessNodeBoundsChanged(
const Node* node,
const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds,
bool originated_change) {
if (originated_change)
return;
TransportNodeId node_id = NodeIdToTransportId(node->id());
if (known_nodes_.count(node_id) > 0) {
AllocationScope scope;
client()->OnNodeBoundsChanged(node_id, old_bounds, new_bounds);
}
}
void ViewManagerConnection::ProcessNodeHierarchyChanged(
const Node* node,
const Node* new_parent,
const Node* old_parent,
TransportChangeId server_change_id,
bool originated_change) {
if (known_nodes_.count(NodeIdToTransportId(node->id())) > 0) {
if (originated_change)
return;
if (node->id().connection_id != id_ && !IsNodeDescendantOfRoots(node)) {
// Node was a descendant of roots and is no longer, treat it as though the
// node was deleted.
RemoveFromKnown(node);
client()->OnNodeDeleted(NodeIdToTransportId(node->id()),
server_change_id);
return;
}
}
if (originated_change || root_node_manager_->is_processing_delete_node())
return;
std::vector<const Node*> to_send;
if (!ShouldNotifyOnHierarchyChange(node, &new_parent, &old_parent,
&to_send)) {
if (root_node_manager_->IsProcessingChange()) {
client()->OnServerChangeIdAdvanced(
root_node_manager_->next_server_change_id() + 1);
}
return;
}
AllocationScope allocation_scope;
const NodeId new_parent_id(new_parent ? new_parent->id() : NodeId());
const NodeId old_parent_id(old_parent ? old_parent->id() : NodeId());
DCHECK((node->id().connection_id == id_) ||
(roots_.count(NodeIdToTransportId(node->id())) > 0) ||
(new_parent && IsNodeDescendantOfRoots(new_parent)) ||
(old_parent && IsNodeDescendantOfRoots(old_parent)));
client()->OnNodeHierarchyChanged(NodeIdToTransportId(node->id()),
NodeIdToTransportId(new_parent_id),
NodeIdToTransportId(old_parent_id),
server_change_id,
NodesToINodes(to_send));
}
void ViewManagerConnection::ProcessNodeViewReplaced(
const Node* node,
const View* new_view,
const View* old_view,
bool originated_change) {
if (originated_change || !known_nodes_.count(NodeIdToTransportId(node->id())))
return;
const TransportViewId new_view_id = new_view ?
ViewIdToTransportId(new_view->id()) : 0;
const TransportViewId old_view_id = old_view ?
ViewIdToTransportId(old_view->id()) : 0;
client()->OnNodeViewReplaced(NodeIdToTransportId(node->id()),
new_view_id, old_view_id);
}
void ViewManagerConnection::ProcessNodeDeleted(
const NodeId& node,
TransportChangeId server_change_id,
bool originated_change) {
const bool in_known = known_nodes_.erase(NodeIdToTransportId(node)) > 0;
const bool in_roots = roots_.erase(NodeIdToTransportId(node)) > 0;
if (in_roots && roots_.empty())
roots_.insert(NodeIdToTransportId(InvalidNodeId()));
if (originated_change)
return;
if (in_known) {
client()->OnNodeDeleted(NodeIdToTransportId(node), server_change_id);
} else if (root_node_manager_->IsProcessingChange()) {
client()->OnServerChangeIdAdvanced(
root_node_manager_->next_server_change_id() + 1);
}
}
void ViewManagerConnection::ProcessViewDeleted(const ViewId& view,
bool originated_change) {
if (originated_change)
return;
client()->OnViewDeleted(ViewIdToTransportId(view));
}
bool ViewManagerConnection::CanRemoveNodeFromParent(const Node* node) const {
if (!node)
return false;
const Node* parent = node->GetParent();
if (!parent)
return false;
// Always allow the remove if there are no roots. Otherwise the remove is
// allowed if the parent is a descendant of the roots, or the node and its
// parent were created by this connection. We explicitly disallow removal of
// the node from its parent if the parent isn't visible to this connection
// (not in roots).
return (roots_.empty() ||
(IsNodeDescendantOfRoots(parent) ||
(node->id().connection_id == id_ &&
parent->id().connection_id == id_)));
}
bool ViewManagerConnection::CanAddNode(const Node* parent,
const Node* child) const {
if (!parent || !child)
return false; // Both nodes must be valid.
if (child->GetParent() == parent || child->Contains(parent))
return false; // Would result in an invalid hierarchy.
if (roots_.empty())
return true; // No restriction if there are no roots.
if (!IsNodeDescendantOfRoots(parent) && parent->id().connection_id != id_)
return false; // |parent| is not visible to this connection.
// Allow the add if the child is already a descendant of the roots or was
// created by this connection.
return (IsNodeDescendantOfRoots(child) || child->id().connection_id == id_);
}
bool ViewManagerConnection::CanDeleteNode(const NodeId& node_id) const {
return node_id.connection_id == id_;
}
bool ViewManagerConnection::CanDeleteView(const ViewId& view_id) const {
return view_id.connection_id == id_;
}
bool ViewManagerConnection::CanSetView(const Node* node,
const ViewId& view_id) const {
if (!node || !IsNodeDescendantOfRoots(node))
return false;
const View* view = GetView(view_id);
return (view && view_id.connection_id == id_) || view_id == ViewId();
}
bool ViewManagerConnection::CanGetNodeTree(const Node* node) const {
return node &&
(IsNodeDescendantOfRoots(node) || node->id().connection_id == id_);
}
bool ViewManagerConnection::DeleteNodeImpl(ViewManagerConnection* source,
const NodeId& node_id) {
DCHECK_EQ(node_id.connection_id, id_);
Node* node = GetNode(node_id);
if (!node)
return false;
RootNodeManager::ScopedChange change(
source, root_node_manager_,
RootNodeManager::CHANGE_TYPE_ADVANCE_SERVER_CHANGE_ID, true);
if (node->GetParent())
node->GetParent()->Remove(node);
std::vector<Node*> children(node->GetChildren());
for (size_t i = 0; i < children.size(); ++i)
node->Remove(children[i]);
DCHECK(node->GetChildren().empty());
node_map_.erase(node_id.node_id);
delete node;
node = NULL;
root_node_manager_->ProcessNodeDeleted(node_id);
return true;
}
bool ViewManagerConnection::DeleteViewImpl(ViewManagerConnection* source,
const ViewId& view_id) {
DCHECK_EQ(view_id.connection_id, id_);
View* view = GetView(view_id);
if (!view)
return false;
RootNodeManager::ScopedChange change(
source, root_node_manager_,
RootNodeManager::CHANGE_TYPE_DONT_ADVANCE_SERVER_CHANGE_ID, false);
if (view->node())
view->node()->SetView(NULL);
view_map_.erase(view_id.view_id);
// Make a copy of |view_id| as once we delete view |view_id| may no longer be
// valid.
const ViewId view_id_copy(view_id);
delete view;
root_node_manager_->ProcessViewDeleted(view_id_copy);
return true;
}
bool ViewManagerConnection::SetViewImpl(Node* node, const ViewId& view_id) {
DCHECK(node); // CanSetView() should have verified node exists.
View* view = GetView(view_id);
RootNodeManager::ScopedChange change(
this, root_node_manager_,
RootNodeManager::CHANGE_TYPE_DONT_ADVANCE_SERVER_CHANGE_ID, false);
node->SetView(view);
return true;
}
void ViewManagerConnection::GetUnknownNodesFrom(
const Node* node,
std::vector<const Node*>* nodes) {
const TransportNodeId transport_id = NodeIdToTransportId(node->id());
if (known_nodes_.count(transport_id) == 1)
return;
nodes->push_back(node);
known_nodes_.insert(transport_id);
std::vector<const Node*> children(node->GetChildren());
for (size_t i = 0 ; i < children.size(); ++i)
GetUnknownNodesFrom(children[i], nodes);
}
void ViewManagerConnection::RemoveFromKnown(const Node* node) {
if (node->id().connection_id == id_)
return;
known_nodes_.erase(NodeIdToTransportId(node->id()));
std::vector<const Node*> children = node->GetChildren();
for (size_t i = 0; i < children.size(); ++i)
RemoveFromKnown(children[i]);
}
bool ViewManagerConnection::IsNodeDescendantOfRoots(const Node* node) const {
if (roots_.empty())
return true;
if (!node)
return false;
const TransportNodeId invalid_node_id =
NodeIdToTransportId(InvalidNodeId());
for (NodeIdSet::const_iterator i = roots_.begin(); i != roots_.end(); ++i) {
if (*i == invalid_node_id)
continue;
const Node* root = GetNode(NodeIdFromTransportId(*i));
DCHECK(root);
if (root->Contains(node))
return true;
}
return false;
}
bool ViewManagerConnection::ShouldNotifyOnHierarchyChange(
const Node* node,
const Node** new_parent,
const Node** old_parent,
std::vector<const Node*>* to_send) {
// If the node is not in |roots_| or was never known to this connection then
// don't notify the client about it.
if (node->id().connection_id != id_ &&
known_nodes_.count(NodeIdToTransportId(node->id())) == 0 &&
!IsNodeDescendantOfRoots(node)) {
return false;
}
if (!IsNodeDescendantOfRoots(*new_parent))
*new_parent = NULL;
if (!IsNodeDescendantOfRoots(*old_parent))
*old_parent = NULL;
if (*new_parent) {
// On getting a new parent we may need to communicate new nodes to the
// client. We do that in the following cases:
// . New parent is a descendant of the roots. In this case the client
// already knows all ancestors, so we only have to communicate descendants
// of node the client doesn't know about.
// . If the client knew about the parent, we have to do the same.
// . If the client knows about the node and is added to a tree the client
// doesn't know about we have to communicate from the root down (the
// client is learning about a new root).
if (root_node_manager_->root()->Contains(*new_parent) ||
known_nodes_.count(NodeIdToTransportId((*new_parent)->id()))) {
GetUnknownNodesFrom(node, to_send);
return true;
}
// If parent wasn't known we have to communicate from the root down.
if (known_nodes_.count(NodeIdToTransportId(node->id()))) {
// No need to check against |roots_| as client should always know it's
// |roots_|.
GetUnknownNodesFrom((*new_parent)->GetRoot(), to_send);
return true;
}
}
// Otherwise only communicate the change if the node was known. We shouldn't
// need to communicate any nodes on a remove.
return known_nodes_.count(NodeIdToTransportId(node->id())) > 0;
}
bool ViewManagerConnection::ProcessSetRoots(
TransportConnectionId source_connection_id,
const Array<TransportNodeId>& transport_node_ids) {
// TODO(sky): these DCHECKs can go away once this is part of a real API. Also
// make sure that when roots are set nodes are communicate to client. Code in
// ProcessNodeHierarchyChanged() is depending on this.
DCHECK(node_map_.empty());
DCHECK(view_map_.empty());
NodeIdSet roots;
for (size_t i = 0; i < transport_node_ids.size(); ++i) {
const Node* node = GetNode(NodeIdFromTransportId(transport_node_ids[i]));
// Only allow setting roots that are owned by the source connection.
if (!node || node->id().connection_id != source_connection_id)
return false;
roots.insert(transport_node_ids[i]);
}
roots_.swap(roots);
// TODO(sky): remove |known_nodes_.clear()| temporary while this is done here
// instead of at creation time.
known_nodes_.clear();
std::vector<const Node*> to_send;
for (NodeIdSet::const_iterator i = roots_.begin(); i != roots_.end(); ++i)
GetUnknownNodesFrom(GetNode(NodeIdFromTransportId(*i)), &to_send);
AllocationScope allocation_scope;
client()->OnViewManagerConnectionEstablished(
id_,
root_node_manager_->next_server_change_id(),
NodesToINodes(to_send));
return true;
}
Array<INode> ViewManagerConnection::NodesToINodes(
const std::vector<const Node*>& nodes) {
Array<INode>::Builder array_builder(nodes.size());
for (size_t i = 0; i < nodes.size(); ++i) {
INode::Builder node_builder;
const Node* node = nodes[i];
DCHECK(known_nodes_.count(NodeIdToTransportId(node->id())) > 0);
const Node* parent = node->GetParent();
// If the parent isn't known, it means the parent is not visible to us (not
// in roots), and should not be sent over.
if (parent && known_nodes_.count(NodeIdToTransportId(parent->id())) == 0)
parent = NULL;
node_builder.set_parent_id(NodeIdToTransportId(
parent ? parent->id() : NodeId()));
node_builder.set_node_id(NodeIdToTransportId(node->id()));
node_builder.set_view_id(ViewIdToTransportId(
node->view() ? node->view()->id() : ViewId()));
node_builder.set_bounds(node->bounds());
array_builder[i] = node_builder.Finish();
}
return array_builder.Finish();
}
void ViewManagerConnection::CreateNode(
TransportNodeId transport_node_id,
const Callback<void(bool)>& callback) {
const NodeId node_id(NodeIdFromTransportId(transport_node_id));
if (node_id.connection_id != id_ ||
node_map_.find(node_id.node_id) != node_map_.end()) {
callback.Run(false);
return;
}
node_map_[node_id.node_id] = new Node(this, node_id);
known_nodes_.insert(transport_node_id);
callback.Run(true);
}
void ViewManagerConnection::DeleteNode(
TransportNodeId transport_node_id,
const Callback<void(bool)>& callback) {
AllocationScope allocation_scope;
const NodeId node_id(NodeIdFromTransportId(transport_node_id));
bool did_delete = CanDeleteNode(node_id);
if (did_delete) {
ViewManagerConnection* connection = root_node_manager_->GetConnection(
node_id.connection_id);
did_delete = connection && connection->DeleteNodeImpl(this, node_id);
}
callback.Run(did_delete);
}
void ViewManagerConnection::AddNode(
TransportNodeId parent_id,
TransportNodeId child_id,
TransportChangeId server_change_id,
const Callback<void(bool)>& callback) {
bool success = false;
if (server_change_id == root_node_manager_->next_server_change_id()) {
Node* parent = GetNode(NodeIdFromTransportId(parent_id));
Node* child = GetNode(NodeIdFromTransportId(child_id));
if (CanAddNode(parent, child)) {
success = true;
RootNodeManager::ScopedChange change(
this, root_node_manager_,
RootNodeManager::CHANGE_TYPE_ADVANCE_SERVER_CHANGE_ID, false);
parent->Add(child);
}
}
callback.Run(success);
}
void ViewManagerConnection::RemoveNodeFromParent(
TransportNodeId node_id,
TransportChangeId server_change_id,
const Callback<void(bool)>& callback) {
bool success = false;
if (server_change_id == root_node_manager_->next_server_change_id()) {
Node* node = GetNode(NodeIdFromTransportId(node_id));
if (CanRemoveNodeFromParent(node)) {
success = true;
RootNodeManager::ScopedChange change(
this, root_node_manager_,
RootNodeManager::CHANGE_TYPE_ADVANCE_SERVER_CHANGE_ID, false);
node->GetParent()->Remove(node);
}
}
callback.Run(success);
}
void ViewManagerConnection::GetNodeTree(
TransportNodeId node_id,
const Callback<void(Array<INode>)>& callback) {
AllocationScope allocation_scope;
Node* node = GetNode(NodeIdFromTransportId(node_id));
std::vector<const Node*> nodes;
if (CanGetNodeTree(node)) {
GetDescendants(node, &nodes);
for (size_t i = 0; i < nodes.size(); ++i)
known_nodes_.insert(NodeIdToTransportId(nodes[i]->id()));
}
callback.Run(NodesToINodes(nodes));
}
void ViewManagerConnection::CreateView(
TransportViewId transport_view_id,
const Callback<void(bool)>& callback) {
const ViewId view_id(ViewIdFromTransportId(transport_view_id));
if (view_id.connection_id != id_ || view_map_.count(view_id.view_id)) {
callback.Run(false);
return;
}
view_map_[view_id.view_id] = new View(view_id);
callback.Run(true);
}
void ViewManagerConnection::DeleteView(
TransportViewId transport_view_id,
const Callback<void(bool)>& callback) {
const ViewId view_id(ViewIdFromTransportId(transport_view_id));
bool did_delete = CanDeleteView(view_id);
if (did_delete) {
ViewManagerConnection* connection = root_node_manager_->GetConnection(
view_id.connection_id);
did_delete = (connection && connection->DeleteViewImpl(this, view_id));
}
callback.Run(did_delete);
}
void ViewManagerConnection::SetView(
TransportNodeId transport_node_id,
TransportViewId transport_view_id,
const Callback<void(bool)>& callback) {
Node* node = GetNode(NodeIdFromTransportId(transport_node_id));
const ViewId view_id(ViewIdFromTransportId(transport_view_id));
callback.Run(CanSetView(node, view_id) && SetViewImpl(node, view_id));
}
void ViewManagerConnection::SetViewContents(
TransportViewId view_id,
ScopedSharedBufferHandle buffer,
uint32_t buffer_size,
const Callback<void(bool)>& callback) {
View* view = GetView(ViewIdFromTransportId(view_id));
if (!view) {
callback.Run(false);
return;
}
void* handle_data;
if (MapBuffer(buffer.get(), 0, buffer_size, &handle_data,
MOJO_MAP_BUFFER_FLAG_NONE) != MOJO_RESULT_OK) {
callback.Run(false);
return;
}
SkBitmap bitmap;
gfx::PNGCodec::Decode(static_cast<const unsigned char*>(handle_data),
buffer_size, &bitmap);
view->SetBitmap(bitmap);
UnmapBuffer(handle_data);
callback.Run(true);
}
void ViewManagerConnection::SetRoots(
TransportConnectionId connection_id,
const Array<TransportNodeId>& transport_node_ids,
const Callback<void(bool)>& callback) {
ViewManagerConnection* connection =
root_node_manager_->GetConnection(connection_id);
callback.Run(connection &&
connection->ProcessSetRoots(id_, transport_node_ids));
}
void ViewManagerConnection::SetNodeBounds(
TransportNodeId node_id,
const Rect& bounds,
const Callback<void(bool)>& callback) {
if (NodeIdFromTransportId(node_id).connection_id != id_) {
callback.Run(false);
return;
}
Node* node = GetNode(NodeIdFromTransportId(node_id));
if (!node) {
callback.Run(false);
return;
}
RootNodeManager::ScopedChange change(
this, root_node_manager_,
RootNodeManager::CHANGE_TYPE_DONT_ADVANCE_SERVER_CHANGE_ID, false);
gfx::Rect old_bounds = node->window()->bounds();
node->window()->SetBounds(bounds);
root_node_manager_->ProcessNodeBoundsChanged(node, old_bounds, bounds);
callback.Run(true);
}
void ViewManagerConnection::OnNodeHierarchyChanged(const Node* node,
const Node* new_parent,
const Node* old_parent) {
root_node_manager_->ProcessNodeHierarchyChanged(node, new_parent, old_parent);
}
void ViewManagerConnection::OnNodeViewReplaced(const Node* node,
const View* new_view,
const View* old_view) {
root_node_manager_->ProcessNodeViewReplaced(node, new_view, old_view);
}
void ViewManagerConnection::OnConnectionEstablished() {
DCHECK_EQ(0, id_); // Should only get OnConnectionEstablished() once.
id_ = root_node_manager_->GetAndAdvanceNextConnectionId();
root_node_manager_->AddConnection(this);
std::vector<const Node*> to_send;
GetUnknownNodesFrom(root_node_manager_->root(), &to_send);
AllocationScope allocation_scope;
client()->OnViewManagerConnectionEstablished(
id_,
root_node_manager_->next_server_change_id(),
NodesToINodes(to_send));
}
} // namespace service
} // namespace view_manager
} // namespace mojo
|