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_PUBLIC_CPP_VIEW_MANAGER_LIB_VIEW_MANAGER_SYNCHRONIZER_H_ | 5 #ifndef MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_VIEW_MANAGER_SYNCHRONIZER_H_ |
6 #define MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_VIEW_MANAGER_SYNCHRONIZER_H_ | 6 #define MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_VIEW_MANAGER_SYNCHRONIZER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 void AddChild(TransportNodeId child_id, TransportNodeId parent_id); | 41 void AddChild(TransportNodeId child_id, TransportNodeId parent_id); |
42 void RemoveChild(TransportNodeId child_id, TransportNodeId parent_id); | 42 void RemoveChild(TransportNodeId child_id, TransportNodeId parent_id); |
43 | 43 |
44 bool OwnsNode(TransportNodeId id) const; | 44 bool OwnsNode(TransportNodeId id) const; |
45 | 45 |
46 private: | 46 private: |
47 friend class ViewManagerTransaction; | 47 friend class ViewManagerTransaction; |
48 typedef ScopedVector<ViewManagerTransaction> Transactions; | 48 typedef ScopedVector<ViewManagerTransaction> Transactions; |
49 | 49 |
50 // Overridden from IViewManagerClient: | 50 // Overridden from IViewManagerClient: |
51 virtual void OnConnectionEstablished(uint16 connection_id) OVERRIDE; | 51 virtual void OnConnectionEstablished( |
52 virtual void OnNodeHierarchyChanged(uint32 node_id, | 52 TransportConnectionId connection_id, |
53 uint32 new_parent_id, | 53 TransportChangeId next_server_change_id) OVERRIDE; |
54 uint32 old_parent_id, | 54 virtual void OnNodeHierarchyChanged( |
55 uint32 change_id) OVERRIDE; | 55 uint32 node_id, |
| 56 uint32 new_parent_id, |
| 57 uint32 old_parent_id, |
| 58 TransportChangeId server_change_id, |
| 59 TransportChangeId client_change_id) OVERRIDE; |
| 60 virtual void OnNodeDeleted(TransportNodeId node_id, |
| 61 TransportChangeId server_change_id, |
| 62 TransportChangeId client_change_id) OVERRIDE; |
56 virtual void OnNodeViewReplaced(uint32_t node, | 63 virtual void OnNodeViewReplaced(uint32_t node, |
57 uint32_t new_view_id, | 64 uint32_t new_view_id, |
58 uint32_t old_view_id, | 65 uint32_t old_view_id, |
59 uint32_t change_id) OVERRIDE; | 66 TransportChangeId client_change_id) OVERRIDE; |
60 virtual void OnNodeDeleted(uint32_t node_id, uint32_t change_id) OVERRIDE; | |
61 | |
62 // Called to schedule a sync of the client model with the service after a | |
63 // return to the message loop. | |
64 void ScheduleSync(); | |
65 | 67 |
66 // Sync the client model with the service by enumerating the pending | 68 // Sync the client model with the service by enumerating the pending |
67 // transaction queue and applying them in order. | 69 // transaction queue and applying them in order. |
68 void DoSync(); | 70 void Sync(); |
69 | 71 |
70 // Used by individual transactions to generate a connection-specific change | 72 // Used by individual transactions to generate a connection-specific change |
71 // id. | 73 // id. |
72 // TODO(beng): What happens when there are more than sizeof(int) changes in | 74 // TODO(beng): What happens when there are more than sizeof(int) changes in |
73 // the queue? | 75 // the queue? |
74 uint32_t GetNextChangeId(); | 76 TransportChangeId GetNextClientChangeId(); |
75 | 77 |
76 // Removes |transaction| from the pending queue. |transaction| must be at the | 78 // Removes |transaction| from the pending queue. |transaction| must be at the |
77 // front of the queue. | 79 // front of the queue. |
78 void RemoveFromPendingQueue(ViewManagerTransaction* transaction); | 80 void RemoveFromPendingQueue(ViewManagerTransaction* transaction); |
79 | 81 |
80 void OnRootTreeReceived(const Array<INode>& data); | 82 void OnRootTreeReceived(const Array<INode>& data); |
81 | 83 |
82 ViewManager* view_manager_; | 84 ViewManager* view_manager_; |
83 bool connected_; | 85 bool connected_; |
84 uint16_t connection_id_; | 86 TransportConnectionId connection_id_; |
85 uint16_t next_id_; | 87 uint16_t next_id_; |
86 uint32_t next_change_id_; | 88 TransportChangeId next_client_change_id_; |
| 89 TransportChangeId next_server_change_id_; |
87 | 90 |
88 Transactions pending_transactions_; | 91 Transactions pending_transactions_; |
89 | 92 |
90 base::WeakPtrFactory<ViewManagerSynchronizer> sync_factory_; | 93 base::WeakPtrFactory<ViewManagerSynchronizer> sync_factory_; |
91 | 94 |
92 // Non-NULL while blocking on the connection to |service_| during | 95 // Non-NULL while blocking on the connection to |service_| during |
93 // construction. | 96 // construction. |
94 base::RunLoop* init_loop_; | 97 base::RunLoop* init_loop_; |
95 | 98 |
96 IViewManagerPtr service_; | 99 IViewManagerPtr service_; |
97 | 100 |
98 DISALLOW_COPY_AND_ASSIGN(ViewManagerSynchronizer); | 101 DISALLOW_COPY_AND_ASSIGN(ViewManagerSynchronizer); |
99 }; | 102 }; |
100 | 103 |
101 } // namespace view_manager | 104 } // namespace view_manager |
102 } // namespace services | 105 } // namespace services |
103 } // namespace mojo | 106 } // namespace mojo |
104 | 107 |
105 #endif // MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_VIEW_MANAGER_SYNCHRONIZER_H
_ | 108 #endif // MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_VIEW_MANAGER_SYNCHRONIZER_H
_ |
OLD | NEW |