Skip to content

Commit

Permalink
sync: Use a specialized transaction version setter
Browse files Browse the repository at this point in the history
The setting of the transaction version used to be implemented with
Put(TRANSACTION_VERSION, ...), like other int64 EntryKernel fields.
This had the side effect of calling SaveOriginal() on the entry.  That
had the side effect of creating unnecessary copies of the EntryKernels.

This change creates a new function,
MutableEntry::UpdateTransactionVersion() which does not try to save the
original entry.  It also prevents the use of Put(TRANSACTION_VERSION)
and updates the only call site for this function.

BUG=241940,241813,238621

Review URL: https://chromiumcodereview.appspot.com/15376002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@201905 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
rlarocque@chromium.org committed May 23, 2013
1 parent 307ef81 commit bcda347
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
10 changes: 10 additions & 0 deletions sync/syncable/mutable_entry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ bool MutableEntry::PutIsDel(bool is_del) {

bool MutableEntry::Put(Int64Field field, const int64& value) {
DCHECK(kernel_);

// We shouldn't set TRANSACTION_VERSION here. See UpdateTransactionVersion.
DCHECK_NE(TRANSACTION_VERSION, field);

write_transaction_->SaveOriginal(kernel_);
if (kernel_->ref(field) != value) {
ScopedKernelLock lock(dir());
Expand Down Expand Up @@ -413,6 +417,12 @@ bool MutableEntry::Put(BitTemp field, bool value) {
return true;
}

void MutableEntry::UpdateTransactionVersion(int64 value) {
ScopedKernelLock lock(dir());
kernel_->put(TRANSACTION_VERSION, value);
kernel_->mark_dirty(dir()->kernel_->dirty_metahandles);
}

// This function sets only the flags needed to get this entry to sync.
bool MarkForSyncing(MutableEntry* e) {
DCHECK_NE(static_cast<MutableEntry*>(NULL), e);
Expand Down
6 changes: 6 additions & 0 deletions sync/syncable/mutable_entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ class SYNC_EXPORT_PRIVATE MutableEntry : public Entry {

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
// used its list of mutations by the time this function is called.
void UpdateTransactionVersion(int64 version);

protected:
syncable::MetahandleSet* GetDirtyIndexHelper();

Expand Down
2 changes: 1 addition & 1 deletion sync/syncable/syncable_write_transaction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ void WriteTransaction::UpdateTransactionVersion(
directory_->IncrementTransactionVersion(type);
type_seen.Put(type);
}
entry.Put(TRANSACTION_VERSION, directory_->GetTransactionVersion(type));
entry.UpdateTransactionVersion(directory_->GetTransactionVersion(type));
}
}

Expand Down

0 comments on commit bcda347

Please sign in to comment.