Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(323)

Side by Side Diff: mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.h

Issue 258623005: First step at synchronizing client model changes with service. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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);
24 virtual ~ViewManagerSynchronizer();
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);
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();
sky 2014/04/29 04:14:06 uint32_t
60
61 // Removes |transaction| from the pending queue. |transaction| must be at the
62 // front of the queue.
63 void RemoveFromPendingQueue(ViewManagerTransaction* transaction);
64
65 ViewManager* view_manager_;
66 bool connected_;
67 uint16_t connection_id_;
68 uint16_t next_id_;
69 uint32_t next_change_id_;
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 _
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698