summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync/api/sync_data.h
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-16 04:55:39 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-16 04:55:39 +0000
commitfb16d7f9b150ad6893e1db386707252b0dbdeab2 (patch)
tree3e4eabb5c0cc934ba0086614e6a18e4d19f77d05 /chrome/browser/sync/api/sync_data.h
parenteb21c1d6ec3dd475a7f9e0b1541c117d9041878a (diff)
downloadchromium_src-fb16d7f9b150ad6893e1db386707252b0dbdeab2.zip
chromium_src-fb16d7f9b150ad6893e1db386707252b0dbdeab2.tar.gz
chromium_src-fb16d7f9b150ad6893e1db386707252b0dbdeab2.tar.bz2
[Sync] Rework SharedValue<T> into Immutable<T>
Rework SharedValue<T> into Immutable<T>, which behaves similarly but is easier to use and is better documented. Make everything that used SharedValue<T> use Immutable<T> instead. Make SyncData use Immutable<T>. BUG= TEST= Review URL: http://codereview.chromium.org/7904021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@101455 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync/api/sync_data.h')
-rw-r--r--chrome/browser/sync/api/sync_data.h42
1 files changed, 24 insertions, 18 deletions
diff --git a/chrome/browser/sync/api/sync_data.h b/chrome/browser/sync/api/sync_data.h
index 7656de8..d73fdfa 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_