diff options
author | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-13 20:26:31 +0000 |
---|---|---|
committer | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-13 20:26:31 +0000 |
commit | 65824a157879e0ec148964e8194b86ce1b60c1c0 (patch) | |
tree | f1c6b6b6e47cfe35915eefd4f5b175b00a5d6843 /sync/syncable | |
parent | 68bddb4f0ee93b59868b19a31827148dbb6403ab (diff) | |
download | chromium_src-65824a157879e0ec148964e8194b86ce1b60c1c0.zip chromium_src-65824a157879e0ec148964e8194b86ce1b60c1c0.tar.gz chromium_src-65824a157879e0ec148964e8194b86ce1b60c1c0.tar.bz2 |
sync: Add getters and setters to Entry classes
Replace the Entry and MutableEntry classes' Get(X) and Put(X, V) members
with GetX() and PutX(V) style members.
There are many good reasons for performing this refactor. The main
reason to implement it now is that we'd like to have more fine-grained
control over the visibility of the getters and setters for certain
fields, and it's really hard to implement that control when several
different fields use the same accessor functions.
Once this refactor is complete, we can modify the inheritance hierarchy
for Entry and MutableEntry to introduce a new, semi-MutableEntry that
provides only the setters whose changes are not "visible" to the
underlying model.
We can also build on this work to simplify the implementation of
MutableEntry.
The interface changes are the most notable part of this CL, but there
are a few smaller changes here too, including:
- Some small formatting cleanups.
- In cases where Put() functions had signatures that returned bool but
never returned anything other than 'true', those return values have
been changed to void.
- Some dead code in syncer_proto_util.cc has been removed.
BUG=284672
Review URL: https://chromiumcodereview.appspot.com/23484035
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@223111 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/syncable')
-rw-r--r-- | sync/syncable/directory.cc | 45 | ||||
-rw-r--r-- | sync/syncable/entry.cc | 19 | ||||
-rw-r--r-- | sync/syncable/entry.h | 145 | ||||
-rw-r--r-- | sync/syncable/mutable_entry.cc | 103 | ||||
-rw-r--r-- | sync/syncable/mutable_entry.h | 67 | ||||
-rw-r--r-- | sync/syncable/nigori_util.cc | 26 | ||||
-rw-r--r-- | sync/syncable/nigori_util.h | 2 | ||||
-rw-r--r-- | sync/syncable/syncable_unittest.cc | 594 | ||||
-rw-r--r-- | sync/syncable/syncable_util.cc | 8 | ||||
-rw-r--r-- | sync/syncable/syncable_write_transaction.cc | 2 |
10 files changed, 606 insertions, 405 deletions
diff --git a/sync/syncable/directory.cc b/sync/syncable/directory.cc index 200606e..9754b88 100644 --- a/sync/syncable/directory.cc +++ b/sync/syncable/directory.cc @@ -833,7 +833,7 @@ bool Directory::InitialSyncEndedForType( syncable::Entry entry(trans, syncable::GET_BY_SERVER_TAG, ModelTypeToRootTag(type)); - return entry.good() && entry.Get(syncable::BASE_VERSION) != CHANGES_VERSION; + return entry.good() && entry.GetBaseVersion() != CHANGES_VERSION; } string Directory::store_birthday() const { @@ -993,11 +993,11 @@ bool Directory::CheckTreeInvariants(syncable::BaseTransaction* trans, Entry e(trans, GET_BY_HANDLE, metahandle); if (!SyncAssert(e.good(), FROM_HERE, "Entry is bad", trans)) return false; - syncable::Id id = e.Get(ID); - syncable::Id parentid = e.Get(PARENT_ID); + syncable::Id id = e.GetId(); + syncable::Id parentid = e.GetParentId(); if (id.IsRoot()) { - if (!SyncAssert(e.Get(IS_DIR), FROM_HERE, + if (!SyncAssert(e.GetIsDir(), FROM_HERE, "Entry should be a directory", trans)) return false; @@ -1005,19 +1005,19 @@ bool Directory::CheckTreeInvariants(syncable::BaseTransaction* trans, "Entry should be root", trans)) return false; - if (!SyncAssert(!e.Get(IS_UNSYNCED), FROM_HERE, + if (!SyncAssert(!e.GetIsUnsynced(), FROM_HERE, "Entry should be sycned", trans)) return false; continue; } - if (!e.Get(IS_DEL)) { + if (!e.GetIsDel()) { if (!SyncAssert(id != parentid, FROM_HERE, "Id should be different from parent id.", trans)) return false; - if (!SyncAssert(!e.Get(NON_UNIQUE_NAME).empty(), FROM_HERE, + if (!SyncAssert(!e.GetNonUniqueName().empty(), FROM_HERE, "Non unique name should not be empty.", trans)) return false; @@ -1028,37 +1028,37 @@ bool Directory::CheckTreeInvariants(syncable::BaseTransaction* trans, "Parent entry is not valid.", trans)) return false; - if (handles.end() == handles.find(parent.Get(META_HANDLE))) + if (handles.end() == handles.find(parent.GetMetahandle())) break; // Skip further checking if parent was unmodified. - if (!SyncAssert(parent.Get(IS_DIR), FROM_HERE, + if (!SyncAssert(parent.GetIsDir(), FROM_HERE, "Parent should be a directory", trans)) return false; - if (!SyncAssert(!parent.Get(IS_DEL), FROM_HERE, + if (!SyncAssert(!parent.GetIsDel(), FROM_HERE, "Parent should not have been marked for deletion.", trans)) return false; - if (!SyncAssert(handles.end() != handles.find(parent.Get(META_HANDLE)), + if (!SyncAssert(handles.end() != handles.find(parent.GetMetahandle()), FROM_HERE, "Parent should be in the index.", trans)) return false; - parentid = parent.Get(PARENT_ID); + parentid = parent.GetParentId(); if (!SyncAssert(--safety_count > 0, FROM_HERE, "Count should be greater than zero.", trans)) return false; } } - int64 base_version = e.Get(BASE_VERSION); - int64 server_version = e.Get(SERVER_VERSION); - bool using_unique_client_tag = !e.Get(UNIQUE_CLIENT_TAG).empty(); + int64 base_version = e.GetBaseVersion(); + int64 server_version = e.GetServerVersion(); + bool using_unique_client_tag = !e.GetUniqueClientTag().empty(); if (CHANGES_VERSION == base_version || 0 == base_version) { - if (e.Get(IS_UNAPPLIED_UPDATE)) { + if (e.GetIsUnappliedUpdate()) { // Must be a new item, or a de-duplicated unique client tag // that was created both locally and remotely. if (!using_unique_client_tag) { - if (!SyncAssert(e.Get(IS_DEL), FROM_HERE, + if (!SyncAssert(e.GetIsDel(), FROM_HERE, "The entry should not have been deleted.", trans)) return false; @@ -1069,7 +1069,7 @@ bool Directory::CheckTreeInvariants(syncable::BaseTransaction* trans, trans)) return false; } else { - if (e.Get(IS_DIR)) { + if (e.GetIsDir()) { // TODO(chron): Implement this mode if clients ever need it. // For now, you can't combine a client tag and a directory. if (!SyncAssert(!using_unique_client_tag, FROM_HERE, @@ -1078,8 +1078,8 @@ bool Directory::CheckTreeInvariants(syncable::BaseTransaction* trans, return false; } // Should be an uncomitted item, or a successfully deleted one. - if (!e.Get(IS_DEL)) { - if (!SyncAssert(e.Get(IS_UNSYNCED), FROM_HERE, + if (!e.GetIsDel()) { + if (!SyncAssert(e.GetIsUnsynced(), FROM_HERE, "The item should be unsynced.", trans)) return false; @@ -1112,9 +1112,8 @@ bool Directory::CheckTreeInvariants(syncable::BaseTransaction* trans, } // Server-unknown items that are locally deleted should not be sent up to // the server. They must be !IS_UNSYNCED. - if (!SyncAssert(!(!id.ServerKnows() && - e.Get(IS_DEL) && - e.Get(IS_UNSYNCED)), FROM_HERE, + if (!SyncAssert(!(!id.ServerKnows() && e.GetIsDel() && e.GetIsUnsynced()), + FROM_HERE, "Locally deleted item must not be unsynced.", trans)) { return false; diff --git a/sync/syncable/entry.cc b/sync/syncable/entry.cc index 7739098..3891c55 100644 --- a/sync/syncable/entry.cc +++ b/sync/syncable/entry.cc @@ -56,11 +56,6 @@ base::DictionaryValue* Entry::ToValue(Cryptographer* cryptographer) const { return entry_info; } -const string& Entry::Get(StringField field) const { - DCHECK(kernel_); - return kernel_->ref(field); -} - ModelType Entry::GetServerModelType() const { ModelType specifics_type = kernel_->GetServerModelType(); if (specifics_type != UNSPECIFIED) @@ -70,23 +65,23 @@ ModelType Entry::GetServerModelType() const { // if the item is an uncommitted locally created item. // It's possible we'll need to relax these checks in the future; they're // just here for now as a safety measure. - DCHECK(Get(IS_UNSYNCED)); - DCHECK_EQ(Get(SERVER_VERSION), 0); - DCHECK(Get(SERVER_IS_DEL)); - // Note: can't enforce !Get(ID).ServerKnows() here because that could + DCHECK(GetIsUnsynced()); + DCHECK_EQ(GetServerVersion(), 0); + DCHECK(GetServerIsDel()); + // Note: can't enforce !GetId().ServerKnows() here because that could // actually happen if we hit AttemptReuniteLostCommitResponses. return UNSPECIFIED; } ModelType Entry::GetModelType() const { - ModelType specifics_type = GetModelTypeFromSpecifics(Get(SPECIFICS)); + ModelType specifics_type = GetModelTypeFromSpecifics(GetSpecifics()); if (specifics_type != UNSPECIFIED) return specifics_type; if (IsRoot()) return TOP_LEVEL_FOLDER; // Loose check for server-created top-level folders that aren't // bound to a particular model type. - if (!Get(UNIQUE_SERVER_TAG).empty() && Get(IS_DIR)) + if (!GetUniqueServerTag().empty() && GetIsDir()) return TOP_LEVEL_FOLDER; return UNSPECIFIED; @@ -105,7 +100,7 @@ Id Entry::GetFirstChildId() const { } void Entry::GetChildHandles(std::vector<int64>* result) const { - dir()->GetChildHandlesById(basetrans_, Get(ID), result); + dir()->GetChildHandlesById(basetrans_, GetId(), result); } int Entry::GetTotalNodeCount() const { diff --git a/sync/syncable/entry.h b/sync/syncable/entry.h index 177dc5d..09ff9c7 100644 --- a/sync/syncable/entry.h +++ b/sync/syncable/entry.h @@ -56,50 +56,149 @@ class SYNC_EXPORT Entry { BaseTransaction* trans() const { return basetrans_; } // Field accessors. - inline int64 Get(MetahandleField field) const { + int64 GetMetahandle() const { DCHECK(kernel_); - return kernel_->ref(field); + return kernel_->ref(META_HANDLE); } - inline Id Get(IdField field) const { + + int64 GetBaseVersion() const { + DCHECK(kernel_); + return kernel_->ref(BASE_VERSION); + } + + int64 GetServerVersion() const { + DCHECK(kernel_); + return kernel_->ref(SERVER_VERSION); + } + + int64 GetLocalExternalId() const { + DCHECK(kernel_); + return kernel_->ref(LOCAL_EXTERNAL_ID); + } + + int64 GetTransactionVersion() const { + DCHECK(kernel_); + return kernel_->ref(TRANSACTION_VERSION); + } + + const base::Time& GetMtime() const { + DCHECK(kernel_); + return kernel_->ref(MTIME); + } + + const base::Time& GetServerMtime() const { + DCHECK(kernel_); + return kernel_->ref(SERVER_MTIME); + } + + const base::Time& GetCtime() const { + DCHECK(kernel_); + return kernel_->ref(CTIME); + } + + const base::Time& GetServerCtime() const { + DCHECK(kernel_); + return kernel_->ref(SERVER_CTIME); + } + + Id GetId() const { + DCHECK(kernel_); + return kernel_->ref(ID); + } + + Id GetParentId() const { + DCHECK(kernel_); + return kernel_->ref(PARENT_ID); + } + + Id GetServerParentId() const { + DCHECK(kernel_); + return kernel_->ref(SERVER_PARENT_ID); + } + + bool GetIsUnsynced() const { + DCHECK(kernel_); + return kernel_->ref(IS_UNSYNCED); + } + + bool GetIsUnappliedUpdate() const { + DCHECK(kernel_); + return kernel_->ref(IS_UNAPPLIED_UPDATE); + } + + bool GetIsDel() const { + DCHECK(kernel_); + return kernel_->ref(IS_DEL); + } + + bool GetIsDir() const { + DCHECK(kernel_); + return kernel_->ref(IS_DIR); + } + + bool GetServerIsDir() const { + DCHECK(kernel_); + return kernel_->ref(SERVER_IS_DIR); + } + + bool GetServerIsDel() const { + DCHECK(kernel_); + return kernel_->ref(SERVER_IS_DEL); + } + + const std::string& GetNonUniqueName() const { DCHECK(kernel_); - return kernel_->ref(field); + return kernel_->ref(NON_UNIQUE_NAME); } - inline int64 Get(Int64Field field) const { + + const std::string& GetServerNonUniqueName() const { + DCHECK(kernel_); + return kernel_->ref(SERVER_NON_UNIQUE_NAME); + } + + const std::string& GetUniqueServerTag() const { DCHECK(kernel_); - return kernel_->ref(field); + return kernel_->ref(UNIQUE_SERVER_TAG); } - inline const base::Time& Get(TimeField field) const { + + const std::string& GetUniqueClientTag() const { DCHECK(kernel_); - return kernel_->ref(field); + return kernel_->ref(UNIQUE_CLIENT_TAG); } - inline int64 Get(BaseVersion field) const { + + const std::string& GetUniqueBookmarkTag() const { DCHECK(kernel_); - return kernel_->ref(field); + return kernel_->ref(UNIQUE_BOOKMARK_TAG); } - inline bool Get(IndexedBitField field) const { + + const sync_pb::EntitySpecifics& GetSpecifics() const { DCHECK(kernel_); - return kernel_->ref(field); + return kernel_->ref(SPECIFICS); } - inline bool Get(IsDelField field) const { + + const sync_pb::EntitySpecifics& GetServerSpecifics() const { DCHECK(kernel_); - return kernel_->ref(field); + return kernel_->ref(SERVER_SPECIFICS); } - inline bool Get(BitField field) const { + + const sync_pb::EntitySpecifics& GetBaseServerSpecifics() const { DCHECK(kernel_); - return kernel_->ref(field); + return kernel_->ref(BASE_SERVER_SPECIFICS); } - const std::string& Get(StringField field) const; - inline const sync_pb::EntitySpecifics& Get(ProtoField field) const { + + const UniquePosition& GetServerUniquePosition() const { DCHECK(kernel_); - return kernel_->ref(field); + return kernel_->ref(SERVER_UNIQUE_POSITION); } - inline const UniquePosition& Get(UniquePositionField field) const { + + const UniquePosition& GetUniquePosition() const { DCHECK(kernel_); - return kernel_->ref(field); + return kernel_->ref(UNIQUE_POSITION); } - inline bool Get(BitTemp field) const { + + bool GetSyncing() const { DCHECK(kernel_); - return kernel_->ref(field); + return kernel_->ref(SYNCING); } ModelType GetServerModelType() const; diff --git a/sync/syncable/mutable_entry.cc b/sync/syncable/mutable_entry.cc index 9562f31..d85a9c6 100644 --- a/sync/syncable/mutable_entry.cc +++ b/sync/syncable/mutable_entry.cc @@ -66,7 +66,7 @@ MutableEntry::MutableEntry(WriteTransaction* trans, if (model_type == BOOKMARKS) { // Base the tag off of our cache-guid and local "c-" style ID. std::string unique_tag = syncable::GenerateSyncableBookmarkHash( - trans->directory()->cache_guid(), Get(ID).GetServerId()); + trans->directory()->cache_guid(), GetId().GetServerId()); kernel_->put(UNIQUE_BOOKMARK_TAG, unique_tag); kernel_->put(UNIQUE_POSITION, UniquePosition::InitialPosition(unique_tag)); } else { @@ -120,6 +120,99 @@ MutableEntry::MutableEntry(WriteTransaction* trans, GetByServerTag, : Entry(trans, GET_BY_SERVER_TAG, tag), write_transaction_(trans) { } +void MutableEntry::PutBaseVersion(int64 value) { + Put(BASE_VERSION, value); +} + +void MutableEntry::PutServerVersion(int64 value) { + Put(SERVER_VERSION, value); +} + +void MutableEntry::PutLocalExternalId(int64 value) { + Put(LOCAL_EXTERNAL_ID, value); +} + +void MutableEntry::PutMtime(base::Time value) { + Put(MTIME, value); +} + +void MutableEntry::PutServerMtime(base::Time value) { + Put(SERVER_MTIME, value); +} + +void MutableEntry::PutCtime(base::Time value) { + Put(CTIME, value); +} + +void MutableEntry::PutServerCtime(base::Time value) { + Put(SERVER_CTIME, value); +} + +bool MutableEntry::PutId(const Id& value) { + return Put(ID, value); +} + +void MutableEntry::PutParentId(const Id& value) { + Put(PARENT_ID, value); +} + +void MutableEntry::PutServerParentId(const Id& value) { + Put(SERVER_PARENT_ID, value); +} + +bool MutableEntry::PutIsUnsynced(bool value) { + return Put(IS_UNSYNCED, value); +} + +bool MutableEntry::PutIsUnappliedUpdate(bool value) { + return Put(IS_UNAPPLIED_UPDATE, value); +} + +void MutableEntry::PutIsDir(bool value) { + Put(IS_DIR, value); +} + +void MutableEntry::PutServerIsDir(bool value) { + Put(SERVER_IS_DIR, value); +} + +void MutableEntry::PutServerIsDel(bool value) { + Put(SERVER_IS_DEL, value); +} + +void MutableEntry::PutNonUniqueName(const std::string& value) { + Put(NON_UNIQUE_NAME, value); +} + +void MutableEntry::PutServerNonUniqueName(const std::string& value) { + Put(SERVER_NON_UNIQUE_NAME, value); +} + +void MutableEntry::PutSpecifics(const sync_pb::EntitySpecifics& value) { + Put(SPECIFICS, value); +} + +void MutableEntry::PutServerSpecifics(const sync_pb::EntitySpecifics& value) { + Put(SERVER_SPECIFICS, value); +} + +void MutableEntry::PutBaseServerSpecifics( + const sync_pb::EntitySpecifics& value) { + Put(BASE_SERVER_SPECIFICS, value); +} + +void MutableEntry::PutUniquePosition(const UniquePosition& value) { + Put(UNIQUE_POSITION, value); +} + +void MutableEntry::PutServerUniquePosition(const UniquePosition& value) { + Put(SERVER_UNIQUE_POSITION, value); +} + +void MutableEntry::PutSyncing(bool value) { + Put(SYNCING, value); +} + bool MutableEntry::PutIsDel(bool is_del) { DCHECK(kernel_); write_transaction_->SaveOriginal(kernel_); @@ -135,7 +228,7 @@ bool MutableEntry::PutIsDel(bool is_del) { // - Let us delete this entry permanently through // DirectoryBackingStore::DropDeletedEntries() when we next restart sync. // This will save memory and avoid crbug.com/125381. - if (!Get(ID).ServerKnows()) { + if (!GetId().ServerKnows()) { Put(IS_UNSYNCED, false); } } @@ -188,7 +281,7 @@ bool MutableEntry::Put(IdField field, const Id& value) { return false; } else if (PARENT_ID == field) { PutParentIdPropertyOnly(value); - if (!Get(IS_DEL)) { + if (!GetIsDel()) { if (!PutPredecessor(Id())) { // TODO(lipalani) : Propagate the error to caller. crbug.com/100444. NOTREACHED(); @@ -453,9 +546,9 @@ void MutableEntry::UpdateTransactionVersion(int64 value) { bool MarkForSyncing(MutableEntry* e) { DCHECK_NE(static_cast<MutableEntry*>(NULL), e); DCHECK(!e->IsRoot()) << "We shouldn't mark a permanent object for syncing."; - if (!(e->Put(IS_UNSYNCED, true))) + if (!(e->PutIsUnsynced(true))) return false; - e->Put(SYNCING, false); + e->PutSyncing(false); return true; } diff --git a/sync/syncable/mutable_entry.h b/sync/syncable/mutable_entry.h index 9bc01b9..2a5a047 100644 --- a/sync/syncable/mutable_entry.h +++ b/sync/syncable/mutable_entry.h @@ -45,13 +45,36 @@ class SYNC_EXPORT_PRIVATE MutableEntry : public Entry { } // Field Accessors. Some of them trigger the re-indexing of the entry. - // Return true on success, return false on failure, which means - // that putting the value would have caused a duplicate in the index. - // TODO(chron): Remove some of these unecessary return values. - bool Put(Int64Field field, const int64& value); - bool Put(TimeField field, const base::Time& value); - bool Put(IdField field, const Id& value); - bool Put(UniquePositionField field, const UniquePosition& value); + // Return true on success, return false on failure, which means that putting + // the value would have caused a duplicate in the index. The setters that + // never fail return void. + void PutBaseVersion(int64 value); + void PutServerVersion(int64 value); + void PutLocalExternalId(int64 value); + void PutMtime(base::Time value); + void PutServerMtime(base::Time value); + void PutCtime(base::Time value); + void PutServerCtime(base::Time value); + bool PutId(const Id& value); + void PutParentId(const Id& value); + void PutServerParentId(const Id& value); + bool PutIsUnsynced(bool value); + bool PutIsUnappliedUpdate(bool value); + void PutIsDir(bool value); + void PutServerIsDir(bool value); + bool PutIsDel(bool value); + void PutServerIsDel(bool value); + void PutNonUniqueName(const std::string& value); + void PutServerNonUniqueName(const std::string& value); + bool PutUniqueServerTag(const std::string& value); + bool PutUniqueClientTag(const std::string& value); + void PutUniqueBookmarkTag(const std::string& tag); + void PutSpecifics(const sync_pb::EntitySpecifics& value); + void PutServerSpecifics(const sync_pb::EntitySpecifics& value); + void PutBaseServerSpecifics(const sync_pb::EntitySpecifics& value); + void PutUniquePosition(const UniquePosition& value); + void PutServerUniquePosition(const UniquePosition& value); + void PutSyncing(bool value); // Do a simple property-only update if the PARENT_ID field. Use with caution. // @@ -64,26 +87,12 @@ class SYNC_EXPORT_PRIVATE MutableEntry : public Entry { // if you're not careful. void PutParentIdPropertyOnly(const Id& parent_id); - bool Put(StringField field, const std::string& value); - bool Put(BaseVersion field, int64 value); - - bool Put(ProtoField field, const sync_pb::EntitySpecifics& value); - bool Put(BitField field, bool value); - inline bool Put(IsDelField field, bool value) { - return PutIsDel(value); - } - bool Put(IndexedBitField field, bool value); - - void PutUniqueBookmarkTag(const std::string& tag); - // Sets the position of this item, and updates the entry kernels of the // adjacent siblings so that list invariants are maintained. Returns false // and fails if |predecessor_id| does not identify a sibling. Pass the root // ID to put the node in first position. bool PutPredecessor(const Id& predecessor_id); - bool Put(BitTemp field, bool value); - // This is similar to what one would expect from Put(TRANSACTION_VERSION), // except that it doesn't bother to invoke 'SaveOriginals'. Calling that // function is at best unnecessary, since the transaction will have already @@ -93,19 +102,25 @@ class SYNC_EXPORT_PRIVATE MutableEntry : public Entry { protected: syncable::MetahandleSet* GetDirtyIndexHelper(); - bool PutIsDel(bool value); - private: friend class Directory; friend class WriteTransaction; friend class syncer::WriteNode; + bool Put(Int64Field field, const int64& value); + bool Put(TimeField field, const base::Time& value); + bool Put(IdField field, const Id& value); + bool Put(StringField field, const std::string& value); + bool Put(BaseVersion field, int64 value); + bool Put(ProtoField field, const sync_pb::EntitySpecifics& value); + bool Put(BitTemp field, bool value); + bool Put(BitField field, bool value); + bool Put(IndexedBitField field, bool value); + bool Put(UniquePositionField field, const UniquePosition& value); + // Don't allow creation on heap, except by sync API wrappers. void* operator new(size_t size) { return (::operator new)(size); } - bool PutUniqueClientTag(const std::string& value); - bool PutUniqueServerTag(const std::string& value); - // Adjusts the successor and predecessor entries so that they no longer // refer to this entry. bool UnlinkFromOrder(); diff --git a/sync/syncable/nigori_util.cc b/sync/syncable/nigori_util.cc index 3da7917..9100e9d 100644 --- a/sync/syncable/nigori_util.cc +++ b/sync/syncable/nigori_util.cc @@ -37,7 +37,7 @@ bool ProcessUnsyncedChangesForEncryption( GetUnsyncedEntries(trans, &handles); for (size_t i = 0; i < handles.size(); ++i) { MutableEntry entry(trans, GET_BY_HANDLE, handles[i]); - const sync_pb::EntitySpecifics& specifics = entry.Get(SPECIFICS); + const sync_pb::EntitySpecifics& specifics = entry.GetSpecifics(); // Ignore types that don't need encryption or entries that are already // encrypted. if (!SpecificsNeedsEncryption(encrypted_types, specifics)) @@ -67,7 +67,7 @@ bool VerifyUnsyncedChangesAreEncrypted( bool EntryNeedsEncryption(ModelTypeSet encrypted_types, const Entry& entry) { - if (!entry.Get(UNIQUE_SERVER_TAG).empty()) + if (!entry.GetUniqueServerTag().empty()) return false; // We don't encrypt unique server nodes. ModelType type = entry.GetModelType(); if (type == PASSWORDS || IsControlType(type)) @@ -75,9 +75,9 @@ bool EntryNeedsEncryption(ModelTypeSet encrypted_types, // Checking NON_UNIQUE_NAME is not necessary for the correctness of encrypting // the data, nor for determining if data is encrypted. We simply ensure it has // been overwritten to avoid any possible leaks of sensitive data. - return SpecificsNeedsEncryption(encrypted_types, entry.Get(SPECIFICS)) || + return SpecificsNeedsEncryption(encrypted_types, entry.GetSpecifics()) || (encrypted_types.Has(type) && - entry.Get(NON_UNIQUE_NAME) != kEncryptedString); + entry.GetNonUniqueName() != kEncryptedString); } bool SpecificsNeedsEncryption(ModelTypeSet encrypted_types, @@ -121,20 +121,20 @@ bool VerifyDataTypeEncryptionForTest( NOTREACHED(); return false; } - if (child.Get(IS_DIR)) { + if (child.GetIsDir()) { Id child_id_string = child.GetFirstChildId(); // Traverse the children. to_visit.push(child_id_string); } - const sync_pb::EntitySpecifics& specifics = child.Get(SPECIFICS); + const sync_pb::EntitySpecifics& specifics = child.GetSpecifics(); DCHECK_EQ(type, child.GetModelType()); DCHECK_EQ(type, GetModelTypeFromSpecifics(specifics)); // We don't encrypt the server's permanent items. - if (child.Get(UNIQUE_SERVER_TAG).empty()) { + if (child.GetUniqueServerTag().empty()) { if (specifics.has_encrypted() != is_encrypted) return false; if (specifics.has_encrypted()) { - if (child.Get(NON_UNIQUE_NAME) != kEncryptedString) + if (child.GetNonUniqueName() != kEncryptedString) return false; if (!cryptographer->CanDecryptUsingDefaultKey(specifics.encrypted())) return false; @@ -154,7 +154,7 @@ bool UpdateEntryWithEncryption( Cryptographer* cryptographer = trans->directory()->GetCryptographer(trans); ModelType type = GetModelTypeFromSpecifics(new_specifics); DCHECK_GE(type, FIRST_REAL_MODEL_TYPE); - const sync_pb::EntitySpecifics& old_specifics = entry->Get(SPECIFICS); + const sync_pb::EntitySpecifics& old_specifics = entry->GetSpecifics(); const ModelTypeSet encrypted_types = nigori_handler->GetEncryptedTypes(trans); // It's possible the nigori lost the set of encrypted types. If the current // specifics are already encrypted, we want to ensure we continue encrypting. @@ -205,7 +205,7 @@ bool UpdateEntryWithEncryption( // It's possible this entry was encrypted but didn't properly overwrite the // non_unique_name (see crbug.com/96314). bool encrypted_without_overwriting_name = (was_encrypted && - entry->Get(syncable::NON_UNIQUE_NAME) != kEncryptedString); + entry->GetNonUniqueName() != kEncryptedString); // If we're encrypted but the name wasn't overwritten properly we still want // to rewrite the entry, irrespective of whether the specifics match. @@ -219,18 +219,18 @@ bool UpdateEntryWithEncryption( if (generated_specifics.has_encrypted()) { // Overwrite the possibly sensitive non-specifics data. - entry->Put(syncable::NON_UNIQUE_NAME, kEncryptedString); + entry->PutNonUniqueName(kEncryptedString); // For bookmarks we actually put bogus data into the unencrypted specifics, // else the server will try to do it for us. if (type == BOOKMARKS) { sync_pb::BookmarkSpecifics* bookmark_specifics = generated_specifics.mutable_bookmark(); - if (!entry->Get(syncable::IS_DIR)) + if (!entry->GetIsDir()) bookmark_specifics->set_url(kEncryptedString); bookmark_specifics->set_title(kEncryptedString); } } - entry->Put(syncable::SPECIFICS, generated_specifics); + entry->PutSpecifics(generated_specifics); DVLOG(1) << "Overwriting specifics of type " << ModelTypeToString(type) << " and marking for syncing."; diff --git a/sync/syncable/nigori_util.h b/sync/syncable/nigori_util.h index c2f0040..7f57a72 100644 --- a/sync/syncable/nigori_util.h +++ b/sync/syncable/nigori_util.h @@ -62,7 +62,7 @@ SYNC_EXPORT_PRIVATE bool VerifyDataTypeEncryptionForTest( // Stores |new_specifics| into |entry|, encrypting if necessary. // Returns false if an error encrypting occurred (does not modify |entry|). -// Note: gracefully handles new_specifics aliasing with entry->Get(SPECIFICS). +// Note: gracefully handles new_specifics aliasing with entry->GetSpecifics(). bool UpdateEntryWithEncryption( BaseTransaction* const trans, const sync_pb::EntitySpecifics& new_specifics, diff --git a/sync/syncable/syncable_unittest.cc b/sync/syncable/syncable_unittest.cc index 2c4a964..cfcc2db 100644 --- a/sync/syncable/syncable_unittest.cc +++ b/sync/syncable/syncable_unittest.cc @@ -70,7 +70,7 @@ void PutDataAsBookmarkFavicon(WriteTransaction* wtrans, sync_pb::EntitySpecifics specifics; specifics.mutable_bookmark()->set_url("http://demo/"); specifics.mutable_bookmark()->set_favicon(bytes, bytes_length); - e->Put(SPECIFICS, specifics); + e->PutSpecifics(specifics); } void ExpectDataFromBookmarkFaviconEquals(BaseTransaction* trans, @@ -78,10 +78,10 @@ void ExpectDataFromBookmarkFaviconEquals(BaseTransaction* trans, const char* bytes, size_t bytes_length) { ASSERT_TRUE(e->good()); - ASSERT_TRUE(e->Get(SPECIFICS).has_bookmark()); - ASSERT_EQ("http://demo/", e->Get(SPECIFICS).bookmark().url()); + ASSERT_TRUE(e->GetSpecifics().has_bookmark()); + ASSERT_EQ("http://demo/", e->GetSpecifics().bookmark().url()); ASSERT_EQ(std::string(bytes, bytes_length), - e->Get(SPECIFICS).bookmark().favicon()); + e->GetSpecifics().bookmark().favicon()); } } // namespace @@ -122,7 +122,7 @@ TEST_F(SyncableGeneralTest, General) { ReadTransaction rtrans(FROM_HERE, &dir); Entry e(&rtrans, GET_BY_ID, rtrans.root_id()); ASSERT_TRUE(e.good()); - root_metahandle = e.Get(META_HANDLE); + root_metahandle = e.GetMetahandle(); } int64 written_metahandle; @@ -147,9 +147,9 @@ TEST_F(SyncableGeneralTest, General) { WriteTransaction wtrans(FROM_HERE, UNITTEST, &dir); MutableEntry me(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), name); ASSERT_TRUE(me.good()); - me.Put(ID, id); - me.Put(BASE_VERSION, 1); - written_metahandle = me.Get(META_HANDLE); + me.PutId(id); + me.PutBaseVersion(1); + written_metahandle = me.GetMetahandle(); } // Test GetChildHandles* after something is now in the DB. @@ -204,7 +204,7 @@ TEST_F(SyncableGeneralTest, General) { { WriteTransaction trans(FROM_HERE, UNITTEST, &dir); MutableEntry e(&trans, GET_BY_HANDLE, written_metahandle); - e.Put(IS_DEL, true); + e.PutIsDel(true); EXPECT_EQ(0, CountEntriesWithName(&trans, trans.root_id(), name)); } @@ -239,9 +239,9 @@ TEST_F(SyncableGeneralTest, ChildrenOps) { WriteTransaction wtrans(FROM_HERE, UNITTEST, &dir); MutableEntry me(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), name); ASSERT_TRUE(me.good()); - me.Put(ID, id); - me.Put(BASE_VERSION, 1); - written_metahandle = me.Get(META_HANDLE); + me.PutId(id); + me.PutBaseVersion(1); + written_metahandle = me.GetMetahandle(); } // Test children ops after something is now in the DB. @@ -256,14 +256,14 @@ TEST_F(SyncableGeneralTest, ChildrenOps) { Entry root(&rtrans, GET_BY_ID, rtrans.root_id()); ASSERT_TRUE(root.good()); EXPECT_TRUE(dir.HasChildren(&rtrans, rtrans.root_id())); - EXPECT_EQ(e.Get(ID), root.GetFirstChildId()); + EXPECT_EQ(e.GetId(), root.GetFirstChildId()); } { WriteTransaction wtrans(FROM_HERE, UNITTEST, &dir); MutableEntry me(&wtrans, GET_BY_HANDLE, written_metahandle); ASSERT_TRUE(me.good()); - me.Put(IS_DEL, true); + me.PutIsDel(true); } // Test children ops after the children have been deleted. @@ -301,10 +301,10 @@ TEST_F(SyncableGeneralTest, ClientIndexRebuildsProperly) { WriteTransaction wtrans(FROM_HERE, UNITTEST, &dir); MutableEntry me(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), name); ASSERT_TRUE(me.good()); - me.Put(ID, id); - me.Put(BASE_VERSION, 1); - me.Put(UNIQUE_CLIENT_TAG, tag); - written_metahandle = me.Get(META_HANDLE); + me.PutId(id); + me.PutBaseVersion(1); + me.PutUniqueClientTag(tag); + written_metahandle = me.GetMetahandle(); } dir.SaveChanges(); } @@ -322,10 +322,10 @@ TEST_F(SyncableGeneralTest, ClientIndexRebuildsProperly) { ReadTransaction trans(FROM_HERE, &dir); Entry me(&trans, GET_BY_CLIENT_TAG, tag); ASSERT_TRUE(me.good()); - EXPECT_EQ(me.Get(ID), id); - EXPECT_EQ(me.Get(BASE_VERSION), 1); - EXPECT_EQ(me.Get(UNIQUE_CLIENT_TAG), tag); - EXPECT_EQ(me.Get(META_HANDLE), written_metahandle); + EXPECT_EQ(me.GetId(), id); + EXPECT_EQ(me.GetBaseVersion(), 1); + EXPECT_EQ(me.GetUniqueClientTag(), tag); + EXPECT_EQ(me.GetMetahandle(), written_metahandle); } } @@ -347,11 +347,11 @@ TEST_F(SyncableGeneralTest, ClientIndexRebuildsDeletedProperly) { WriteTransaction wtrans(FROM_HERE, UNITTEST, &dir); MutableEntry me(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "deleted"); ASSERT_TRUE(me.good()); - me.Put(ID, id); - me.Put(BASE_VERSION, 1); - me.Put(UNIQUE_CLIENT_TAG, tag); - me.Put(IS_DEL, true); - me.Put(IS_UNSYNCED, true); // Or it might be purged. + me.PutId(id); + me.PutBaseVersion(1); + me.PutUniqueClientTag(tag); + me.PutIsDel(true); + me.PutIsUnsynced(true); // Or it might be purged. } dir.SaveChanges(); } @@ -370,10 +370,10 @@ TEST_F(SyncableGeneralTest, ClientIndexRebuildsDeletedProperly) { ReadTransaction trans(FROM_HERE, &dir); Entry me(&trans, GET_BY_CLIENT_TAG, tag); ASSERT_TRUE(me.good()); - EXPECT_EQ(me.Get(ID), id); - EXPECT_EQ(me.Get(UNIQUE_CLIENT_TAG), tag); - EXPECT_TRUE(me.Get(IS_DEL)); - EXPECT_TRUE(me.Get(IS_UNSYNCED)); + EXPECT_EQ(me.GetId(), id); + EXPECT_EQ(me.GetUniqueClientTag(), tag); + EXPECT_TRUE(me.GetIsDel()); + EXPECT_TRUE(me.GetIsUnsynced()); } } @@ -402,8 +402,8 @@ TEST_F(SyncableGeneralTest, ToValue) { WriteTransaction wtrans(FROM_HERE, UNITTEST, &dir); MutableEntry me(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "new"); ASSERT_TRUE(me.good()); - me.Put(ID, id); - me.Put(BASE_VERSION, 1); + me.PutId(id); + me.PutBaseVersion(1); scoped_ptr<base::DictionaryValue> value(me.ToValue(NULL)); ExpectDictBooleanValue(true, *value, "good"); @@ -432,13 +432,13 @@ TEST_F(SyncableGeneralTest, BookmarkTagTest) { { WriteTransaction wtrans(FROM_HERE, UNITTEST, &dir); MutableEntry bm(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "bm"); - bm.Put(IS_UNSYNCED, true); + bm.PutIsUnsynced(true); // If this assertion fails, that might indicate that the algorithm used to // generate bookmark tags has been modified. This could have implications // for bookmark ordering. Please make sure you know what you're doing if // you intend to make such a change. - ASSERT_EQ("6wHRAb3kbnXV5GHrejp4/c1y5tw=", bm.Get(UNIQUE_BOOKMARK_TAG)); + ASSERT_EQ("6wHRAb3kbnXV5GHrejp4/c1y5tw=", bm.GetUniqueBookmarkTag()); } } @@ -531,8 +531,8 @@ class SyncableDirectoryTest : public testing::Test { WriteTransaction wtrans(FROM_HERE, UNITTEST, dir_.get()); MutableEntry me(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), entryname); ASSERT_TRUE(me.good()); - me.Put(ID, id); - me.Put(IS_UNSYNCED, true); + me.PutId(id); + me.PutIsUnsynced(true); } void ValidateEntry(BaseTransaction* trans, @@ -570,18 +570,18 @@ TEST_F(SyncableDirectoryTest, TakeSnapshotGetsMetahandlesToPurge) { WriteTransaction trans(FROM_HERE, UNITTEST, dir_.get()); for (int i = 0; i < metas_to_create; i++) { MutableEntry e(&trans, CREATE, BOOKMARKS, trans.root_id(), "foo"); - e.Put(IS_UNSYNCED, true); + e.PutIsUnsynced(true); sync_pb::EntitySpecifics specs; if (i % 2 == 0) { AddDefaultFieldValue(BOOKMARKS, &specs); - expected_purges.insert(e.Get(META_HANDLE)); - all_handles.insert(e.Get(META_HANDLE)); + expected_purges.insert(e.GetMetahandle()); + all_handles.insert(e.GetMetahandle()); } else { AddDefaultFieldValue(PREFERENCES, &specs); - all_handles.insert(e.Get(META_HANDLE)); + all_handles.insert(e.GetMetahandle()); } - e.Put(SPECIFICS, specs); - e.Put(SERVER_SPECIFICS, specs); + e.PutSpecifics(specs); + e.PutServerSpecifics(specs); } } @@ -611,8 +611,8 @@ TEST_F(SyncableDirectoryTest, TakeSnapshotGetsAllDirtyHandlesTest) { WriteTransaction trans(FROM_HERE, UNITTEST, dir_.get()); for (int i = 0; i < metahandles_to_create; i++) { MutableEntry e(&trans, CREATE, BOOKMARKS, trans.root_id(), "foo"); - expected_dirty_metahandles.push_back(e.Get(META_HANDLE)); - e.Put(IS_UNSYNCED, true); + expected_dirty_metahandles.push_back(e.GetMetahandle()); + e.PutIsUnsynced(true); } } // Fake SaveChanges() and make sure we got what we expected. @@ -638,12 +638,12 @@ TEST_F(SyncableDirectoryTest, TakeSnapshotGetsAllDirtyHandlesTest) { i != expected_dirty_metahandles.end(); ++i) { // Change existing entries to directories to dirty them. MutableEntry e1(&trans, GET_BY_HANDLE, *i); - e1.Put(IS_DIR, true); - e1.Put(IS_UNSYNCED, true); + e1.PutIsDir(true); + e1.PutIsUnsynced(true); // Add new entries MutableEntry e2(&trans, CREATE, BOOKMARKS, trans.root_id(), "bar"); - e2.Put(IS_UNSYNCED, true); - new_dirty_metahandles.push_back(e2.Get(META_HANDLE)); + e2.PutIsUnsynced(true); + new_dirty_metahandles.push_back(e2.GetMetahandle()); } expected_dirty_metahandles.insert(expected_dirty_metahandles.end(), new_dirty_metahandles.begin(), new_dirty_metahandles.end()); @@ -674,8 +674,8 @@ TEST_F(SyncableDirectoryTest, TakeSnapshotGetsOnlyDirtyHandlesTest) { WriteTransaction trans(FROM_HERE, UNITTEST, dir_.get()); for (int i = 0; i < metahandles_to_create; i++) { MutableEntry e(&trans, CREATE, BOOKMARKS, trans.root_id(), "foo"); - expected_dirty_metahandles.push_back(e.Get(META_HANDLE)); - e.Put(IS_UNSYNCED, true); + expected_dirty_metahandles.push_back(e.GetMetahandle()); + e.PutIsUnsynced(true); } } dir_->SaveChanges(); @@ -689,12 +689,12 @@ TEST_F(SyncableDirectoryTest, TakeSnapshotGetsOnlyDirtyHandlesTest) { // Change existing entries to directories to dirty them. MutableEntry e1(&trans, GET_BY_HANDLE, *i); ASSERT_TRUE(e1.good()); - e1.Put(IS_DIR, true); - e1.Put(IS_UNSYNCED, true); + e1.PutIsDir(true); + e1.PutIsUnsynced(true); // Add new entries MutableEntry e2(&trans, CREATE, BOOKMARKS, trans.root_id(), "bar"); - e2.Put(IS_UNSYNCED, true); - new_dirty_metahandles.push_back(e2.Get(META_HANDLE)); + e2.PutIsUnsynced(true); + new_dirty_metahandles.push_back(e2.GetMetahandle()); } expected_dirty_metahandles.insert(expected_dirty_metahandles.end(), new_dirty_metahandles.begin(), new_dirty_metahandles.end()); @@ -731,9 +731,9 @@ TEST_F(SyncableDirectoryTest, TakeSnapshotGetsOnlyDirtyHandlesTest) { ASSERT_TRUE(e.good()); should_change = !should_change; if (should_change) { - bool not_dir = !e.Get(IS_DIR); - e.Put(IS_DIR, not_dir); - e.Put(IS_UNSYNCED, true); + bool not_dir = !e.GetIsDir(); + e.PutIsDir(not_dir); + e.PutIsUnsynced(true); } } } @@ -771,14 +771,14 @@ TEST_F(SyncableDirectoryTest, ManageDeleteJournals) { WriteTransaction trans(FROM_HERE, UNITTEST, dir_.get()); MutableEntry item1(&trans, GET_BY_ID, id1); ASSERT_TRUE(item1.good()); - handle1 = item1.Get(META_HANDLE); - item1.Put(SPECIFICS, bookmark_specifics); - item1.Put(SERVER_SPECIFICS, bookmark_specifics); + handle1 = item1.GetMetahandle(); + item1.PutSpecifics(bookmark_specifics); + item1.PutServerSpecifics(bookmark_specifics); MutableEntry item2(&trans, GET_BY_ID, id2); ASSERT_TRUE(item2.good()); - handle2 = item2.Get(META_HANDLE); - item2.Put(SPECIFICS, bookmark_specifics); - item2.Put(SERVER_SPECIFICS, bookmark_specifics); + handle2 = item2.GetMetahandle(); + item2.PutSpecifics(bookmark_specifics); + item2.PutServerSpecifics(bookmark_specifics); } ASSERT_EQ(OPENED, SimulateSaveAndReloadDir()); } @@ -795,10 +795,10 @@ TEST_F(SyncableDirectoryTest, ManageDeleteJournals) { // delete journals. MutableEntry item1(&trans, GET_BY_ID, id1); ASSERT_TRUE(item1.good()); - item1.Put(SERVER_IS_DEL, true); + item1.PutServerIsDel(true); MutableEntry item2(&trans, GET_BY_ID, id2); ASSERT_TRUE(item2.good()); - item2.Put(SERVER_IS_DEL, true); + item2.PutServerIsDel(true); EntryKernel tmp; tmp.put(ID, id1); EXPECT_TRUE(delete_journal->delete_journals_.count(&tmp)); @@ -860,7 +860,7 @@ TEST_F(SyncableDirectoryTest, ManageDeleteJournals) { // Undelete item1. MutableEntry item1(&trans, GET_BY_ID, id1); ASSERT_TRUE(item1.good()); - item1.Put(SERVER_IS_DEL, false); + item1.PutServerIsDel(false); EXPECT_TRUE(delete_journal->delete_journals_.empty()); EXPECT_EQ(1u, delete_journal->delete_journals_to_purge_.size()); EXPECT_TRUE(delete_journal->delete_journals_to_purge_.count(handle1)); @@ -898,21 +898,21 @@ TEST_F(SyncableDirectoryTest, TestDelete) { WriteTransaction trans(FROM_HERE, UNITTEST, dir_.get()); MutableEntry e1(&trans, CREATE, BOOKMARKS, trans.root_id(), name); ASSERT_TRUE(e1.good()); - ASSERT_TRUE(e1.Put(IS_DEL, true)); + e1.PutIsDel(true); MutableEntry e2(&trans, CREATE, BOOKMARKS, trans.root_id(), name); ASSERT_TRUE(e2.good()); - ASSERT_TRUE(e2.Put(IS_DEL, true)); + e2.PutIsDel(true); MutableEntry e3(&trans, CREATE, BOOKMARKS, trans.root_id(), name); ASSERT_TRUE(e3.good()); - ASSERT_TRUE(e3.Put(IS_DEL, true)); + e3.PutIsDel(true); - ASSERT_TRUE(e1.Put(IS_DEL, false)); - ASSERT_TRUE(e2.Put(IS_DEL, false)); - ASSERT_TRUE(e3.Put(IS_DEL, false)); + e1.PutIsDel(false); + e2.PutIsDel(false); + e3.PutIsDel(false); - ASSERT_TRUE(e1.Put(IS_DEL, true)); - ASSERT_TRUE(e2.Put(IS_DEL, true)); - ASSERT_TRUE(e3.Put(IS_DEL, true)); + e1.PutIsDel(true); + e2.PutIsDel(true); + e3.PutIsDel(true); } TEST_F(SyncableDirectoryTest, TestGetUnsynced) { @@ -926,16 +926,16 @@ TEST_F(SyncableDirectoryTest, TestGetUnsynced) { MutableEntry e1(&trans, CREATE, BOOKMARKS, trans.root_id(), "abba"); ASSERT_TRUE(e1.good()); - handle1 = e1.Get(META_HANDLE); - e1.Put(BASE_VERSION, 1); - e1.Put(IS_DIR, true); - e1.Put(ID, TestIdFactory::FromNumber(101)); + handle1 = e1.GetMetahandle(); + e1.PutBaseVersion(1); + e1.PutIsDir(true); + e1.PutId(TestIdFactory::FromNumber(101)); - MutableEntry e2(&trans, CREATE, BOOKMARKS, e1.Get(ID), "bread"); + MutableEntry e2(&trans, CREATE, BOOKMARKS, e1.GetId(), "bread"); ASSERT_TRUE(e2.good()); - handle2 = e2.Get(META_HANDLE); - e2.Put(BASE_VERSION, 1); - e2.Put(ID, TestIdFactory::FromNumber(102)); + handle2 = e2.GetMetahandle(); + e2.PutBaseVersion(1); + e2.PutId(TestIdFactory::FromNumber(102)); } dir_->SaveChanges(); { @@ -946,7 +946,7 @@ TEST_F(SyncableDirectoryTest, TestGetUnsynced) { MutableEntry e3(&trans, GET_BY_HANDLE, handle1); ASSERT_TRUE(e3.good()); - e3.Put(IS_UNSYNCED, true); + e3.PutIsUnsynced(true); } dir_->SaveChanges(); { @@ -957,7 +957,7 @@ TEST_F(SyncableDirectoryTest, TestGetUnsynced) { MutableEntry e4(&trans, GET_BY_HANDLE, handle2); ASSERT_TRUE(e4.good()); - e4.Put(IS_UNSYNCED, true); + e4.PutIsUnsynced(true); } dir_->SaveChanges(); { @@ -973,9 +973,9 @@ TEST_F(SyncableDirectoryTest, TestGetUnsynced) { MutableEntry e5(&trans, GET_BY_HANDLE, handle1); ASSERT_TRUE(e5.good()); - ASSERT_TRUE(e5.Get(IS_UNSYNCED)); - ASSERT_TRUE(e5.Put(IS_UNSYNCED, false)); - ASSERT_FALSE(e5.Get(IS_UNSYNCED)); + ASSERT_TRUE(e5.GetIsUnsynced()); + ASSERT_TRUE(e5.PutIsUnsynced(false)); + ASSERT_FALSE(e5.GetIsUnsynced()); } dir_->SaveChanges(); { @@ -998,18 +998,18 @@ TEST_F(SyncableDirectoryTest, TestGetUnappliedUpdates) { MutableEntry e1(&trans, CREATE, BOOKMARKS, trans.root_id(), "abba"); ASSERT_TRUE(e1.good()); - handle1 = e1.Get(META_HANDLE); - e1.Put(IS_UNAPPLIED_UPDATE, false); - e1.Put(BASE_VERSION, 1); - e1.Put(ID, TestIdFactory::FromNumber(101)); - e1.Put(IS_DIR, true); + handle1 = e1.GetMetahandle(); + e1.PutIsUnappliedUpdate(false); + e1.PutBaseVersion(1); + e1.PutId(TestIdFactory::FromNumber(101)); + e1.PutIsDir(true); - MutableEntry e2(&trans, CREATE, BOOKMARKS, e1.Get(ID), "bread"); + MutableEntry e2(&trans, CREATE, BOOKMARKS, e1.GetId(), "bread"); ASSERT_TRUE(e2.good()); - handle2 = e2.Get(META_HANDLE); - e2.Put(IS_UNAPPLIED_UPDATE, false); - e2.Put(BASE_VERSION, 1); - e2.Put(ID, TestIdFactory::FromNumber(102)); + handle2 = e2.GetMetahandle(); + e2.PutIsUnappliedUpdate(false); + e2.PutBaseVersion(1); + e2.PutId(TestIdFactory::FromNumber(102)); } dir_->SaveChanges(); { @@ -1020,7 +1020,7 @@ TEST_F(SyncableDirectoryTest, TestGetUnappliedUpdates) { MutableEntry e3(&trans, GET_BY_HANDLE, handle1); ASSERT_TRUE(e3.good()); - e3.Put(IS_UNAPPLIED_UPDATE, true); + e3.PutIsUnappliedUpdate(true); } dir_->SaveChanges(); { @@ -1031,7 +1031,7 @@ TEST_F(SyncableDirectoryTest, TestGetUnappliedUpdates) { MutableEntry e4(&trans, GET_BY_HANDLE, handle2); ASSERT_TRUE(e4.good()); - e4.Put(IS_UNAPPLIED_UPDATE, true); + e4.PutIsUnappliedUpdate(true); } dir_->SaveChanges(); { @@ -1047,7 +1047,7 @@ TEST_F(SyncableDirectoryTest, TestGetUnappliedUpdates) { MutableEntry e5(&trans, GET_BY_HANDLE, handle1); ASSERT_TRUE(e5.good()); - e5.Put(IS_UNAPPLIED_UPDATE, false); + e5.PutIsUnappliedUpdate(false); } dir_->SaveChanges(); { @@ -1067,36 +1067,36 @@ TEST_F(SyncableDirectoryTest, DeleteBug_531383) { WriteTransaction wtrans(FROM_HERE, UNITTEST, dir_.get()); MutableEntry parent(&wtrans, CREATE, BOOKMARKS, id_factory.root(), "Bob"); ASSERT_TRUE(parent.good()); - parent.Put(IS_DIR, true); - parent.Put(ID, id_factory.NewServerId()); - parent.Put(BASE_VERSION, 1); - MutableEntry child(&wtrans, CREATE, BOOKMARKS, parent.Get(ID), "Bob"); + parent.PutIsDir(true); + parent.PutId(id_factory.NewServerId()); + parent.PutBaseVersion(1); + MutableEntry child(&wtrans, CREATE, BOOKMARKS, parent.GetId(), "Bob"); ASSERT_TRUE(child.good()); - child.Put(IS_DIR, true); - child.Put(ID, id_factory.NewServerId()); - child.Put(BASE_VERSION, 1); - MutableEntry grandchild(&wtrans, CREATE, BOOKMARKS, child.Get(ID), "Bob"); + child.PutIsDir(true); + child.PutId(id_factory.NewServerId()); + child.PutBaseVersion(1); + MutableEntry grandchild(&wtrans, CREATE, BOOKMARKS, child.GetId(), "Bob"); ASSERT_TRUE(grandchild.good()); - grandchild.Put(ID, id_factory.NewServerId()); - grandchild.Put(BASE_VERSION, 1); - ASSERT_TRUE(grandchild.Put(IS_DEL, true)); - MutableEntry twin(&wtrans, CREATE, BOOKMARKS, child.Get(ID), "Bob"); + grandchild.PutId(id_factory.NewServerId()); + grandchild.PutBaseVersion(1); + grandchild.PutIsDel(true); + MutableEntry twin(&wtrans, CREATE, BOOKMARKS, child.GetId(), "Bob"); ASSERT_TRUE(twin.good()); - ASSERT_TRUE(twin.Put(IS_DEL, true)); - ASSERT_TRUE(grandchild.Put(IS_DEL, false)); + twin.PutIsDel(true); + grandchild.PutIsDel(false); - grandchild_handle = grandchild.Get(META_HANDLE); + grandchild_handle = grandchild.GetMetahandle(); } dir_->SaveChanges(); { WriteTransaction wtrans(FROM_HERE, UNITTEST, dir_.get()); MutableEntry grandchild(&wtrans, GET_BY_HANDLE, grandchild_handle); - grandchild.Put(IS_DEL, true); // Used to CHECK fail here. + grandchild.PutIsDel(true); // Used to CHECK fail here. } } static inline bool IsLegalNewParent(const Entry& a, const Entry& b) { - return IsLegalNewParent(a.trans(), a.Get(ID), b.Get(ID)); + return IsLegalNewParent(a.trans(), a.GetId(), b.GetId()); } TEST_F(SyncableDirectoryTest, TestIsLegalNewParent) { @@ -1104,35 +1104,35 @@ TEST_F(SyncableDirectoryTest, TestIsLegalNewParent) { WriteTransaction wtrans(FROM_HERE, UNITTEST, dir_.get()); Entry root(&wtrans, GET_BY_ID, id_factory.root()); ASSERT_TRUE(root.good()); - MutableEntry parent(&wtrans, CREATE, BOOKMARKS, root.Get(ID), "Bob"); + MutableEntry parent(&wtrans, CREATE, BOOKMARKS, root.GetId(), "Bob"); ASSERT_TRUE(parent.good()); - parent.Put(IS_DIR, true); - parent.Put(ID, id_factory.NewServerId()); - parent.Put(BASE_VERSION, 1); - MutableEntry child(&wtrans, CREATE, BOOKMARKS, parent.Get(ID), "Bob"); + parent.PutIsDir(true); + parent.PutId(id_factory.NewServerId()); + parent.PutBaseVersion(1); + MutableEntry child(&wtrans, CREATE, BOOKMARKS, parent.GetId(), "Bob"); ASSERT_TRUE(child.good()); - child.Put(IS_DIR, true); - child.Put(ID, id_factory.NewServerId()); - child.Put(BASE_VERSION, 1); - MutableEntry grandchild(&wtrans, CREATE, BOOKMARKS, child.Get(ID), "Bob"); + child.PutIsDir(true); + child.PutId(id_factory.NewServerId()); + child.PutBaseVersion(1); + MutableEntry grandchild(&wtrans, CREATE, BOOKMARKS, child.GetId(), "Bob"); ASSERT_TRUE(grandchild.good()); - grandchild.Put(ID, id_factory.NewServerId()); - grandchild.Put(BASE_VERSION, 1); + grandchild.PutId(id_factory.NewServerId()); + grandchild.PutBaseVersion(1); - MutableEntry parent2(&wtrans, CREATE, BOOKMARKS, root.Get(ID), "Pete"); + MutableEntry parent2(&wtrans, CREATE, BOOKMARKS, root.GetId(), "Pete"); ASSERT_TRUE(parent2.good()); - parent2.Put(IS_DIR, true); - parent2.Put(ID, id_factory.NewServerId()); - parent2.Put(BASE_VERSION, 1); - MutableEntry child2(&wtrans, CREATE, BOOKMARKS, parent2.Get(ID), "Pete"); + parent2.PutIsDir(true); + parent2.PutId(id_factory.NewServerId()); + parent2.PutBaseVersion(1); + MutableEntry child2(&wtrans, CREATE, BOOKMARKS, parent2.GetId(), "Pete"); ASSERT_TRUE(child2.good()); - child2.Put(IS_DIR, true); - child2.Put(ID, id_factory.NewServerId()); - child2.Put(BASE_VERSION, 1); - MutableEntry grandchild2(&wtrans, CREATE, BOOKMARKS, child2.Get(ID), "Pete"); + child2.PutIsDir(true); + child2.PutId(id_factory.NewServerId()); + child2.PutBaseVersion(1); + MutableEntry grandchild2(&wtrans, CREATE, BOOKMARKS, child2.GetId(), "Pete"); ASSERT_TRUE(grandchild2.good()); - grandchild2.Put(ID, id_factory.NewServerId()); - grandchild2.Put(BASE_VERSION, 1); + grandchild2.PutId(id_factory.NewServerId()); + grandchild2.PutBaseVersion(1); // resulting tree // root // / | @@ -1163,15 +1163,15 @@ TEST_F(SyncableDirectoryTest, TestEntryIsInFolder) { WriteTransaction trans(FROM_HERE, UNITTEST, dir_.get()); MutableEntry folder(&trans, CREATE, BOOKMARKS, trans.root_id(), "folder"); ASSERT_TRUE(folder.good()); - EXPECT_TRUE(folder.Put(IS_DIR, true)); - EXPECT_TRUE(folder.Put(IS_UNSYNCED, true)); - folder_id = folder.Get(ID); + folder.PutIsDir(true); + EXPECT_TRUE(folder.PutIsUnsynced(true)); + folder_id = folder.GetId(); - MutableEntry entry(&trans, CREATE, BOOKMARKS, folder.Get(ID), entry_name); + MutableEntry entry(&trans, CREATE, BOOKMARKS, folder.GetId(), entry_name); ASSERT_TRUE(entry.good()); - entry_handle = entry.Get(META_HANDLE); - entry.Put(IS_UNSYNCED, true); - entry_id = entry.Get(ID); + entry_handle = entry.GetMetahandle(); + entry.PutIsUnsynced(true); + entry_id = entry.GetId(); } // Make sure we can find the entry in the folder. @@ -1182,9 +1182,9 @@ TEST_F(SyncableDirectoryTest, TestEntryIsInFolder) { Entry entry(&trans, GET_BY_ID, entry_id); ASSERT_TRUE(entry.good()); - EXPECT_EQ(entry_handle, entry.Get(META_HANDLE)); - EXPECT_TRUE(entry.Get(NON_UNIQUE_NAME) == entry_name); - EXPECT_TRUE(entry.Get(PARENT_ID) == folder_id); + EXPECT_EQ(entry_handle, entry.GetMetahandle()); + EXPECT_TRUE(entry.GetNonUniqueName()== entry_name); + EXPECT_TRUE(entry.GetParentId()== folder_id); } } @@ -1193,27 +1193,27 @@ TEST_F(SyncableDirectoryTest, TestParentIdIndexUpdate) { WriteTransaction wt(FROM_HERE, UNITTEST, dir_.get()); MutableEntry parent_folder(&wt, CREATE, BOOKMARKS, wt.root_id(), "folder1"); - parent_folder.Put(IS_UNSYNCED, true); - EXPECT_TRUE(parent_folder.Put(IS_DIR, true)); + parent_folder.PutIsUnsynced(true); + parent_folder.PutIsDir(true); MutableEntry parent_folder2(&wt, CREATE, BOOKMARKS, wt.root_id(), "folder2"); - parent_folder2.Put(IS_UNSYNCED, true); - EXPECT_TRUE(parent_folder2.Put(IS_DIR, true)); + parent_folder2.PutIsUnsynced(true); + parent_folder2.PutIsDir(true); - MutableEntry child(&wt, CREATE, BOOKMARKS, parent_folder.Get(ID), child_name); - EXPECT_TRUE(child.Put(IS_DIR, true)); - child.Put(IS_UNSYNCED, true); + MutableEntry child(&wt, CREATE, BOOKMARKS, parent_folder.GetId(), child_name); + child.PutIsDir(true); + child.PutIsUnsynced(true); ASSERT_TRUE(child.good()); EXPECT_EQ(0, CountEntriesWithName(&wt, wt.root_id(), child_name)); - EXPECT_EQ(parent_folder.Get(ID), child.Get(PARENT_ID)); - EXPECT_EQ(1, CountEntriesWithName(&wt, parent_folder.Get(ID), child_name)); - EXPECT_EQ(0, CountEntriesWithName(&wt, parent_folder2.Get(ID), child_name)); - child.Put(PARENT_ID, parent_folder2.Get(ID)); - EXPECT_EQ(parent_folder2.Get(ID), child.Get(PARENT_ID)); - EXPECT_EQ(0, CountEntriesWithName(&wt, parent_folder.Get(ID), child_name)); - EXPECT_EQ(1, CountEntriesWithName(&wt, parent_folder2.Get(ID), child_name)); + EXPECT_EQ(parent_folder.GetId(), child.GetParentId()); + EXPECT_EQ(1, CountEntriesWithName(&wt, parent_folder.GetId(), child_name)); + EXPECT_EQ(0, CountEntriesWithName(&wt, parent_folder2.GetId(), child_name)); + child.PutParentId(parent_folder2.GetId()); + EXPECT_EQ(parent_folder2.GetId(), child.GetParentId()); + EXPECT_EQ(0, CountEntriesWithName(&wt, parent_folder.GetId(), child_name)); + EXPECT_EQ(1, CountEntriesWithName(&wt, parent_folder2.GetId(), child_name)); } TEST_F(SyncableDirectoryTest, TestNoReindexDeletedItems) { @@ -1223,15 +1223,15 @@ TEST_F(SyncableDirectoryTest, TestNoReindexDeletedItems) { WriteTransaction trans(FROM_HERE, UNITTEST, dir_.get()); MutableEntry folder(&trans, CREATE, BOOKMARKS, trans.root_id(), folder_name); ASSERT_TRUE(folder.good()); - ASSERT_TRUE(folder.Put(IS_DIR, true)); - ASSERT_TRUE(folder.Put(IS_DEL, true)); + folder.PutIsDir(true); + folder.PutIsDel(true); EXPECT_EQ(0, CountEntriesWithName(&trans, trans.root_id(), folder_name)); - MutableEntry deleted(&trans, GET_BY_ID, folder.Get(ID)); + MutableEntry deleted(&trans, GET_BY_ID, folder.GetId()); ASSERT_TRUE(deleted.good()); - ASSERT_TRUE(deleted.Put(PARENT_ID, trans.root_id())); - ASSERT_TRUE(deleted.Put(NON_UNIQUE_NAME, new_name)); + deleted.PutParentId(trans.root_id()); + deleted.PutNonUniqueName(new_name); EXPECT_EQ(0, CountEntriesWithName(&trans, trans.root_id(), folder_name)); EXPECT_EQ(0, CountEntriesWithName(&trans, trans.root_id(), new_name)); @@ -1241,9 +1241,9 @@ TEST_F(SyncableDirectoryTest, TestCaseChangeRename) { WriteTransaction trans(FROM_HERE, UNITTEST, dir_.get()); MutableEntry folder(&trans, CREATE, BOOKMARKS, trans.root_id(), "CaseChange"); ASSERT_TRUE(folder.good()); - EXPECT_TRUE(folder.Put(PARENT_ID, trans.root_id())); - EXPECT_TRUE(folder.Put(NON_UNIQUE_NAME, "CASECHANGE")); - EXPECT_TRUE(folder.Put(IS_DEL, true)); + folder.PutParentId(trans.root_id()); + folder.PutNonUniqueName("CASECHANGE"); + folder.PutIsDel(true); } // Create items of each model type, and check that GetModelType and @@ -1269,20 +1269,20 @@ TEST_F(SyncableDirectoryTest, GetModelType) { MutableEntry folder(&trans, CREATE, BOOKMARKS, trans.root_id(), "Folder"); ASSERT_TRUE(folder.good()); - folder.Put(ID, id_factory.NewServerId()); - folder.Put(SPECIFICS, specifics); - folder.Put(BASE_VERSION, 1); - folder.Put(IS_DIR, true); - folder.Put(IS_DEL, false); + folder.PutId(id_factory.NewServerId()); + folder.PutSpecifics(specifics); + folder.PutBaseVersion(1); + folder.PutIsDir(true); + folder.PutIsDel(false); ASSERT_EQ(datatype, folder.GetModelType()); MutableEntry item(&trans, CREATE, BOOKMARKS, trans.root_id(), "Item"); ASSERT_TRUE(item.good()); - item.Put(ID, id_factory.NewServerId()); - item.Put(SPECIFICS, specifics); - item.Put(BASE_VERSION, 1); - item.Put(IS_DIR, false); - item.Put(IS_DEL, false); + item.PutId(id_factory.NewServerId()); + item.PutSpecifics(specifics); + item.PutBaseVersion(1); + item.PutIsDir(false); + item.PutIsDel(false); ASSERT_EQ(datatype, item.GetModelType()); // It's critical that deletion records retain their datatype, so that @@ -1290,29 +1290,29 @@ TEST_F(SyncableDirectoryTest, GetModelType) { MutableEntry deleted_item( &trans, CREATE, BOOKMARKS, trans.root_id(), "Deleted Item"); ASSERT_TRUE(item.good()); - deleted_item.Put(ID, id_factory.NewServerId()); - deleted_item.Put(SPECIFICS, specifics); - deleted_item.Put(BASE_VERSION, 1); - deleted_item.Put(IS_DIR, false); - deleted_item.Put(IS_DEL, true); + deleted_item.PutId(id_factory.NewServerId()); + deleted_item.PutSpecifics(specifics); + deleted_item.PutBaseVersion(1); + deleted_item.PutIsDir(false); + deleted_item.PutIsDel(true); ASSERT_EQ(datatype, deleted_item.GetModelType()); MutableEntry server_folder(&trans, CREATE_NEW_UPDATE_ITEM, id_factory.NewServerId()); ASSERT_TRUE(server_folder.good()); - server_folder.Put(SERVER_SPECIFICS, specifics); - server_folder.Put(BASE_VERSION, 1); - server_folder.Put(SERVER_IS_DIR, true); - server_folder.Put(SERVER_IS_DEL, false); + server_folder.PutServerSpecifics(specifics); + server_folder.PutBaseVersion(1); + server_folder.PutServerIsDir(true); + server_folder.PutServerIsDel(false); ASSERT_EQ(datatype, server_folder.GetServerModelType()); MutableEntry server_item(&trans, CREATE_NEW_UPDATE_ITEM, id_factory.NewServerId()); ASSERT_TRUE(server_item.good()); - server_item.Put(SERVER_SPECIFICS, specifics); - server_item.Put(BASE_VERSION, 1); - server_item.Put(SERVER_IS_DIR, false); - server_item.Put(SERVER_IS_DEL, false); + server_item.PutServerSpecifics(specifics); + server_item.PutBaseVersion(1); + server_item.PutServerIsDir(false); + server_item.PutServerIsDel(false); ASSERT_EQ(datatype, server_item.GetServerModelType()); sync_pb::SyncEntity folder_entity; @@ -1344,14 +1344,14 @@ TEST_F(SyncableDirectoryTest, ChangeEntryIDAndUpdateChildren_ParentAndChild) { WriteTransaction trans(FROM_HERE, UNITTEST, dir_.get()); MutableEntry parent(&trans, CREATE, BOOKMARKS, id_factory.root(), "parent"); - parent.Put(IS_DIR, true); - parent.Put(IS_UNSYNCED, true); + parent.PutIsDir(true); + parent.PutIsUnsynced(true); - MutableEntry child(&trans, CREATE, BOOKMARKS, parent.Get(ID), "child"); - child.Put(IS_UNSYNCED, true); + MutableEntry child(&trans, CREATE, BOOKMARKS, parent.GetId(), "child"); + child.PutIsUnsynced(true); - orig_parent_id = parent.Get(ID); - orig_child_id = child.Get(ID); + orig_parent_id = parent.GetId(); + orig_child_id = child.GetId(); } { @@ -1363,14 +1363,14 @@ TEST_F(SyncableDirectoryTest, ChangeEntryIDAndUpdateChildren_ParentAndChild) { MutableEntry child(&trans, GET_BY_ID, orig_child_id); ChangeEntryIDAndUpdateChildren(&trans, &child, id_factory.NewServerId()); - child.Put(IS_UNSYNCED, false); - child.Put(BASE_VERSION, 1); - child.Put(SERVER_VERSION, 1); + child.PutIsUnsynced(false); + child.PutBaseVersion(1); + child.PutServerVersion(1); ChangeEntryIDAndUpdateChildren(&trans, &parent, id_factory.NewServerId()); - parent.Put(IS_UNSYNCED, false); - parent.Put(BASE_VERSION, 1); - parent.Put(SERVER_VERSION, 1); + parent.PutIsUnsynced(false); + parent.PutBaseVersion(1); + parent.PutServerVersion(1); } // Final check for validity. @@ -1392,14 +1392,14 @@ TEST_F(SyncableDirectoryTest, WriteTransaction trans(FROM_HERE, UNITTEST, dir_.get()); MutableEntry parent(&trans, CREATE, BOOKMARKS, id_factory.root(), "parent"); - parent.Put(IS_DIR, true); - parent.Put(IS_UNSYNCED, true); + parent.PutIsDir(true); + parent.PutIsUnsynced(true); - MutableEntry child(&trans, CREATE, BOOKMARKS, parent.Get(ID), "child"); - child.Put(IS_UNSYNCED, true); + MutableEntry child(&trans, CREATE, BOOKMARKS, parent.GetId(), "child"); + child.PutIsUnsynced(true); - orig_parent_id = parent.Get(ID); - orig_child_id = child.Get(ID); + orig_parent_id = parent.GetId(); + orig_child_id = child.GetId(); } { @@ -1407,7 +1407,7 @@ TEST_F(SyncableDirectoryTest, WriteTransaction trans(FROM_HERE, UNITTEST, dir_.get()); MutableEntry child(&trans, GET_BY_ID, orig_child_id); - child.Put(IS_DEL, true); + child.PutIsDel(true); } { @@ -1418,9 +1418,9 @@ TEST_F(SyncableDirectoryTest, MutableEntry parent(&trans, GET_BY_ID, orig_parent_id); ChangeEntryIDAndUpdateChildren(&trans, &parent, id_factory.NewServerId()); - parent.Put(IS_UNSYNCED, false); - parent.Put(BASE_VERSION, 1); - parent.Put(SERVER_VERSION, 1); + parent.PutIsUnsynced(false); + parent.PutBaseVersion(1); + parent.PutServerVersion(1); } // Final check for validity. @@ -1476,18 +1476,18 @@ TEST_F(SyncableDirectoryTest, OldClientLeftUnsyncedDeletedLocalItem) { // Create an uncommitted tombstone entry. MutableEntry server_knows(&trans, CREATE, BOOKMARKS, id_factory.root(), "server_knows"); - server_knows.Put(ID, server_knows_id); - server_knows.Put(IS_UNSYNCED, true); - server_knows.Put(IS_DEL, true); - server_knows.Put(BASE_VERSION, 5); - server_knows.Put(SERVER_VERSION, 4); + server_knows.PutId(server_knows_id); + server_knows.PutIsUnsynced(true); + server_knows.PutIsDel(true); + server_knows.PutBaseVersion(5); + server_knows.PutServerVersion(4); // Create a valid update entry. MutableEntry not_is_del( &trans, CREATE, BOOKMARKS, id_factory.root(), "not_is_del"); - not_is_del.Put(ID, not_is_del_id); - not_is_del.Put(IS_DEL, false); - not_is_del.Put(IS_UNSYNCED, true); + not_is_del.PutId(not_is_del_id); + not_is_del.PutIsDel(false); + not_is_del.PutIsUnsynced(true); // Create a tombstone which should never be sent to the server because the // server never knew about the item's existence. @@ -1496,9 +1496,9 @@ TEST_F(SyncableDirectoryTest, OldClientLeftUnsyncedDeletedLocalItem) { // this by setting IS_DEL before setting IS_UNSYNCED, something which the // client should never do in practice. MutableEntry zombie(&trans, CREATE, BOOKMARKS, id_factory.root(), "zombie"); - zombie.Put(ID, zombie_id); - zombie.Put(IS_DEL, true); - zombie.Put(IS_UNSYNCED, true); + zombie.PutId(zombie_id); + zombie.PutIsDel(true); + zombie.PutIsUnsynced(true); } ASSERT_EQ(OPENED, SimulateSaveAndReloadDir()); @@ -1539,15 +1539,15 @@ TEST_F(SyncableDirectoryTest, PositionWithNullSurvivesSaveAndReload) { WriteTransaction trans(FROM_HERE, UNITTEST, dir_.get()); MutableEntry parent(&trans, CREATE, BOOKMARKS, id_factory.root(), "parent"); - parent.Put(IS_DIR, true); - parent.Put(IS_UNSYNCED, true); + parent.PutIsDir(true); + parent.PutIsUnsynced(true); - MutableEntry child(&trans, CREATE, BOOKMARKS, parent.Get(ID), "child"); - child.Put(IS_UNSYNCED, true); - child.Put(UNIQUE_POSITION, null_pos); - child.Put(SERVER_UNIQUE_POSITION, null_pos); + MutableEntry child(&trans, CREATE, BOOKMARKS, parent.GetId(), "child"); + child.PutIsUnsynced(true); + child.PutUniquePosition(null_pos); + child.PutServerUniquePosition(null_pos); - null_child_id = child.Get(ID); + null_child_id = child.GetId(); } EXPECT_EQ(OPENED, SimulateSaveAndReloadDir()); @@ -1557,9 +1557,9 @@ TEST_F(SyncableDirectoryTest, PositionWithNullSurvivesSaveAndReload) { Entry null_ordinal_child(&trans, GET_BY_ID, null_child_id); EXPECT_TRUE( - null_pos.Equals(null_ordinal_child.Get(UNIQUE_POSITION))); + null_pos.Equals(null_ordinal_child.GetUniquePosition())); EXPECT_TRUE( - null_pos.Equals(null_ordinal_child.Get(SERVER_UNIQUE_POSITION))); + null_pos.Equals(null_ordinal_child.GetServerUniquePosition())); } } @@ -1730,40 +1730,40 @@ TEST_F(OnDiskSyncableDirectoryTest, TestPurgeEntriesWithTypeIn) { // if their parent isn't quite right. MutableEntry item1(&trans, CREATE, BOOKMARKS, trans.root_id(), "Item"); ASSERT_TRUE(item1.good()); - item1.Put(SERVER_SPECIFICS, bookmark_specs); - item1.Put(IS_UNSYNCED, true); + item1.PutServerSpecifics(bookmark_specs); + item1.PutIsUnsynced(true); MutableEntry item2(&trans, CREATE_NEW_UPDATE_ITEM, id_factory.NewServerId()); ASSERT_TRUE(item2.good()); - item2.Put(SERVER_SPECIFICS, bookmark_specs); - item2.Put(IS_UNAPPLIED_UPDATE, true); + item2.PutServerSpecifics(bookmark_specs); + item2.PutIsUnappliedUpdate(true); MutableEntry item3(&trans, CREATE, PREFERENCES, trans.root_id(), "Item"); ASSERT_TRUE(item3.good()); - item3.Put(SPECIFICS, preference_specs); - item3.Put(SERVER_SPECIFICS, preference_specs); - item3.Put(IS_UNSYNCED, true); + item3.PutSpecifics(preference_specs); + item3.PutServerSpecifics(preference_specs); + item3.PutIsUnsynced(true); MutableEntry item4(&trans, CREATE_NEW_UPDATE_ITEM, id_factory.NewServerId()); ASSERT_TRUE(item4.good()); - item4.Put(SERVER_SPECIFICS, preference_specs); - item4.Put(IS_UNAPPLIED_UPDATE, true); + item4.PutServerSpecifics(preference_specs); + item4.PutIsUnappliedUpdate(true); MutableEntry item5(&trans, CREATE, AUTOFILL, trans.root_id(), "Item"); ASSERT_TRUE(item5.good()); - item5.Put(SPECIFICS, autofill_specs); - item5.Put(SERVER_SPECIFICS, autofill_specs); - item5.Put(IS_UNSYNCED, true); + item5.PutSpecifics(autofill_specs); + item5.PutServerSpecifics(autofill_specs); + item5.PutIsUnsynced(true); MutableEntry item6(&trans, CREATE_NEW_UPDATE_ITEM, id_factory.NewServerId()); ASSERT_TRUE(item6.good()); - item6.Put(SERVER_SPECIFICS, autofill_specs); - item6.Put(IS_UNAPPLIED_UPDATE, true); + item6.PutServerSpecifics(autofill_specs); + item6.PutIsUnappliedUpdate(true); } dir_->SaveChanges(); @@ -1831,16 +1831,16 @@ TEST_F(OnDiskSyncableDirectoryTest, MutableEntry create( &trans, CREATE, BOOKMARKS, trans.root_id(), create_name); MutableEntry update(&trans, CREATE_NEW_UPDATE_ITEM, update_id); - create.Put(IS_UNSYNCED, true); - update.Put(IS_UNAPPLIED_UPDATE, true); + create.PutIsUnsynced(true); + update.PutIsUnappliedUpdate(true); sync_pb::EntitySpecifics specifics; specifics.mutable_bookmark()->set_favicon("PNG"); specifics.mutable_bookmark()->set_url("http://nowhere"); - create.Put(SPECIFICS, specifics); - update.Put(SPECIFICS, specifics); + create.PutSpecifics(specifics); + update.PutSpecifics(specifics); create_pre_save = create.GetKernelCopy(); update_pre_save = update.GetKernelCopy(); - create_id = create.Get(ID); + create_id = create.GetId(); } dir_->SaveChanges(); @@ -1932,10 +1932,10 @@ TEST_F(OnDiskSyncableDirectoryTest, TestSaveChangesFailure) { MutableEntry e1(&trans, CREATE, BOOKMARKS, trans.root_id(), "aguilera"); ASSERT_TRUE(e1.good()); EXPECT_TRUE(e1.GetKernelCopy().is_dirty()); - handle1 = e1.Get(META_HANDLE); - e1.Put(BASE_VERSION, 1); - e1.Put(IS_DIR, true); - e1.Put(ID, TestIdFactory::FromNumber(101)); + handle1 = e1.GetMetahandle(); + e1.PutBaseVersion(1); + e1.PutIsDir(true); + e1.PutId(TestIdFactory::FromNumber(101)); EXPECT_TRUE(e1.GetKernelCopy().is_dirty()); EXPECT_TRUE(IsInDirtyMetahandles(handle1)); } @@ -1949,8 +1949,8 @@ TEST_F(OnDiskSyncableDirectoryTest, TestSaveChangesFailure) { MutableEntry aguilera(&trans, GET_BY_HANDLE, handle1); ASSERT_TRUE(aguilera.good()); EXPECT_FALSE(aguilera.GetKernelCopy().is_dirty()); - EXPECT_EQ(aguilera.Get(NON_UNIQUE_NAME), "aguilera"); - aguilera.Put(NON_UNIQUE_NAME, "overwritten"); + EXPECT_EQ(aguilera.GetNonUniqueName(), "aguilera"); + aguilera.PutNonUniqueName("overwritten"); EXPECT_TRUE(aguilera.GetKernelCopy().is_dirty()); EXPECT_TRUE(IsInDirtyMetahandles(handle1)); } @@ -1967,10 +1967,10 @@ TEST_F(OnDiskSyncableDirectoryTest, TestSaveChangesFailure) { MutableEntry aguilera(&trans, GET_BY_HANDLE, handle1); ASSERT_TRUE(aguilera.good()); EXPECT_FALSE(aguilera.GetKernelCopy().is_dirty()); - EXPECT_EQ(aguilera.Get(NON_UNIQUE_NAME), "overwritten"); + EXPECT_EQ(aguilera.GetNonUniqueName(), "overwritten"); EXPECT_FALSE(aguilera.GetKernelCopy().is_dirty()); EXPECT_FALSE(IsInDirtyMetahandles(handle1)); - aguilera.Put(NON_UNIQUE_NAME, "christina"); + aguilera.PutNonUniqueName("christina"); EXPECT_TRUE(aguilera.GetKernelCopy().is_dirty()); EXPECT_TRUE(IsInDirtyMetahandles(handle1)); @@ -1978,10 +1978,10 @@ TEST_F(OnDiskSyncableDirectoryTest, TestSaveChangesFailure) { MutableEntry kids_on_block( &trans, CREATE, BOOKMARKS, trans.root_id(), "kids"); ASSERT_TRUE(kids_on_block.good()); - handle2 = kids_on_block.Get(META_HANDLE); - kids_on_block.Put(BASE_VERSION, 1); - kids_on_block.Put(IS_DIR, true); - kids_on_block.Put(ID, TestIdFactory::FromNumber(102)); + handle2 = kids_on_block.GetMetahandle(); + kids_on_block.PutBaseVersion(1); + kids_on_block.PutIsDir(true); + kids_on_block.PutId(TestIdFactory::FromNumber(102)); EXPECT_TRUE(kids_on_block.GetKernelCopy().is_dirty()); EXPECT_TRUE(IsInDirtyMetahandles(handle2)); } @@ -2014,15 +2014,15 @@ TEST_F(OnDiskSyncableDirectoryTest, TestSaveChangesFailureWithPurge) { MutableEntry e1(&trans, CREATE, BOOKMARKS, trans.root_id(), "aguilera"); ASSERT_TRUE(e1.good()); EXPECT_TRUE(e1.GetKernelCopy().is_dirty()); - handle1 = e1.Get(META_HANDLE); - e1.Put(BASE_VERSION, 1); - e1.Put(IS_DIR, true); - e1.Put(ID, TestIdFactory::FromNumber(101)); + handle1 = e1.GetMetahandle(); + e1.PutBaseVersion(1); + e1.PutIsDir(true); + e1.PutId(TestIdFactory::FromNumber(101)); sync_pb::EntitySpecifics bookmark_specs; AddDefaultFieldValue(BOOKMARKS, &bookmark_specs); - e1.Put(SPECIFICS, bookmark_specs); - e1.Put(SERVER_SPECIFICS, bookmark_specs); - e1.Put(ID, TestIdFactory::FromNumber(101)); + e1.PutSpecifics(bookmark_specs); + e1.PutServerSpecifics(bookmark_specs); + e1.PutId(TestIdFactory::FromNumber(101)); EXPECT_TRUE(e1.GetKernelCopy().is_dirty()); EXPECT_TRUE(IsInDirtyMetahandles(handle1)); } @@ -2051,10 +2051,10 @@ void SyncableDirectoryTest::ValidateEntry(BaseTransaction* trans, Entry e(trans, GET_BY_ID, TestIdFactory::FromNumber(id)); ASSERT_TRUE(e.good()); if (check_name) - ASSERT_TRUE(name == e.Get(NON_UNIQUE_NAME)); - ASSERT_TRUE(base_version == e.Get(BASE_VERSION)); - ASSERT_TRUE(server_version == e.Get(SERVER_VERSION)); - ASSERT_TRUE(is_del == e.Get(IS_DEL)); + ASSERT_TRUE(name == e.GetNonUniqueName()); + ASSERT_TRUE(base_version == e.GetBaseVersion()); + ASSERT_TRUE(server_version == e.GetServerVersion()); + ASSERT_TRUE(is_del == e.GetIsDel()); } DirOpenResult SyncableDirectoryTest::SimulateSaveAndReloadDir() { @@ -2159,10 +2159,10 @@ class StressTransactionsDelegate : public base::PlatformThread::Delegate { CHECK(e.good()); base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds( rand() % 20)); - e.Put(IS_UNSYNCED, true); - if (e.Put(ID, TestIdFactory::FromNumber(rand())) && - e.Get(ID).ServerKnows() && !e.Get(ID).IsRoot()) { - e.Put(BASE_VERSION, 1); + e.PutIsUnsynced(true); + if (e.PutId(TestIdFactory::FromNumber(rand())) && + e.GetId().ServerKnows() && !e.GetId().IsRoot()) { + e.PutBaseVersion(1); } } } @@ -2216,14 +2216,14 @@ class SyncableClientTagTest : public SyncableDirectoryTest { MutableEntry me(&wtrans, CREATE, PREFERENCES, wtrans.root_id(), test_name_); CHECK(me.good()); - me.Put(ID, id); + me.PutId(id); if (id.ServerKnows()) { - me.Put(BASE_VERSION, kBaseVersion); + me.PutBaseVersion(kBaseVersion); } - me.Put(IS_UNSYNCED, true); - me.Put(IS_DEL, deleted); - me.Put(IS_DIR, false); - return me.Put(UNIQUE_CLIENT_TAG, test_tag_); + me.PutIsUnsynced(true); + me.PutIsDel(deleted); + me.PutIsDir(false); + return me.PutUniqueClientTag(test_tag_); } // Verify an entry exists with the default tag. @@ -2232,13 +2232,13 @@ class SyncableClientTagTest : public SyncableDirectoryTest { ReadTransaction trans(FROM_HERE, dir_.get()); Entry me(&trans, GET_BY_CLIENT_TAG, test_tag_); CHECK(me.good()); - EXPECT_EQ(me.Get(ID), id); - EXPECT_EQ(me.Get(UNIQUE_CLIENT_TAG), test_tag_); - EXPECT_EQ(me.Get(IS_DEL), deleted); + EXPECT_EQ(me.GetId(), id); + EXPECT_EQ(me.GetUniqueClientTag(), test_tag_); + EXPECT_EQ(me.GetIsDel(), deleted); // We only sync deleted items that the server knew about. - if (me.Get(ID).ServerKnows() || !me.Get(IS_DEL)) { - EXPECT_EQ(me.Get(IS_UNSYNCED), true); + if (me.GetId().ServerKnows() || !me.GetIsDel()) { + EXPECT_EQ(me.GetIsUnsynced(), true); } } @@ -2253,7 +2253,7 @@ TEST_F(SyncableClientTagTest, TestClientTagClear) { WriteTransaction trans(FROM_HERE, UNITTEST, dir_.get()); MutableEntry me(&trans, GET_BY_CLIENT_TAG, test_tag_); EXPECT_TRUE(me.good()); - me.Put(UNIQUE_CLIENT_TAG, std::string()); + me.PutUniqueClientTag(std::string()); } { ReadTransaction trans(FROM_HERE, dir_.get()); @@ -2262,7 +2262,7 @@ TEST_F(SyncableClientTagTest, TestClientTagClear) { Entry by_id(&trans, GET_BY_ID, server_id); EXPECT_TRUE(by_id.good()); - EXPECT_TRUE(by_id.Get(UNIQUE_CLIENT_TAG).empty()); + EXPECT_TRUE(by_id.GetUniqueClientTag().empty()); } } diff --git a/sync/syncable/syncable_util.cc b/sync/syncable/syncable_util.cc index e57071b..05cc2a9 100644 --- a/sync/syncable/syncable_util.cc +++ b/sync/syncable/syncable_util.cc @@ -41,7 +41,7 @@ bool IsLegalNewParent(BaseTransaction* trans, const Id& entry_id, "Invalid new parent", trans)) return false; - ancestor_id = new_parent.Get(PARENT_ID); + ancestor_id = new_parent.GetParentId(); } return true; } @@ -50,15 +50,15 @@ void ChangeEntryIDAndUpdateChildren( WriteTransaction* trans, MutableEntry* entry, const Id& new_id) { - Id old_id = entry->Get(ID); - if (!entry->Put(ID, new_id)) { + Id old_id = entry->GetId(); + if (!entry->PutId(new_id)) { Entry old_entry(trans, GET_BY_ID, new_id); CHECK(old_entry.good()); LOG(FATAL) << "Attempt to change ID to " << new_id << " conflicts with existing entry.\n\n" << *entry << "\n\n" << old_entry; } - if (entry->Get(IS_DIR)) { + if (entry->GetIsDir()) { // Get all child entries of the old id. Directory::Metahandles children; trans->directory()->GetChildHandlesById(trans, old_id, &children); diff --git a/sync/syncable/syncable_write_transaction.cc b/sync/syncable/syncable_write_transaction.cc index 04113a7..057b258 100644 --- a/sync/syncable/syncable_write_transaction.cc +++ b/sync/syncable/syncable_write_transaction.cc @@ -127,7 +127,7 @@ void WriteTransaction::UpdateTransactionVersion( for (uint32 i = 0; i < entry_changed.size(); ++i) { MutableEntry entry(this, GET_BY_HANDLE, entry_changed[i]); if (entry.good()) { - ModelType type = GetModelTypeFromSpecifics(entry.Get(SPECIFICS)); + ModelType type = GetModelTypeFromSpecifics(entry.GetSpecifics()); if (type < FIRST_REAL_MODEL_TYPE) continue; if (!type_seen.Has(type)) { |