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 27 matching lines...) Expand all Loading... |
38 public: | 38 public: |
39 ViewManagerConnection(RootNodeManager* root_node_manager); | 39 ViewManagerConnection(RootNodeManager* root_node_manager); |
40 virtual ~ViewManagerConnection(); | 40 virtual ~ViewManagerConnection(); |
41 | 41 |
42 virtual void OnConnectionEstablished() MOJO_OVERRIDE; | 42 virtual void OnConnectionEstablished() MOJO_OVERRIDE; |
43 virtual void OnConnectionError() MOJO_OVERRIDE; | 43 virtual void OnConnectionError() MOJO_OVERRIDE; |
44 | 44 |
45 TransportConnectionId id() const { return id_; } | 45 TransportConnectionId id() const { return id_; } |
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 return const_cast<Node*>( |
| 50 const_cast<const ViewManagerConnection*>(this)->GetNode(id)); |
| 51 } |
| 52 const Node* GetNode(const NodeId& id) const; |
49 | 53 |
50 // Returns the View with the specified id. | 54 // Returns the View with the specified id. |
51 View* GetView(const ViewId& id); | 55 View* GetView(const ViewId& id); |
52 | 56 |
53 // The following methods are invoked after the corresponding change has been | 57 // The following methods are invoked after the corresponding change has been |
54 // processed. They do the appropriate bookkeeping and update the client as | 58 // processed. They do the appropriate bookkeeping and update the client as |
55 // necessary. | 59 // necessary. |
56 void ProcessNodeHierarchyChanged(const Node* node, | 60 void ProcessNodeHierarchyChanged(const Node* node, |
57 const Node* new_parent, | 61 const Node* new_parent, |
58 const Node* old_parent, | 62 const Node* old_parent, |
59 TransportChangeId server_change_id, | 63 TransportChangeId server_change_id, |
60 bool originated_change); | 64 bool originated_change); |
61 void ProcessNodeViewReplaced(const Node* node, | 65 void ProcessNodeViewReplaced(const Node* node, |
62 const View* new_view, | 66 const View* new_view, |
63 const View* old_view, | 67 const View* old_view, |
64 bool originated_change); | 68 bool originated_change); |
65 void ProcessNodeDeleted(const NodeId& node, | 69 void ProcessNodeDeleted(const NodeId& node, |
66 TransportChangeId server_change_id, | 70 TransportChangeId server_change_id, |
67 bool originated_change); | 71 bool originated_change); |
68 void ProcessViewDeleted(const ViewId& view, bool originated_change); | 72 void ProcessViewDeleted(const ViewId& view, bool originated_change); |
69 | 73 |
70 private: | 74 private: |
71 typedef std::map<TransportConnectionSpecificNodeId, Node*> NodeMap; | 75 typedef std::map<TransportConnectionSpecificNodeId, Node*> NodeMap; |
72 typedef std::map<TransportConnectionSpecificViewId, View*> ViewMap; | 76 typedef std::map<TransportConnectionSpecificViewId, View*> ViewMap; |
73 typedef base::hash_set<TransportNodeId> NodeIdSet; | 77 typedef base::hash_set<TransportNodeId> NodeIdSet; |
74 | 78 |
| 79 // Returns true if this connection is allowed to delete the specified node. |
| 80 bool CanDeleteNode(const NodeId& node_id) const; |
| 81 |
| 82 // Returns true if this connection is allowed to delete the specified view. |
| 83 bool CanDeleteView(const ViewId& view_id) const; |
| 84 |
75 // Deletes a node owned by this connection. Returns true on success. |source| | 85 // Deletes a node owned by this connection. Returns true on success. |source| |
76 // is the connection that originated the change. | 86 // is the connection that originated the change. |
77 bool DeleteNodeImpl(ViewManagerConnection* source, const NodeId& node_id); | 87 bool DeleteNodeImpl(ViewManagerConnection* source, const NodeId& node_id); |
78 | 88 |
79 // Deletes a view owned by this connection. Returns true on success. |source| | 89 // Deletes a view owned by this connection. Returns true on success. |source| |
80 // is the connection that originated the change. | 90 // is the connection that originated the change. |
81 bool DeleteViewImpl(ViewManagerConnection* source, const ViewId& view_id); | 91 bool DeleteViewImpl(ViewManagerConnection* source, const ViewId& view_id); |
82 | 92 |
83 // Sets the view associated with a node. | 93 // Sets the view associated with a node. |
84 bool SetViewImpl(const NodeId& node_id, const ViewId& view_id); | 94 bool SetViewImpl(const NodeId& node_id, const ViewId& view_id); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 | 158 |
149 #if defined(OS_WIN) | 159 #if defined(OS_WIN) |
150 #pragma warning(pop) | 160 #pragma warning(pop) |
151 #endif | 161 #endif |
152 | 162 |
153 } // namespace service | 163 } // namespace service |
154 } // namespace view_manager | 164 } // namespace view_manager |
155 } // namespace mojo | 165 } // namespace mojo |
156 | 166 |
157 #endif // MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_CONNECTION_H_ | 167 #endif // MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_CONNECTION_H_ |
OLD | NEW |