diff options
author | lipalani@chromium.org <lipalani@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-18 22:13:18 +0000 |
---|---|---|
committer | lipalani@chromium.org <lipalani@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-18 22:13:18 +0000 |
commit | b1787c7f579221c2a8724ff089f9114a456c6062 (patch) | |
tree | bf4ed75666c34115681555b89e1959522e20e5e2 /sync | |
parent | c907656e92631caedf646ca8ee56cc91a0debb51 (diff) | |
download | chromium_src-b1787c7f579221c2a8724ff089f9114a456c6062.zip chromium_src-b1787c7f579221c2a8724ff089f9114a456c6062.tar.gz chromium_src-b1787c7f579221c2a8724ff089f9114a456c6062.tar.bz2 |
Fix the crash by the introduction of a enum to figure out whether to save original or not.
BUG=121587
TEST=
Review URL: http://codereview.chromium.org/10117011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132880 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync')
-rw-r--r-- | sync/syncable/syncable.cc | 14 | ||||
-rw-r--r-- | sync/syncable/syncable.h | 10 |
2 files changed, 18 insertions, 6 deletions
diff --git a/sync/syncable/syncable.cc b/sync/syncable/syncable.cc index f5dde90..760a331 100644 --- a/sync/syncable/syncable.cc +++ b/sync/syncable/syncable.cc @@ -933,7 +933,7 @@ void Directory::PurgeEntriesWithTypeIn(ModelTypeSet types) { // Note the dance around incrementing |it|, since we sometimes erase(). if ((IsRealDataType(local_type) && types.Has(local_type)) || (IsRealDataType(server_type) && types.Has(server_type))) { - if (!UnlinkEntryFromOrder(*it, NULL, &lock)) + if (!UnlinkEntryFromOrder(*it, &trans, &lock, DATA_TYPE_PURGE)) return; int64 handle = (*it)->ref(META_HANDLE); @@ -1952,12 +1952,16 @@ bool MutableEntry::Put(IndexedBitField field, bool value) { bool MutableEntry::UnlinkFromOrder() { ScopedKernelLock lock(dir()); - return dir()->UnlinkEntryFromOrder(kernel_, write_transaction(), &lock); + return dir()->UnlinkEntryFromOrder(kernel_, + write_transaction(), + &lock, + NODE_MANIPULATION); } bool Directory::UnlinkEntryFromOrder(EntryKernel* entry, WriteTransaction* trans, - ScopedKernelLock* lock) { + ScopedKernelLock* lock, + UnlinkReason unlink_reason) { if (!SyncAssert(!trans || this == trans->directory(), FROM_HERE, "Transaction not pointing to the right directory", @@ -2002,7 +2006,7 @@ bool Directory::UnlinkEntryFromOrder(EntryKernel* entry, return false; } } - if (trans) + if (unlink_reason == NODE_MANIPULATION) trans->SaveOriginal(previous_entry); previous_entry->put(NEXT_ID, old_next); previous_entry->mark_dirty(kernel_->dirty_metahandles); @@ -2016,7 +2020,7 @@ bool Directory::UnlinkEntryFromOrder(EntryKernel* entry, trans)) { return false; } - if (trans) + if (unlink_reason == NODE_MANIPULATION) trans->SaveOriginal(next_entry); next_entry->put(PREV_ID, old_previous); next_entry->mark_dirty(kernel_->dirty_metahandles); diff --git a/sync/syncable/syncable.h b/sync/syncable/syncable.h index 3eb22f4..d568a01 100644 --- a/sync/syncable/syncable.h +++ b/sync/syncable/syncable.h @@ -246,6 +246,13 @@ enum CreateNewUpdateItem { typedef std::set<int64> MetahandleSet; +// Reason for unlinking. +enum UnlinkReason { + NODE_MANIPULATION, // To be used by any operation manipulating the linked + // list. + DATA_TYPE_PURGE // To be used when purging a dataype. +}; + // TODO(akalin): Move EntryKernel and related into its own header file. // Why the singular enums? So the code compile-time dispatches instead of @@ -920,7 +927,8 @@ class Directory { // The semantic checking is implemented higher up. bool UnlinkEntryFromOrder(EntryKernel* entry, WriteTransaction* trans, - ScopedKernelLock* lock); + ScopedKernelLock* lock, + UnlinkReason unlink_reason); DirOpenResult OpenImpl( DirectoryBackingStore* store, const std::string& name, |