| 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 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 | 43 |
| 44 RootNodeManager(); | 44 RootNodeManager(); |
| 45 virtual ~RootNodeManager(); | 45 virtual ~RootNodeManager(); |
| 46 | 46 |
| 47 // Returns the id for the next ViewManagerConnection. | 47 // Returns the id for the next ViewManagerConnection. |
| 48 uint16_t GetAndAdvanceNextConnectionId(); | 48 uint16_t GetAndAdvanceNextConnectionId(); |
| 49 | 49 |
| 50 void AddConnection(ViewManagerConnection* connection); | 50 void AddConnection(ViewManagerConnection* connection); |
| 51 void RemoveConnection(ViewManagerConnection* connection); | 51 void RemoveConnection(ViewManagerConnection* connection); |
| 52 | 52 |
| 53 // Returns the connection by id. | |
| 54 ViewManagerConnection* GetConnection(uint16_t connection_id); | |
| 55 | |
| 56 // Returns the Node identified by |id|. | 53 // Returns the Node identified by |id|. |
| 57 Node* GetNode(const NodeId& id); | 54 Node* GetNode(const NodeId& id); |
| 58 | 55 |
| 59 // Returns the View identified by |id|. | 56 // Notifies all ViewManagerConnections of a hierarchy change. |
| 60 View* GetView(const ViewId& id); | |
| 61 | |
| 62 // These functions trivially delegate to all ViewManagerConnections, which in | |
| 63 // term notify their clients. | |
| 64 void NotifyNodeHierarchyChanged(const NodeId& node, | 57 void NotifyNodeHierarchyChanged(const NodeId& node, |
| 65 const NodeId& new_parent, | 58 const NodeId& new_parent, |
| 66 const NodeId& old_parent); | 59 const NodeId& old_parent); |
| 67 void NotifyNodeViewReplaced(const NodeId& node, | |
| 68 const ViewId& new_view_id, | |
| 69 const ViewId& old_view_id); | |
| 70 | 60 |
| 71 private: | 61 private: |
| 72 // Tracks a change. | 62 // Tracks a change. |
| 73 struct Change { | 63 struct Change { |
| 74 Change(int32_t connection_id, int32_t change_id) | 64 Change(int32_t connection_id, int32_t change_id) |
| 75 : connection_id(connection_id), | 65 : connection_id(connection_id), |
| 76 change_id(change_id) { | 66 change_id(change_id) { |
| 77 } | 67 } |
| 78 | 68 |
| 79 int32_t connection_id; | 69 int32_t connection_id; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 97 virtual void OnCreated() OVERRIDE; | 87 virtual void OnCreated() OVERRIDE; |
| 98 virtual void OnDestroyed() OVERRIDE; | 88 virtual void OnDestroyed() OVERRIDE; |
| 99 virtual void OnBoundsChanged(const Rect& bounds) OVERRIDE; | 89 virtual void OnBoundsChanged(const Rect& bounds) OVERRIDE; |
| 100 virtual void OnEvent(const Event& event, | 90 virtual void OnEvent(const Event& event, |
| 101 const mojo::Callback<void()>& callback) OVERRIDE; | 91 const mojo::Callback<void()>& callback) OVERRIDE; |
| 102 | 92 |
| 103 // Overriden from NodeDelegate: | 93 // Overriden from NodeDelegate: |
| 104 virtual void OnNodeHierarchyChanged(const NodeId& node, | 94 virtual void OnNodeHierarchyChanged(const NodeId& node, |
| 105 const NodeId& new_parent, | 95 const NodeId& new_parent, |
| 106 const NodeId& old_parent) OVERRIDE; | 96 const NodeId& old_parent) OVERRIDE; |
| 107 virtual void OnNodeViewReplaced(const NodeId& node, | |
| 108 const ViewId& new_view_id, | |
| 109 const ViewId& old_view_id) OVERRIDE; | |
| 110 | 97 |
| 111 // ID to use for next ViewManagerConnection. | 98 // ID to use for next ViewManagerConnection. |
| 112 uint16_t next_connection_id_; | 99 uint16_t next_connection_id_; |
| 113 | 100 |
| 114 // Set of ViewManagerConnections. | 101 // Set of ViewManagerConnections. |
| 115 ConnectionMap connection_map_; | 102 ConnectionMap connection_map_; |
| 116 | 103 |
| 117 // Root node. | 104 // Root node. |
| 118 Node root_; | 105 Node root_; |
| 119 | 106 |
| 120 // If non-null we're processing a change. | 107 // If non-null we're processing a change. |
| 121 scoped_ptr<Change> change_; | 108 scoped_ptr<Change> change_; |
| 122 | 109 |
| 123 DISALLOW_COPY_AND_ASSIGN(RootNodeManager); | 110 DISALLOW_COPY_AND_ASSIGN(RootNodeManager); |
| 124 }; | 111 }; |
| 125 | 112 |
| 126 } // namespace view_manager | 113 } // namespace view_manager |
| 127 } // namespace services | 114 } // namespace services |
| 128 } // namespace mojo | 115 } // namespace mojo |
| 129 | 116 |
| 130 #endif // MOJO_SERVICES_VIEW_MANAGER_ROOT_NODE_MANAGER_H_ | 117 #endif // MOJO_SERVICES_VIEW_MANAGER_ROOT_NODE_MANAGER_H_ |
| OLD | NEW |