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 #ifndef MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_CONNECTION_H_ | 5 #ifndef MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_CONNECTION_H_ |
6 #define MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_CONNECTION_H_ | 6 #define MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_CONNECTION_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "mojo/public/cpp/shell/service.h" | 11 #include "mojo/public/cpp/shell/service.h" |
12 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h" | 12 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h" |
13 #include "mojo/services/view_manager/ids.h" | |
14 #include "mojo/services/view_manager/node_delegate.h" | 13 #include "mojo/services/view_manager/node_delegate.h" |
15 #include "mojo/services/view_manager/view_manager_export.h" | 14 #include "mojo/services/view_manager/view_manager_export.h" |
16 | 15 |
17 namespace mojo { | 16 namespace mojo { |
18 namespace services { | 17 namespace services { |
19 namespace view_manager { | 18 namespace view_manager { |
20 | 19 |
21 class Node; | 20 class Node; |
22 class RootNodeManager; | 21 class RootNodeManager; |
23 class View; | 22 class View; |
(...skipping 17 matching lines...) Expand all Loading... |
41 // Returns the Node with the specified id. | 40 // Returns the Node with the specified id. |
42 Node* GetNode(const NodeId& id); | 41 Node* GetNode(const NodeId& id); |
43 | 42 |
44 // Returns the View with the specified id. | 43 // Returns the View with the specified id. |
45 View* GetView(const ViewId& id); | 44 View* GetView(const ViewId& id); |
46 | 45 |
47 // Notifies the client of a hierarchy change. | 46 // Notifies the client of a hierarchy change. |
48 void NotifyNodeHierarchyChanged(const NodeId& node, | 47 void NotifyNodeHierarchyChanged(const NodeId& node, |
49 const NodeId& new_parent, | 48 const NodeId& new_parent, |
50 const NodeId& old_parent, | 49 const NodeId& old_parent, |
51 ChangeId change_id); | 50 int32_t change_id); |
52 void NotifyNodeViewReplaced(const NodeId& node, | 51 void NotifyNodeViewReplaced(const NodeId& node, |
53 const ViewId& new_view_id, | 52 const ViewId& new_view_id, |
54 const ViewId& old_view_id, | 53 const ViewId& old_view_id, |
55 ChangeId change_id); | 54 int32_t change_id); |
56 | 55 |
57 private: | 56 private: |
58 typedef std::map<uint16_t, Node*> NodeMap; | 57 typedef std::map<uint16_t, Node*> NodeMap; |
59 typedef std::map<uint16_t, View*> ViewMap; | 58 typedef std::map<uint16_t, View*> ViewMap; |
60 | 59 |
61 // Deletes a node owned by this connection. Returns true on success. |source| | 60 // Deletes a node owned by this connection. Returns true on success. |source| |
62 // is the connection that originated the change. | 61 // is the connection that originated the change. |
63 bool DeleteNodeImpl(ViewManagerConnection* source, | 62 bool DeleteNodeImpl(ViewManagerConnection* source, |
64 const NodeId& node_id, | 63 const NodeId& node_id, |
65 ChangeId change_id); | 64 int32_t change_id); |
66 | 65 |
67 // Deletes a view owned by this connection. Returns true on success. |source| | 66 // Deletes a view owned by this connection. Returns true on success. |source| |
68 // is the connection that originated the change. | 67 // is the connection that originated the change. |
69 bool DeleteViewImpl(ViewManagerConnection* source, | 68 bool DeleteViewImpl(ViewManagerConnection* source, |
70 const ViewId& view_id, | 69 const ViewId& view_id, |
71 ChangeId change_id); | 70 int32_t change_id); |
72 | 71 |
73 // Sets the view associated with a node. | 72 // Sets the view associated with a node. |
74 bool SetViewImpl(const NodeId& node_id, | 73 bool SetViewImpl(const NodeId& node_id, |
75 const ViewId& view_id, | 74 const ViewId& view_id, |
76 ChangeId change_id); | 75 int32_t change_id); |
77 | 76 |
78 // Overridden from ViewManager: | 77 // Overridden from ViewManager: |
79 virtual void CreateNode(uint16_t node_id, | 78 virtual void CreateNode(uint16_t node_id, |
80 const Callback<void(bool)>& callback) OVERRIDE; | 79 const Callback<void(bool)>& callback) OVERRIDE; |
81 virtual void DeleteNode(uint32_t transport_node_id, | 80 virtual void DeleteNode(uint32_t transport_node_id, |
82 ChangeId change_id, | 81 int32_t change_id, |
83 const mojo::Callback<void(bool)>& callback) OVERRIDE; | 82 const mojo::Callback<void(bool)>& callback) OVERRIDE; |
84 virtual void AddNode(uint32_t parent_id, | 83 virtual void AddNode(uint32_t parent_id, |
85 uint32_t child_id, | 84 uint32_t child_id, |
86 ChangeId change_id, | 85 int32_t change_id, |
87 const Callback<void(bool)>& callback) OVERRIDE; | 86 const Callback<void(bool)>& callback) OVERRIDE; |
88 virtual void RemoveNodeFromParent( | 87 virtual void RemoveNodeFromParent( |
89 uint32_t node_id, | 88 uint32_t node_id, |
90 ChangeId change_id, | 89 int32_t change_id, |
91 const Callback<void(bool)>& callback) OVERRIDE; | 90 const Callback<void(bool)>& callback) OVERRIDE; |
92 virtual void CreateView(uint16_t view_id, | 91 virtual void CreateView(uint16_t view_id, |
93 const mojo::Callback<void(bool)>& callback) OVERRIDE; | 92 const mojo::Callback<void(bool)>& callback) OVERRIDE; |
94 virtual void DeleteView(uint32_t transport_view_id, | 93 virtual void DeleteView(uint32_t transport_view_id, |
95 ChangeId change_id, | 94 int32_t change_id, |
96 const mojo::Callback<void(bool)>& callback) OVERRIDE; | 95 const mojo::Callback<void(bool)>& callback) OVERRIDE; |
97 virtual void SetView(uint32_t transport_node_id, | 96 virtual void SetView(uint32_t transport_node_id, |
98 uint32_t transport_view_id, | 97 uint32_t transport_view_id, |
99 ChangeId change_id, | 98 int32_t change_id, |
100 const mojo::Callback<void(bool)>& callback) OVERRIDE; | 99 const mojo::Callback<void(bool)>& callback) OVERRIDE; |
101 | 100 |
102 // Overriden from NodeDelegate: | 101 // Overriden from NodeDelegate: |
103 virtual void OnNodeHierarchyChanged(const NodeId& node, | 102 virtual void OnNodeHierarchyChanged(const NodeId& node, |
104 const NodeId& new_parent, | 103 const NodeId& new_parent, |
105 const NodeId& old_parent) OVERRIDE; | 104 const NodeId& old_parent) OVERRIDE; |
106 virtual void OnNodeViewReplaced(const NodeId& node, | 105 virtual void OnNodeViewReplaced(const NodeId& node, |
107 const ViewId& new_view_id, | 106 const ViewId& new_view_id, |
108 const ViewId& old_view_id) OVERRIDE; | 107 const ViewId& old_view_id) OVERRIDE; |
109 | 108 |
110 // Id of this connection as assigned by RootNodeManager. Assigned in | 109 // Id of this connection as assigned by RootNodeManager. Assigned in |
111 // Initialize(). | 110 // Initialize(). |
112 uint16_t id_; | 111 uint16_t id_; |
113 | 112 |
114 NodeMap node_map_; | 113 NodeMap node_map_; |
115 | 114 |
116 ViewMap view_map_; | 115 ViewMap view_map_; |
117 | 116 |
118 DISALLOW_COPY_AND_ASSIGN(ViewManagerConnection); | 117 DISALLOW_COPY_AND_ASSIGN(ViewManagerConnection); |
119 }; | 118 }; |
120 | 119 |
121 } // namespace view_manager | 120 } // namespace view_manager |
122 } // namespace services | 121 } // namespace services |
123 } // namespace mojo | 122 } // namespace mojo |
124 | 123 |
125 #endif // MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_CONNECTION_H_ | 124 #endif // MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_CONNECTION_H_ |
OLD | NEW |