Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(287)

Unified Diff: chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.cc

Issue 442713002: [SyncFS] Drop active tracker IDs in DB (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync_file_system/drive_backend/metadata_database_index_on_disk.cc
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 6afa05c997c61a6ac1f37d8490dde9a9f6914ac2..a0725c19c0fa6a3b1e391b39981715e9e13ac9c2 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
@@ -1008,8 +1008,8 @@ TrackerIDSet MetadataDatabaseIndexOnDisk::GetTrackerIDSetByPrefix(
std::string value;
leveldb::Status status = db_->Get(active_tracker_key, &value);
int64 active_tracker;
- if (status.ok() && base::StringToInt64(value, &active_tracker) &&
- active_tracker != kInvalidTrackerID) {
+ if (status.ok() && base::StringToInt64(value, &active_tracker)) {
+ DCHECK_NE(kInvalidTrackerID, active_tracker);
trackers.Activate(active_tracker);
}
@@ -1038,30 +1038,10 @@ bool MetadataDatabaseIndexOnDisk::EraseInTrackerIDSetWithPrefix(
db_->Delete(del_key);
- size_t count = 0;
- scoped_ptr<LevelDBWrapper::Iterator> itr(db_->NewIterator());
- for (itr->Seek(key_prefix); itr->Valid(); itr->Next()) {
- const std::string key = itr->key().ToString();
- if (!StartsWithASCII(key, key_prefix, true))
- break;
- // Entry for |del_key| is not deleted yet.
- if (key == del_key)
- continue;
- ++count;
- break;
- }
-
- if (count > 0) {
- // TrackerIDSet is still alive. Deactivate if the tracker is active.
- leveldb::Status status =
- db_->Get(active_tracker_key, &value);
- int64 active_tracker_id;
- if (status.ok() && base::StringToInt64(value, &active_tracker_id) &&
- active_tracker_id == tracker_id) {
- db_->Put(active_tracker_key, base::Int64ToString(kInvalidTrackerID));
- }
- } else {
- // TrackerIDSet is no longer alive. Erase active tracker entry.
+ status = db_->Get(active_tracker_key, &value);
+ int64 active_tracker_id;
+ if (status.ok() && base::StringToInt64(value, &active_tracker_id) &&
+ active_tracker_id == tracker_id) {
db_->Delete(active_tracker_key);
}
@@ -1093,7 +1073,7 @@ void MetadataDatabaseIndexOnDisk::DeactivateInTrackerIDSetWithPrefix(
int64 active_tracker_id;
if (status.ok() && base::StringToInt64(value, &active_tracker_id)) {
DCHECK(active_tracker_id == tracker_id);
- db_->Put(active_tracker_key, base::Int64ToString(kInvalidTrackerID));
+ db_->Delete(active_tracker_key);
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698