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

Side by Side Diff: blimp/helium/sync_manager.h

Issue 2602103002: Delete blimp/helium and remove references to it from dependent targets (Closed)
Patch Set: . Created 3 years, 11 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
« no previous file with comments | « blimp/helium/stream_helpers_unittest.cc ('k') | blimp/helium/sync_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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_HELIUM_SYNC_MANAGER_H_
6 #define BLIMP_HELIUM_SYNC_MANAGER_H_
7
8 #include <stdint.h>
9 #include <memory>
10
11 #include "base/macros.h"
12
13 namespace blimp {
14 namespace helium {
15
16 class HeliumObject;
17 class HeliumTransport;
18 class Syncable;
19
20 using HeliumObjectId = uint32_t;
21
22 // TODO(kmarshall): Define this type.
23 class HeliumTransport {};
24
25 class SyncManager {
26 public:
27 // RAII object for managing the sync control and registration status of a
28 // Syncable. When a Syncable is registered, it should hold onto the resulting
29 // SyncRegistration object.
30 //
31 // When the Syncable is destroyed, it will delete the
32 // SyncRegistration along with it, which will automatically unregister the
33 // object from the SyncManager.
34 //
35 // If a Syncable wishes to halt synchronization for any reason (e.g. a tab
36 // is hidden on the Client), it may call SyncRegistration::Pause(), which will
37 // tell the SyncManager to exclude or include the Syncable in state sync.
38 class SyncRegistration {
39 public:
40 SyncRegistration(SyncManager* sync_manager, 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 SyncManager* sync_manager_;
52
53 DISALLOW_COPY_AND_ASSIGN(SyncRegistration);
54 };
55
56 virtual ~SyncManager() {}
57
58 // Returns a concrete implementation of HeliumSyncManager.
59 static std::unique_ptr<SyncManager> Create(
60 std::unique_ptr<HeliumTransport> transport);
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 SyncManager::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;
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 helium
93 } // namespace blimp
94
95 #endif // BLIMP_HELIUM_SYNC_MANAGER_H_
OLDNEW
« no previous file with comments | « blimp/helium/stream_helpers_unittest.cc ('k') | blimp/helium/sync_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698