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/public/cpp/view_manager/lib/view_manager_synchronizer.h" | 5 #include "mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "mojo/public/cpp/shell/connect.h" | 9 #include "mojo/public/cpp/shell/connect.h" |
10 #include "mojo/public/interfaces/shell/shell.mojom.h" | 10 #include "mojo/public/interfaces/shell/shell.mojom.h" |
11 #include "mojo/services/public/cpp/view_manager/lib/view_manager_private.h" | 11 #include "mojo/services/public/cpp/view_manager/lib/view_manager_private.h" |
12 #include "mojo/services/public/cpp/view_manager/lib/view_private.h" | 12 #include "mojo/services/public/cpp/view_manager/lib/view_private.h" |
13 #include "mojo/services/public/cpp/view_manager/lib/view_tree_node_private.h" | 13 #include "mojo/services/public/cpp/view_manager/lib/view_tree_node_private.h" |
14 #include "mojo/services/public/cpp/view_manager/util.h" | 14 #include "mojo/services/public/cpp/view_manager/util.h" |
15 | 15 |
16 namespace mojo { | 16 namespace mojo { |
17 namespace view_manager { | 17 namespace view_manager { |
18 | 18 |
19 uint32_t MakeTransportId(uint16_t connection_id, uint16_t local_id) { | 19 uint32_t MakeTransportId(uint16_t connection_id, uint16_t local_id) { |
20 return (connection_id << 16) | local_id; | 20 return (connection_id << 16) | local_id; |
21 } | 21 } |
22 | 22 |
23 // Helper called to construct a local node/view object from transport data. | 23 // Helper called to construct a local node/view object from transport data. |
24 ViewTreeNode* AddNodeToViewManager(ViewManager* manager, | 24 ViewTreeNode* AddNodeToViewManager(ViewManager* manager, |
25 ViewTreeNode* parent, | 25 ViewTreeNode* parent, |
26 TransportNodeId node_id, | 26 TransportNodeId node_id, |
27 TransportViewId view_id) { | 27 TransportViewId view_id, |
| 28 const gfx::Rect& bounds) { |
28 // We don't use the ctor that takes a ViewManager here, since it will call | 29 // We don't use the ctor that takes a ViewManager here, since it will call |
29 // back to the service and attempt to create a new node. | 30 // back to the service and attempt to create a new node. |
30 ViewTreeNode* node = ViewTreeNodePrivate::LocalCreate(); | 31 ViewTreeNode* node = ViewTreeNodePrivate::LocalCreate(); |
31 ViewTreeNodePrivate private_node(node); | 32 ViewTreeNodePrivate private_node(node); |
32 private_node.set_view_manager(manager); | 33 private_node.set_view_manager(manager); |
33 private_node.set_id(node_id); | 34 private_node.set_id(node_id); |
| 35 private_node.LocalSetBounds(gfx::Rect(), bounds); |
34 if (parent) | 36 if (parent) |
35 ViewTreeNodePrivate(parent).LocalAddChild(node); | 37 ViewTreeNodePrivate(parent).LocalAddChild(node); |
36 ViewManagerPrivate private_manager(manager); | 38 ViewManagerPrivate private_manager(manager); |
37 private_manager.AddNode(node->id(), node); | 39 private_manager.AddNode(node->id(), node); |
38 | 40 |
39 // View. | 41 // View. |
40 if (view_id != 0) { | 42 if (view_id != 0) { |
41 View* view = ViewPrivate::LocalCreate(); | 43 View* view = ViewPrivate::LocalCreate(); |
42 ViewPrivate private_view(view); | 44 ViewPrivate private_view(view); |
43 private_view.set_view_manager(manager); | 45 private_view.set_view_manager(manager); |
(...skipping 16 matching lines...) Expand all Loading... |
60 if (last_node && nodes[i].parent_id() == last_node->id()) { | 62 if (last_node && nodes[i].parent_id() == last_node->id()) { |
61 parents.push_back(last_node); | 63 parents.push_back(last_node); |
62 } else if (!parents.empty()) { | 64 } else if (!parents.empty()) { |
63 while (parents.back()->id() != nodes[i].parent_id()) | 65 while (parents.back()->id() != nodes[i].parent_id()) |
64 parents.pop_back(); | 66 parents.pop_back(); |
65 } | 67 } |
66 ViewTreeNode* node = AddNodeToViewManager( | 68 ViewTreeNode* node = AddNodeToViewManager( |
67 manager, | 69 manager, |
68 !parents.empty() ? parents.back() : NULL, | 70 !parents.empty() ? parents.back() : NULL, |
69 nodes[i].node_id(), | 71 nodes[i].node_id(), |
70 nodes[i].view_id()); | 72 nodes[i].view_id(), |
| 73 nodes[i].bounds()); |
71 if (!last_node) | 74 if (!last_node) |
72 root = node; | 75 root = node; |
73 last_node = node; | 76 last_node = node; |
74 } | 77 } |
75 return root; | 78 return root; |
76 } | 79 } |
77 | 80 |
78 class ViewManagerTransaction { | 81 class ViewManagerTransaction { |
79 public: | 82 public: |
80 virtual ~ViewManagerTransaction() {} | 83 virtual ~ViewManagerTransaction() {} |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 void ViewManagerSynchronizer::RemoveFromPendingQueue( | 542 void ViewManagerSynchronizer::RemoveFromPendingQueue( |
540 ViewManagerTransaction* transaction) { | 543 ViewManagerTransaction* transaction) { |
541 DCHECK_EQ(transaction, pending_transactions_.front()); | 544 DCHECK_EQ(transaction, pending_transactions_.front()); |
542 pending_transactions_.erase(pending_transactions_.begin()); | 545 pending_transactions_.erase(pending_transactions_.begin()); |
543 if (pending_transactions_.empty() && !changes_acked_callback_.is_null()) | 546 if (pending_transactions_.empty() && !changes_acked_callback_.is_null()) |
544 changes_acked_callback_.Run(); | 547 changes_acked_callback_.Run(); |
545 } | 548 } |
546 | 549 |
547 } // namespace view_manager | 550 } // namespace view_manager |
548 } // namespace mojo | 551 } // namespace mojo |
OLD | NEW |