diff options
author | peria <peria@chromium.org> | 2014-08-25 01:24:43 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-08-25 08:25:19 +0000 |
commit | 5e4eefdecbd95539899f2a060c27b802466f5182 (patch) | |
tree | 782619e78a6e261b3f34d6102fbdb465acefc26f | |
parent | 77b343e018d1ed88bc9ce96fc9a9055c2e1c5cde (diff) | |
download | chromium_src-5e4eefdecbd95539899f2a060c27b802466f5182.zip chromium_src-5e4eefdecbd95539899f2a060c27b802466f5182.tar.gz chromium_src-5e4eefdecbd95539899f2a060c27b802466f5182.tar.bz2 |
[SyncFS] Fix error of handling demoted dirty trackers
PromoteDemotedDirtyTrackers() confused demoted dirty trackers and
non-demoted dirty trackers.
BUG=None
TEST=./unit_tests --gtest_filter="MetadataDatabaseIndex*"
Review URL: https://codereview.chromium.org/480683003
Cr-Commit-Position: refs/heads/master@{#291651}
-rw-r--r-- | chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.cc | 6 | ||||
-rw-r--r-- | chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk_unittest.cc | 5 |
2 files changed, 8 insertions, 3 deletions
diff --git a/chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.cc b/chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.cc index 5c13379..1199a13 100644 --- a/chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.cc +++ b/chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.cc @@ -539,9 +539,9 @@ void MetadataDatabaseIndexOnDisk::PromoteDemotedDirtyTracker(int64 tracker_id) { bool MetadataDatabaseIndexOnDisk::PromoteDemotedDirtyTrackers() { bool promoted = false; scoped_ptr<LevelDBWrapper::Iterator> itr(db_->NewIterator()); - for (itr->Seek(kDirtyIDKeyPrefix); itr->Valid(); itr->Next()) { + for (itr->Seek(kDemotedDirtyIDKeyPrefix); itr->Valid(); itr->Next()) { std::string id_str; - if (!RemovePrefix(itr->key().ToString(), kDirtyIDKeyPrefix, &id_str)) + if (!RemovePrefix(itr->key().ToString(), kDemotedDirtyIDKeyPrefix, &id_str)) break; int64 tracker_id; @@ -549,7 +549,7 @@ bool MetadataDatabaseIndexOnDisk::PromoteDemotedDirtyTrackers() { continue; db_->Delete(itr->key().ToString()); - db_->Put(GenerateDemotedDirtyIDKey(tracker_id), std::string()); + db_->Put(GenerateDirtyIDKey(tracker_id), std::string()); promoted = true; } return promoted; diff --git a/chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk_unittest.cc b/chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk_unittest.cc index 3ea2ef5..bab07cc 100644 --- a/chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk_unittest.cc +++ b/chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk_unittest.cc @@ -630,6 +630,11 @@ TEST_F(MetadataDatabaseIndexOnDiskTest, DirtyTrackersTest) { WriteToDB(); EXPECT_EQ(1U, index()->CountDirtyTracker()); EXPECT_EQ(kInvalidTrackerID, index()->PickDirtyTracker()); + + // Demoted trackers + EXPECT_TRUE(index()->HasDemotedDirtyTracker()); + EXPECT_TRUE(index()->PromoteDemotedDirtyTrackers()); + EXPECT_FALSE(index()->HasDemotedDirtyTracker()); } } // namespace drive_backend |