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

Unified Diff: chrome/browser/sync/api/sync_data.h

Issue 7904021: [Sync] Rework SharedValue<T> into Immutable<T> (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 9 years, 3 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 | « chrome/browser/sync/api/sync_change_unittest.cc ('k') | chrome/browser/sync/api/sync_data.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/api/sync_data.h
diff --git a/chrome/browser/sync/api/sync_data.h b/chrome/browser/sync/api/sync_data.h
index 7656de89d3f6750d4a2429e381b584834dfbc750..d73fdfa9ed89e6554411455393a1990269d31afc 100644
--- a/chrome/browser/sync/api/sync_data.h
+++ b/chrome/browser/sync/api/sync_data.h
@@ -9,14 +9,13 @@
#include <string>
#include <vector>
-#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
#include "chrome/browser/sync/syncable/model_type.h"
+#include "chrome/browser/sync/util/immutable.h"
namespace sync_pb {
class EntitySpecifics;
class SyncEntity;
-}
+} // namespace sync_pb
typedef syncable::ModelType SyncDataType;
@@ -77,30 +76,37 @@ class SyncData {
// TODO(zea): Query methods for other sync properties: parent, successor, etc.
private:
- // A reference counted immutable SyncEntity.
- class SharedSyncEntity : public
- base::RefCountedThreadSafe<SharedSyncEntity> {
- public:
- // Takes ownership of |sync_entity|'s contents.
- explicit SharedSyncEntity(sync_pb::SyncEntity* sync_entity);
+ // Necessary since we forward-declare sync_pb::SyncEntity; see
+ // comments in immutable.h.
+ struct ImmutableSyncEntityTraits {
+ typedef sync_pb::SyncEntity* Wrapper;
- // Returns immutable reference to local sync entity.
- const sync_pb::SyncEntity& sync_entity() const;
+ static void InitializeWrapper(Wrapper* wrapper);
- private:
- friend class base::RefCountedThreadSafe<SharedSyncEntity>;
+ static void DestroyWrapper(Wrapper* wrapper);
- // Private due to ref counting.
- ~SharedSyncEntity();
+ static const sync_pb::SyncEntity& Unwrap(const Wrapper& wrapper);
- scoped_ptr<sync_pb::SyncEntity> sync_entity_;
+ static sync_pb::SyncEntity* UnwrapMutable(Wrapper* wrapper);
+
+ static void Swap(sync_pb::SyncEntity* t1, sync_pb::SyncEntity* t2);
};
- // The actual shared sync entity being held.
- scoped_refptr<SharedSyncEntity> shared_entity_;
+ typedef browser_sync::Immutable<
+ sync_pb::SyncEntity, ImmutableSyncEntityTraits>
+ ImmutableSyncEntity;
+
+ // Clears |entity|.
+ SyncData(sync_pb::SyncEntity* entity, bool is_local);
+
+ // Whether this SyncData holds valid data.
+ bool is_valid_;
// Whether this data originated locally or from the syncer (remote data).
bool is_local_;
+
+ // The actual shared sync entity being held.
+ ImmutableSyncEntity immutable_entity_;
};
#endif // CHROME_BROWSER_SYNC_API_SYNC_DATA_H_
« no previous file with comments | « chrome/browser/sync/api/sync_change_unittest.cc ('k') | chrome/browser/sync/api/sync_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698