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

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

Issue 374843002: [SyncFS] [Refactoring] Change RemovePrefix() to return bool (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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
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 35cf0e028f2ec2880ee76d41d2b313abcda05925..54d9ecc4273fcbec06cc19ef941bc25472b0e524 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
@@ -278,12 +278,12 @@ int64 MetadataDatabaseIndexOnDisk::PickDirtyTracker() const {
if (!itr->Valid())
return kInvalidTrackerID;
- const std::string& key(itr->key().ToString());
- if (!StartsWithASCII(key, kDirtyIDKeyPrefix, true))
+ std::string id_str;
+ if (!RemovePrefix(itr->key().ToString(), kDirtyIDKeyPrefix, &id_str))
return kInvalidTrackerID;
int64 tracker_id;
- if (!base::StringToInt64(RemovePrefix(key, kDirtyIDKeyPrefix), &tracker_id))
+ if (!base::StringToInt64(id_str, &tracker_id))
return kInvalidTrackerID;
return tracker_id;
@@ -322,12 +322,12 @@ void MetadataDatabaseIndexOnDisk::PromoteDemotedDirtyTrackers(
leveldb::WriteBatch* batch) {
scoped_ptr<leveldb::Iterator> itr(db_->NewIterator(leveldb::ReadOptions()));
for (itr->Seek(kDirtyIDKeyPrefix); itr->Valid(); itr->Next()) {
- const std::string& key(itr->key().ToString());
- if (!StartsWithASCII(key, kDirtyIDKeyPrefix, true))
+ std::string id_str;
+ if (!RemovePrefix(itr->key().ToString(), kDirtyIDKeyPrefix, &id_str))
break;
int64 tracker_id;
- if (!base::StringToInt64(RemovePrefix(key, kDirtyIDKeyPrefix), &tracker_id))
+ if (!base::StringToInt64(id_str, &tracker_id))
continue;
batch->Delete(itr->key());
@@ -375,10 +375,10 @@ MetadataDatabaseIndexOnDisk::GetRegisteredAppIDs() const {
std::vector<std::string> result;
scoped_ptr<leveldb::Iterator> itr(db_->NewIterator(leveldb::ReadOptions()));
for (itr->Seek(kAppRootIDByAppIDKeyPrefix); itr->Valid(); itr->Next()) {
- const std::string& key(itr->key().ToString());
- if (!StartsWithASCII(key, kAppRootIDByAppIDKeyPrefix, true))
+ std::string id;
+ if (!RemovePrefix(itr->key().ToString(), kAppRootIDByAppIDKeyPrefix, &id))
break;
- result.push_back(RemovePrefix(key, kAppRootIDByAppIDKeyPrefix));
+ result.push_back(id);
}
return result;
}

Powered by Google App Engine
This is Rietveld 408576698