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 25 matching lines...) Expand all Loading... |
36 #endif | 36 #endif |
37 | 37 |
38 // Manages a connection from the client. | 38 // Manages a connection from the client. |
39 class MOJO_VIEW_MANAGER_EXPORT ViewManagerConnection | 39 class MOJO_VIEW_MANAGER_EXPORT ViewManagerConnection |
40 : public InterfaceImpl<IViewManager>, | 40 : public InterfaceImpl<IViewManager>, |
41 public NodeDelegate { | 41 public NodeDelegate { |
42 public: | 42 public: |
43 explicit ViewManagerConnection(RootNodeManager* root_node_manager); | 43 explicit ViewManagerConnection(RootNodeManager* root_node_manager); |
44 virtual ~ViewManagerConnection(); | 44 virtual ~ViewManagerConnection(); |
45 | 45 |
| 46 // Used to mark this connection as originating from a call to |
| 47 // IViewManager::Connect(). When set OnConnectionError() deletes |this|. |
| 48 void set_delete_on_connection_error() { delete_on_connection_error_ = true; } |
| 49 |
46 TransportConnectionId id() const { return id_; } | 50 TransportConnectionId id() const { return id_; } |
47 | 51 |
48 // Returns the Node with the specified id. | 52 // Returns the Node with the specified id. |
49 Node* GetNode(const NodeId& id) { | 53 Node* GetNode(const NodeId& id) { |
50 return const_cast<Node*>( | 54 return const_cast<Node*>( |
51 const_cast<const ViewManagerConnection*>(this)->GetNode(id)); | 55 const_cast<const ViewManagerConnection*>(this)->GetNode(id)); |
52 } | 56 } |
53 const Node* GetNode(const NodeId& id) const; | 57 const Node* GetNode(const NodeId& id) const; |
54 | 58 |
55 // Returns the View with the specified id. | 59 // Returns the View with the specified id. |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 const Node* old_parent) OVERRIDE; | 182 const Node* old_parent) OVERRIDE; |
179 virtual void OnNodeViewReplaced(const Node* node, | 183 virtual void OnNodeViewReplaced(const Node* node, |
180 const View* new_view, | 184 const View* new_view, |
181 const View* old_view) OVERRIDE; | 185 const View* old_view) OVERRIDE; |
182 | 186 |
183 // InterfaceImp overrides: | 187 // InterfaceImp overrides: |
184 virtual void OnConnectionEstablished() MOJO_OVERRIDE; | 188 virtual void OnConnectionEstablished() MOJO_OVERRIDE; |
185 | 189 |
186 RootNodeManager* root_node_manager_; | 190 RootNodeManager* root_node_manager_; |
187 | 191 |
188 // Id of this connection as assigned by RootNodeManager. Assigned in | 192 // Id of this connection as assigned by RootNodeManager. |
189 // OnConnectionEstablished(). | 193 const TransportConnectionId id_; |
190 TransportConnectionId id_; | |
191 | 194 |
192 NodeMap node_map_; | 195 NodeMap node_map_; |
193 | 196 |
194 ViewMap view_map_; | 197 ViewMap view_map_; |
195 | 198 |
196 // The set of nodes that has been communicated to the client. | 199 // The set of nodes that has been communicated to the client. |
197 NodeIdSet known_nodes_; | 200 NodeIdSet known_nodes_; |
198 | 201 |
199 // This is the set of nodes the connection can parent nodes to (in addition to | 202 // This is the set of nodes the connection can parent nodes to (in addition to |
200 // any nodes created by this connection). If empty the connection can | 203 // any nodes created by this connection). If empty the connection can |
201 // manipulate any nodes (except for deleting other connections nodes/views). | 204 // manipulate any nodes (except for deleting other connections nodes/views). |
202 // The connection can not delete or move these. If this is set to a non-empty | 205 // The connection can not delete or move these. If this is set to a non-empty |
203 // value and all the nodes are deleted (by another connection), then an | 206 // value and all the nodes are deleted (by another connection), then an |
204 // invalid node is added here to ensure this connection is still constrained. | 207 // invalid node is added here to ensure this connection is still constrained. |
205 NodeIdSet roots_; | 208 NodeIdSet roots_; |
206 | 209 |
| 210 // See description above setter. |
| 211 bool delete_on_connection_error_; |
| 212 |
207 DISALLOW_COPY_AND_ASSIGN(ViewManagerConnection); | 213 DISALLOW_COPY_AND_ASSIGN(ViewManagerConnection); |
208 }; | 214 }; |
209 | 215 |
210 #if defined(OS_WIN) | 216 #if defined(OS_WIN) |
211 #pragma warning(pop) | 217 #pragma warning(pop) |
212 #endif | 218 #endif |
213 | 219 |
214 } // namespace service | 220 } // namespace service |
215 } // namespace view_manager | 221 } // namespace view_manager |
216 } // namespace mojo | 222 } // namespace mojo |
217 | 223 |
218 #endif // MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_CONNECTION_H_ | 224 #endif // MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_CONNECTION_H_ |
OLD | NEW |