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 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 | 46 |
47 // Returns the Node with the specified id. | 47 // Returns the Node with the specified id. |
48 Node* GetNode(const NodeId& id); | 48 Node* GetNode(const NodeId& id); |
49 | 49 |
50 // Returns the View with the specified id. | 50 // Returns the View with the specified id. |
51 View* GetView(const ViewId& id); | 51 View* GetView(const ViewId& id); |
52 | 52 |
53 // The following methods are invoked after the corresponding change has been | 53 // The following methods are invoked after the corresponding change has been |
54 // processed. They do the appropriate bookkeeping and update the client as | 54 // processed. They do the appropriate bookkeeping and update the client as |
55 // necessary. | 55 // necessary. |
56 // TODO(sky): convert these to take Node*s. | 56 void ProcessNodeHierarchyChanged(const Node* node, |
57 void ProcessNodeHierarchyChanged(const NodeId& node_id, | 57 const Node* new_parent, |
58 const NodeId& new_parent_id, | 58 const Node* old_parent, |
59 const NodeId& old_parent_id, | |
60 TransportChangeId server_change_id, | 59 TransportChangeId server_change_id, |
61 bool originated_change); | 60 bool originated_change); |
62 void ProcessNodeViewReplaced(const NodeId& node, | 61 void ProcessNodeViewReplaced(const Node* node, |
63 const ViewId& new_view_id, | 62 const View* new_view, |
64 const ViewId& old_view_id, | 63 const View* old_view, |
65 bool originated_change); | 64 bool originated_change); |
66 void ProcessNodeDeleted(const NodeId& node, | 65 void ProcessNodeDeleted(const NodeId& node, |
67 TransportChangeId server_change_id, | 66 TransportChangeId server_change_id, |
68 bool originated_change); | 67 bool originated_change); |
69 void ProcessViewDeleted(const ViewId& view, bool originated_change); | 68 void ProcessViewDeleted(const ViewId& view, bool originated_change); |
70 | 69 |
71 private: | 70 private: |
72 typedef std::map<TransportConnectionSpecificNodeId, Node*> NodeMap; | 71 typedef std::map<TransportConnectionSpecificNodeId, Node*> NodeMap; |
73 typedef std::map<TransportConnectionSpecificViewId, View*> ViewMap; | 72 typedef std::map<TransportConnectionSpecificViewId, View*> ViewMap; |
74 typedef base::hash_set<TransportNodeId> NodeIdSet; | 73 typedef base::hash_set<TransportNodeId> NodeIdSet; |
75 | 74 |
76 // Deletes a node owned by this connection. Returns true on success. |source| | 75 // Deletes a node owned by this connection. Returns true on success. |source| |
77 // is the connection that originated the change. | 76 // is the connection that originated the change. |
78 bool DeleteNodeImpl(ViewManagerConnection* source, const NodeId& node_id); | 77 bool DeleteNodeImpl(ViewManagerConnection* source, const NodeId& node_id); |
79 | 78 |
80 // Deletes a view owned by this connection. Returns true on success. |source| | 79 // Deletes a view owned by this connection. Returns true on success. |source| |
81 // is the connection that originated the change. | 80 // is the connection that originated the change. |
82 bool DeleteViewImpl(ViewManagerConnection* source, const ViewId& view_id); | 81 bool DeleteViewImpl(ViewManagerConnection* source, const ViewId& view_id); |
83 | 82 |
84 // Sets the view associated with a node. | 83 // Sets the view associated with a node. |
85 bool SetViewImpl(const NodeId& node_id, const ViewId& view_id); | 84 bool SetViewImpl(const NodeId& node_id, const ViewId& view_id); |
86 | 85 |
87 // If |node| is known (in |known_nodes_|) does nothing. Otherwise adds |node| | 86 // If |node| is known (in |known_nodes_|) does nothing. Otherwise adds |node| |
88 // to |nodes|, marks |node| as known and recurses. | 87 // to |nodes|, marks |node| as known and recurses. |
89 void GetUnknownNodesFrom(Node* node, std::vector<Node*>* nodes); | 88 void GetUnknownNodesFrom(const Node* node, std::vector<const Node*>* nodes); |
90 | 89 |
91 // Returns true if notification should be sent of a hierarchy change. If true | 90 // Returns true if notification should be sent of a hierarchy change. If true |
92 // is returned, any nodes that need to be sent to the client are added to | 91 // is returned, any nodes that need to be sent to the client are added to |
93 // |to_send|. | 92 // |to_send|. |
94 bool ShouldNotifyOnHierarchyChange(const NodeId& node_id, | 93 bool ShouldNotifyOnHierarchyChange(const Node* node_id, |
95 const NodeId& new_parent_id, | 94 const Node* new_parent_id, |
96 const NodeId& old_parent_id, | 95 const Node* old_parent_id, |
97 std::vector<Node*>* to_send); | 96 std::vector<const Node*>* to_send); |
98 | 97 |
99 // Overridden from IViewManager: | 98 // Overridden from IViewManager: |
100 virtual void CreateNode(TransportNodeId transport_node_id, | 99 virtual void CreateNode(TransportNodeId transport_node_id, |
101 const Callback<void(bool)>& callback) OVERRIDE; | 100 const Callback<void(bool)>& callback) OVERRIDE; |
102 virtual void DeleteNode(TransportNodeId transport_node_id, | 101 virtual void DeleteNode(TransportNodeId transport_node_id, |
103 const Callback<void(bool)>& callback) OVERRIDE; | 102 const Callback<void(bool)>& callback) OVERRIDE; |
104 virtual void AddNode(TransportNodeId parent_id, | 103 virtual void AddNode(TransportNodeId parent_id, |
105 TransportNodeId child_id, | 104 TransportNodeId child_id, |
106 TransportChangeId server_change_id, | 105 TransportChangeId server_change_id, |
107 const Callback<void(bool)>& callback) OVERRIDE; | 106 const Callback<void(bool)>& callback) OVERRIDE; |
108 virtual void RemoveNodeFromParent( | 107 virtual void RemoveNodeFromParent( |
109 TransportNodeId node_id, | 108 TransportNodeId node_id, |
110 TransportChangeId server_change_id, | 109 TransportChangeId server_change_id, |
111 const Callback<void(bool)>& callback) OVERRIDE; | 110 const Callback<void(bool)>& callback) OVERRIDE; |
112 virtual void GetNodeTree( | 111 virtual void GetNodeTree( |
113 TransportNodeId node_id, | 112 TransportNodeId node_id, |
114 const Callback<void(Array<INode>)>& callback) OVERRIDE; | 113 const Callback<void(Array<INode>)>& callback) OVERRIDE; |
115 virtual void CreateView(TransportViewId transport_view_id, | 114 virtual void CreateView(TransportViewId transport_view_id, |
116 const Callback<void(bool)>& callback) OVERRIDE; | 115 const Callback<void(bool)>& callback) OVERRIDE; |
117 virtual void DeleteView(TransportViewId transport_view_id, | 116 virtual void DeleteView(TransportViewId transport_view_id, |
118 const Callback<void(bool)>& callback) OVERRIDE; | 117 const Callback<void(bool)>& callback) OVERRIDE; |
119 virtual void SetView(TransportNodeId transport_node_id, | 118 virtual void SetView(TransportNodeId transport_node_id, |
120 TransportViewId transport_view_id, | 119 TransportViewId transport_view_id, |
121 const Callback<void(bool)>& callback) OVERRIDE; | 120 const Callback<void(bool)>& callback) OVERRIDE; |
122 virtual void SetViewContents(TransportViewId view_id, | 121 virtual void SetViewContents(TransportViewId view_id, |
123 ScopedSharedBufferHandle buffer, | 122 ScopedSharedBufferHandle buffer, |
124 uint32_t buffer_size) OVERRIDE; | 123 uint32_t buffer_size) OVERRIDE; |
125 | 124 |
126 // Overridden from NodeDelegate: | 125 // Overridden from NodeDelegate: |
127 virtual void OnNodeHierarchyChanged(const NodeId& node, | 126 virtual void OnNodeHierarchyChanged(const Node* node, |
128 const NodeId& new_parent, | 127 const Node* new_parent, |
129 const NodeId& old_parent) OVERRIDE; | 128 const Node* old_parent) OVERRIDE; |
130 virtual void OnNodeViewReplaced(const NodeId& node, | 129 virtual void OnNodeViewReplaced(const Node* node, |
131 const ViewId& new_view_id, | 130 const View* new_view, |
132 const ViewId& old_view_id) OVERRIDE; | 131 const View* old_view) OVERRIDE; |
133 | 132 |
134 RootNodeManager* root_node_manager_; | 133 RootNodeManager* root_node_manager_; |
135 | 134 |
136 // Id of this connection as assigned by RootNodeManager. Assigned in | 135 // Id of this connection as assigned by RootNodeManager. Assigned in |
137 // OnConnectionEstablished(). | 136 // OnConnectionEstablished(). |
138 TransportConnectionId id_; | 137 TransportConnectionId id_; |
139 | 138 |
140 NodeMap node_map_; | 139 NodeMap node_map_; |
141 | 140 |
142 ViewMap view_map_; | 141 ViewMap view_map_; |
143 | 142 |
144 // The set of nodes that has been communicated to the client. | 143 // The set of nodes that has been communicated to the client. |
145 NodeIdSet known_nodes_; | 144 NodeIdSet known_nodes_; |
146 | 145 |
147 DISALLOW_COPY_AND_ASSIGN(ViewManagerConnection); | 146 DISALLOW_COPY_AND_ASSIGN(ViewManagerConnection); |
148 }; | 147 }; |
149 | 148 |
150 #if defined(OS_WIN) | 149 #if defined(OS_WIN) |
151 #pragma warning(pop) | 150 #pragma warning(pop) |
152 #endif | 151 #endif |
153 | 152 |
154 } // namespace service | 153 } // namespace service |
155 } // namespace view_manager | 154 } // namespace view_manager |
156 } // namespace mojo | 155 } // namespace mojo |
157 | 156 |
158 #endif // MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_CONNECTION_H_ | 157 #endif // MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_CONNECTION_H_ |
OLD | NEW |