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

Unified Diff: sync/api/sync_data.h

Issue 220043002: [Sync] Add sync api support for context changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Self review Created 6 years, 9 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
Index: sync/api/sync_data.h
diff --git a/sync/api/sync_data.h b/sync/api/sync_data.h
index 43f64f9185b10f798abe3086aec60fd85310d11e..d4072db298b87dc8e1295e41ef4989bf48a9ab8a 100644
--- a/sync/api/sync_data.h
+++ b/sync/api/sync_data.h
@@ -17,11 +17,12 @@
namespace sync_pb {
class EntitySpecifics;
-class SyncEntity;
} // namespace sync_pb
namespace syncer {
+struct SyncDataCore;
+
// A light-weight container for immutable sync data. Pass-by-value and storage
// in STL containers are supported and encouraged if helpful.
class SYNC_EXPORT SyncData {
@@ -55,6 +56,10 @@ class SYNC_EXPORT SyncData {
const sync_pb::EntitySpecifics& specifics,
const base::Time& last_modified_time);
+ // For datatype context changes: |datatype| specifies the type whose context
+ // is being updated.
+ static SyncData CreateContext(ModelType datatype, const std::string& context);
maniscalco 2014/03/31 23:59:16 Any reason not to pass datatype by const ref? The
maniscalco 2014/03/31 23:59:16 Are SyncData created by this method "local" or "re
Nicolas Zea 2014/04/02 18:34:36 ModelType is just an enum, so passing by ref is ac
Nicolas Zea 2014/04/02 18:34:36 Neither. I was actually planning to get rid of the
maniscalco 2014/04/02 21:13:09 Pass by value SGTM.
+
// Whether this SyncData holds valid data. The only way to have a SyncData
// without valid data is to use the default constructor.
bool IsValid() const;
@@ -74,6 +79,10 @@ class SYNC_EXPORT SyncData {
// going TO the syncer, not from.
const std::string& GetTitle() const;
+ // Returns the datatype context, if one exists. Returns empty string
+ // otherwise.
+ const std::string& GetContext() const;
+
// Returns the last motification time according to the server. This is
// only valid if IsLocal() is false, and may be null if the SyncData
// represents a deleted item.
@@ -83,6 +92,7 @@ class SYNC_EXPORT SyncData {
int64 GetRemoteId() const;
// Whether this sync data is for local data or data coming from the syncer.
+ // TODO(zea): remove this.
bool IsLocal() const;
std::string ToString() const;
@@ -90,42 +100,33 @@ class SYNC_EXPORT SyncData {
// TODO(zea): Query methods for other sync properties: parent, successor, etc.
private:
- // Necessary since we forward-declare sync_pb::SyncEntity; see
+ // Necessary since we forward-declare SyncDataCore; see
// comments in immutable.h.
- struct ImmutableSyncEntityTraits {
- typedef sync_pb::SyncEntity* Wrapper;
+ struct ImmutableSyncDataCoreTraits {
+ typedef SyncDataCore* Wrapper;
static void InitializeWrapper(Wrapper* wrapper);
static void DestroyWrapper(Wrapper* wrapper);
- static const sync_pb::SyncEntity& Unwrap(const Wrapper& wrapper);
+ static const SyncDataCore& Unwrap(const Wrapper& wrapper);
- static sync_pb::SyncEntity* UnwrapMutable(Wrapper* wrapper);
+ static SyncDataCore* UnwrapMutable(Wrapper* wrapper);
- static void Swap(sync_pb::SyncEntity* t1, sync_pb::SyncEntity* t2);
+ static void Swap(SyncDataCore* t1, SyncDataCore* t2);
};
- typedef Immutable<sync_pb::SyncEntity, ImmutableSyncEntityTraits>
- ImmutableSyncEntity;
+ typedef Immutable<SyncDataCore, ImmutableSyncDataCoreTraits>
+ ImmutableSyncDataCore;
- // Clears |entity|.
- SyncData(int64 id,
- sync_pb::SyncEntity* entity,
- const base::Time& remote_modification_time);
+ // Clears |data|.
+ SyncData(SyncDataCore* data);
// Whether this SyncData holds valid data.
bool is_valid_;
- // Equal to kInvalidId iff this is local.
- int64 id_;
-
- // This is only valid if IsLocal() is false, and may be null if the
- // SyncData represents a deleted item.
- base::Time remote_modification_time_;
-
- // The actual shared sync entity being held.
- ImmutableSyncEntity immutable_entity_;
+ // The actual sync data being held.
+ ImmutableSyncDataCore immutable_data_;
};
// gmock printer helper.

Powered by Google App Engine
This is Rietveld 408576698