Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 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_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/memory/scoped_vector.h" | |
| 10 #include "mojo/public/cpp/bindings/remote_ptr.h" | |
| 11 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h" | |
| 12 | |
| 13 namespace mojo { | |
| 14 namespace services { | |
| 15 namespace view_manager { | |
| 16 | |
| 17 class ViewManager; | |
| 18 class ViewManagerTransaction; | |
| 19 | |
| 20 // Manages the connection with the View Manager service. | |
| 21 class ViewManagerSynchronizer : public IViewManagerClient { | |
| 22 public: | |
| 23 explicit ViewManagerSynchronizer(ViewManager* view_manager); | |
|
sky
2014/04/28 23:04:19
Document who owns view_manager.
| |
| 24 ~ViewManagerSynchronizer(); | |
|
sky
2014/04/28 23:04:19
virtual
| |
| 25 | |
| 26 // API exposed to the node implementation that pushes local changes to the | |
| 27 // service. | |
| 28 int CreateViewTreeNode(); | |
| 29 void AddChild(int child_id, int parent_id); | |
|
sky
2014/04/29 04:14:06
uint16_t for these.
| |
| 30 void RemoveChild(int child_id, int parent_id); | |
| 31 | |
| 32 private: | |
| 33 friend class ViewManagerTransaction; | |
| 34 typedef ScopedVector<ViewManagerTransaction> Transactions; | |
| 35 | |
| 36 // Overridden from IViewManagerClient: | |
| 37 virtual void OnConnectionEstablished(uint16 connection_id) OVERRIDE; | |
| 38 virtual void OnNodeHierarchyChanged(uint32 node, | |
| 39 uint32 new_parent, | |
| 40 uint32 old_parent, | |
| 41 int32 change_id) OVERRIDE; | |
| 42 virtual void OnNodeViewReplaced(uint32_t node, | |
| 43 uint32_t new_view_id, | |
| 44 uint32_t old_view_id, | |
| 45 int32_t change_id) OVERRIDE; | |
| 46 | |
| 47 // Called to schedule a sync of the client model with the service after a | |
| 48 // return to the message loop. | |
| 49 void ScheduleSync(); | |
| 50 | |
| 51 // Sync the client model with the service by enumerating the pending | |
| 52 // transaction queue and applying them in order. | |
| 53 void DoSync(); | |
| 54 | |
| 55 // Used by individual transactions to generate a connection-specific change | |
| 56 // id. | |
| 57 // TODO(beng): What happens when there are more than sizeof(int) changes in | |
| 58 // the queue? | |
| 59 int GetNextChangeId(); | |
| 60 | |
| 61 // Returns true if |change_id| existed in the pending transaction queue and | |
| 62 // was removed. | |
| 63 bool RemovedFromPendingQueue(int change_id); | |
| 64 | |
| 65 ViewManager* view_manager_; | |
| 66 bool connected_; | |
| 67 uint16 connection_id_; | |
|
sky
2014/04/29 04:14:06
uint16_t
| |
| 68 int next_id_; | |
|
sky
2014/04/28 23:04:19
uint16_t.
| |
| 69 int next_change_id_; | |
|
sky
2014/04/28 23:04:19
uint32_t.
| |
| 70 | |
| 71 Transactions pending_transactions_; | |
| 72 | |
| 73 RemotePtr<IViewManager> service_; | |
| 74 | |
| 75 DISALLOW_COPY_AND_ASSIGN(ViewManagerSynchronizer); | |
| 76 }; | |
| 77 | |
| 78 } // namespace view_manager | |
| 79 } // namespace services | |
| 80 } // namespace mojo | |
| 81 | |
| 82 #endif // MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_VIEW_MANAGER_SYNCHRONIZER_H _ | |
| OLD | NEW |