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

Unified Diff: blimp/net/helium/helium_sync_manager.h

Issue 2377873002: Initial definition of HeliumSyncManager and SyncRegistration objects. (Closed)
Patch Set: Remove review cruft from CL Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « blimp/net/BUILD.gn ('k') | blimp/net/helium/helium_sync_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: blimp/net/helium/helium_sync_manager.h
diff --git a/blimp/net/helium/helium_sync_manager.h b/blimp/net/helium/helium_sync_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..17c287ed9cdd3e7e0ee7f6bd78485b0bc68deb4f
--- /dev/null
+++ b/blimp/net/helium/helium_sync_manager.h
@@ -0,0 +1,94 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BLIMP_NET_HELIUM_HELIUM_SYNC_MANAGER_H_
+#define BLIMP_NET_HELIUM_HELIUM_SYNC_MANAGER_H_
+
+#include <stdint.h>
+#include <memory>
+
+#include "base/macros.h"
+
+namespace blimp {
+
+class HeliumObject;
+class HeliumTransport;
+class Syncable;
+
+using HeliumObjectId = uint32_t;
scf 2016/10/06 17:37:49 I with proto allowed typedefs so we could define t
+
+// TODO(kmarshall): Define this type.
+class HeliumTransport {};
+
+class HeliumSyncManager {
+ public:
+ // RAII object for managing the sync control and registration status of a
+ // Syncable. When a Syncable is registered, it should hold onto the resulting
+ // SyncRegistration object.
+ //
+ // When the Syncable is destroyed, it will delete the
+ // SyncRegistration along with it, which will automatically unregister the
+ // 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
+ //
+ // If a Syncable wishes to halt synchronization for any reason (e.g. a tab
+ // is hidden on the Client), it may call SyncRegistration::Pause(), which will
+ // tell the SyncManager to exclude or include the Syncable in state sync.
+ class SyncRegistration {
+ public:
+ explicit SyncRegistration(HeliumSyncManager* sync_manager,
+ HeliumObjectId id);
+ ~SyncRegistration();
+
+ // Tells the HeliumSyncManager to pause or unpause synchronization for the
+ // HeliumObject associated with |this|.
+ void Pause(bool paused);
+
+ HeliumObjectId id() { return id_; }
+
+ private:
+ HeliumObjectId id_;
+ HeliumSyncManager* sync_manager_;
+
+ DISALLOW_COPY_AND_ASSIGN(SyncRegistration);
+ };
+
+ virtual ~HeliumSyncManager() {}
+
+ // Returns a concrete implementation of HeliumSyncManager.
+ static std::unique_ptr<HeliumSyncManager> Create(
+ 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
+
+ // Registers a new Syncable for synchronization. The Sync layer allocates a
+ // unique identifier to the Object (including guaranteeing no clashes between
+ // Client & Engine).
+ // The identifier may be used by other Objects to refer to |object|. E.g. the
+ // tab-list Object might include the Id for each tab’s Object.
+ virtual std::unique_ptr<SyncRegistration> Register(Syncable* syncable) = 0;
+
+ // Registers a Syncable for synchronization with a pre-existing ID.
+ // This form is used when the remote peer has created a new Syncable, to
+ // register our local equivalent.
+ virtual std::unique_ptr<SyncRegistration> RegisterExisting(
+ HeliumObjectId id,
+ Syncable* syncable) = 0;
+
+ protected:
+ friend class HeliumSyncManager::SyncRegistration;
+
+ // Tells the HeliumSyncManager to pause or unpause synchronization for the
+ // HeliumObject associated with |this|.
+ 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
+
+ // Indicates that a Syncable is being destroyed, and should no longer be
+ // synchronized.
+ // Because the Syncable is being destroyed, it is assumed that in-flight
+ // messages
+ // about it are now irrelevant, and the Sync layer should tear down underlying
+ // resources, such as the HeliumStream, immediately.
+ virtual void Unregister(HeliumObjectId id) = 0;
+};
+
+} // namespace blimp
+
+#endif // BLIMP_NET_HELIUM_HELIUM_SYNC_MANAGER_H_
« no previous file with comments | « blimp/net/BUILD.gn ('k') | blimp/net/helium/helium_sync_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698