OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 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 BLIMP_NET_HELIUM_HELIUM_SYNC_MANAGER_H_ | |
6 #define BLIMP_NET_HELIUM_HELIUM_SYNC_MANAGER_H_ | |
7 | |
8 #include <stdint.h> | |
9 #include <memory> | |
10 | |
11 #include "base/macros.h" | |
12 | |
13 namespace blimp { | |
14 | |
15 class HeliumObject; | |
16 class HeliumTransport; | |
17 class Syncable; | |
18 | |
19 using HeliumObjectId = uint32_t; | |
scf
2016/10/06 17:37:49
I with proto allowed typedefs so we could define t
| |
20 | |
21 // TODO(kmarshall): Define this type. | |
22 class HeliumTransport {}; | |
23 | |
24 class HeliumSyncManager { | |
25 public: | |
26 // RAII object for managing the sync control and registration status of a | |
27 // Syncable. When a Syncable is registered, it should hold onto the resulting | |
28 // SyncRegistration object. | |
29 // | |
30 // When the Syncable is destroyed, it will delete the | |
31 // SyncRegistration along with it, which will automatically unregister the | |
32 // object from the SyncManager. | |
scf
2016/10/06 17:37:49
Who owns the SyncRegistration? Should we add to th
Kevin M
2016/10/06 18:41:09
The Object, which is the TwoPhaseSyncable. So yeah
Wez
2016/10/08 00:38:21
It would be preferable to keep a clean separation
| |
33 // | |
34 // If a Syncable wishes to halt synchronization for any reason (e.g. a tab | |
35 // is hidden on the Client), it may call SyncRegistration::Pause(), which will | |
36 // tell the SyncManager to exclude or include the Syncable in state sync. | |
37 class SyncRegistration { | |
38 public: | |
39 explicit SyncRegistration(HeliumSyncManager* sync_manager, | |
40 HeliumObjectId id); | |
41 ~SyncRegistration(); | |
42 | |
43 // Tells the HeliumSyncManager to pause or unpause synchronization for the | |
44 // HeliumObject associated with |this|. | |
45 void Pause(bool paused); | |
46 | |
47 HeliumObjectId id() { return id_; } | |
48 | |
49 private: | |
50 HeliumObjectId id_; | |
51 HeliumSyncManager* sync_manager_; | |
52 | |
53 DISALLOW_COPY_AND_ASSIGN(SyncRegistration); | |
54 }; | |
55 | |
56 virtual ~HeliumSyncManager() {} | |
57 | |
58 // Returns a concrete implementation of HeliumSyncManager. | |
59 static std::unique_ptr<HeliumSyncManager> Create( | |
60 std::unique_ptr<HeliumTransport> transport); | |
Wez
2016/10/08 00:38:21
Given that the impl in this CL is a no-op, and tha
| |
61 | |
62 // Registers a new Syncable for synchronization. The Sync layer allocates a | |
63 // unique identifier to the Object (including guaranteeing no clashes between | |
64 // Client & Engine). | |
65 // The identifier may be used by other Objects to refer to |object|. E.g. the | |
66 // tab-list Object might include the Id for each tab’s Object. | |
67 virtual std::unique_ptr<SyncRegistration> Register(Syncable* syncable) = 0; | |
68 | |
69 // Registers a Syncable for synchronization with a pre-existing ID. | |
70 // This form is used when the remote peer has created a new Syncable, to | |
71 // register our local equivalent. | |
72 virtual std::unique_ptr<SyncRegistration> RegisterExisting( | |
73 HeliumObjectId id, | |
74 Syncable* syncable) = 0; | |
75 | |
76 protected: | |
77 friend class HeliumSyncManager::SyncRegistration; | |
78 | |
79 // Tells the HeliumSyncManager to pause or unpause synchronization for the | |
80 // HeliumObject associated with |this|. | |
81 virtual void Pause(HeliumObjectId id, bool paused) = 0; | |
Wez
2016/10/08 00:38:21
Let's leave out stuff like this until we get to im
| |
82 | |
83 // Indicates that a Syncable is being destroyed, and should no longer be | |
84 // synchronized. | |
85 // Because the Syncable is being destroyed, it is assumed that in-flight | |
86 // messages | |
87 // about it are now irrelevant, and the Sync layer should tear down underlying | |
88 // resources, such as the HeliumStream, immediately. | |
89 virtual void Unregister(HeliumObjectId id) = 0; | |
90 }; | |
91 | |
92 } // namespace blimp | |
93 | |
94 #endif // BLIMP_NET_HELIUM_HELIUM_SYNC_MANAGER_H_ | |
OLD | NEW |