| 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_ROOT_NODE_MANAGER_H_ | 5 #ifndef MOJO_SERVICES_VIEW_MANAGER_ROOT_NODE_MANAGER_H_ |
| 6 #define MOJO_SERVICES_VIEW_MANAGER_ROOT_NODE_MANAGER_H_ | 6 #define MOJO_SERVICES_VIEW_MANAGER_ROOT_NODE_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "mojo/public/cpp/bindings/array.h" | 12 #include "mojo/public/cpp/bindings/array.h" |
| 13 #include "mojo/services/view_manager/ids.h" | 13 #include "mojo/services/view_manager/ids.h" |
| 14 #include "mojo/services/view_manager/node.h" | 14 #include "mojo/services/view_manager/node.h" |
| 15 #include "mojo/services/view_manager/node_delegate.h" | 15 #include "mojo/services/view_manager/node_delegate.h" |
| 16 #include "mojo/services/view_manager/root_view_manager.h" | 16 #include "mojo/services/view_manager/root_view_manager.h" |
| 17 #include "mojo/services/view_manager/view_manager_export.h" | 17 #include "mojo/services/view_manager/view_manager_export.h" |
| 18 | 18 |
| 19 namespace mojo { | 19 namespace mojo { |
| 20 | 20 |
| 21 class ServiceProvider; | 21 class ServiceProvider; |
| 22 | 22 |
| 23 namespace view_manager { | 23 namespace view_manager { |
| 24 namespace service { | 24 namespace service { |
| 25 | 25 |
| 26 class RootViewManagerDelegate; |
| 26 class View; | 27 class View; |
| 27 class ViewManagerConnection; | 28 class ViewManagerConnection; |
| 28 | 29 |
| 29 // RootNodeManager is responsible for managing the set of ViewManagerConnections | 30 // RootNodeManager is responsible for managing the set of ViewManagerConnections |
| 30 // as well as providing the root of the node hierarchy. | 31 // as well as providing the root of the node hierarchy. |
| 31 class MOJO_VIEW_MANAGER_EXPORT RootNodeManager : public NodeDelegate { | 32 class MOJO_VIEW_MANAGER_EXPORT RootNodeManager : public NodeDelegate { |
| 32 public: | 33 public: |
| 33 // Used to indicate if the server id should be incremented after notifiying | 34 // Used to indicate if the server id should be incremented after notifiying |
| 34 // clients of the change. | 35 // clients of the change. |
| 35 enum ChangeType { | 36 enum ChangeType { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 47 bool is_delete_node); | 48 bool is_delete_node); |
| 48 ~ScopedChange(); | 49 ~ScopedChange(); |
| 49 | 50 |
| 50 private: | 51 private: |
| 51 RootNodeManager* root_; | 52 RootNodeManager* root_; |
| 52 const ChangeType change_type_; | 53 const ChangeType change_type_; |
| 53 | 54 |
| 54 DISALLOW_COPY_AND_ASSIGN(ScopedChange); | 55 DISALLOW_COPY_AND_ASSIGN(ScopedChange); |
| 55 }; | 56 }; |
| 56 | 57 |
| 57 explicit RootNodeManager(ServiceProvider* service_provider); | 58 RootNodeManager(ServiceProvider* service_provider, |
| 59 RootViewManagerDelegate* view_manager_delegate); |
| 58 virtual ~RootNodeManager(); | 60 virtual ~RootNodeManager(); |
| 59 | 61 |
| 60 // Returns the id for the next ViewManagerConnection. | 62 // Returns the id for the next ViewManagerConnection. |
| 61 TransportConnectionId GetAndAdvanceNextConnectionId(); | 63 TransportConnectionId GetAndAdvanceNextConnectionId(); |
| 62 | 64 |
| 63 TransportChangeId next_server_change_id() const { | 65 TransportChangeId next_server_change_id() const { |
| 64 return next_server_change_id_; | 66 return next_server_change_id_; |
| 65 } | 67 } |
| 66 | 68 |
| 67 void AddConnection(ViewManagerConnection* connection); | 69 void AddConnection(ViewManagerConnection* connection); |
| 68 void RemoveConnection(ViewManagerConnection* connection); | 70 void RemoveConnection(ViewManagerConnection* connection); |
| 69 | 71 |
| 72 // Establishes the initial client. Similar to Connect(), but the resulting |
| 73 // client is allowed to do anything. |
| 74 void InitialConnect(const std::string& url); |
| 75 |
| 76 // See description of IViewManager::Connect() for details. This assumes |
| 77 // |node_ids| has been validated. |
| 70 void Connect(const String& url, const Array<TransportNodeId>& node_ids); | 78 void Connect(const String& url, const Array<TransportNodeId>& node_ids); |
| 71 | 79 |
| 72 // Returns the connection by id. | 80 // Returns the connection by id. |
| 73 ViewManagerConnection* GetConnection(TransportConnectionId connection_id); | 81 ViewManagerConnection* GetConnection(TransportConnectionId connection_id); |
| 74 | 82 |
| 75 // Returns the Node identified by |id|. | 83 // Returns the Node identified by |id|. |
| 76 Node* GetNode(const NodeId& id); | 84 Node* GetNode(const NodeId& id); |
| 77 | 85 |
| 78 // Returns the View identified by |id|. | 86 // Returns the View identified by |id|. |
| 79 View* GetView(const ViewId& id); | 87 View* GetView(const ViewId& id); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 void PrepareForChange(ViewManagerConnection* connection, bool is_delete_node); | 124 void PrepareForChange(ViewManagerConnection* connection, bool is_delete_node); |
| 117 | 125 |
| 118 // Balances a call to PrepareForChange(). | 126 // Balances a call to PrepareForChange(). |
| 119 void FinishChange(ChangeType change_type); | 127 void FinishChange(ChangeType change_type); |
| 120 | 128 |
| 121 // Returns true if the specified connection originated the current change. | 129 // Returns true if the specified connection originated the current change. |
| 122 bool IsChangeSource(TransportConnectionId connection_id) const { | 130 bool IsChangeSource(TransportConnectionId connection_id) const { |
| 123 return connection_id == change_source_; | 131 return connection_id == change_source_; |
| 124 } | 132 } |
| 125 | 133 |
| 134 // Implementation of the two connect variants. |
| 135 ViewManagerConnection* ConnectImpl(const String& url, |
| 136 const Array<TransportNodeId>& node_ids); |
| 137 |
| 126 // Overridden from NodeDelegate: | 138 // Overridden from NodeDelegate: |
| 127 virtual void OnNodeHierarchyChanged(const Node* node, | 139 virtual void OnNodeHierarchyChanged(const Node* node, |
| 128 const Node* new_parent, | 140 const Node* new_parent, |
| 129 const Node* old_parent) OVERRIDE; | 141 const Node* old_parent) OVERRIDE; |
| 130 virtual void OnNodeViewReplaced(const Node* node, | 142 virtual void OnNodeViewReplaced(const Node* node, |
| 131 const View* new_view, | 143 const View* new_view, |
| 132 const View* old_view) OVERRIDE; | 144 const View* old_view) OVERRIDE; |
| 133 | 145 |
| 134 Context context_; | 146 Context context_; |
| 135 | 147 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 159 std::set<ViewManagerConnection*> connections_created_by_connect_; | 171 std::set<ViewManagerConnection*> connections_created_by_connect_; |
| 160 | 172 |
| 161 DISALLOW_COPY_AND_ASSIGN(RootNodeManager); | 173 DISALLOW_COPY_AND_ASSIGN(RootNodeManager); |
| 162 }; | 174 }; |
| 163 | 175 |
| 164 } // namespace service | 176 } // namespace service |
| 165 } // namespace view_manager | 177 } // namespace view_manager |
| 166 } // namespace mojo | 178 } // namespace mojo |
| 167 | 179 |
| 168 #endif // MOJO_SERVICES_VIEW_MANAGER_ROOT_NODE_MANAGER_H_ | 180 #endif // MOJO_SERVICES_VIEW_MANAGER_ROOT_NODE_MANAGER_H_ |
| OLD | NEW |