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

Side by Side Diff: chrome/browser/sync_file_system/drive_backend/metadata_db_migration_util.cc

Issue 1172183002: Move StartsWith[ASCII] to base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@string_util3
Patch Set: merger Created 5 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/sync_file_system/drive_backend/metadata_db_migration_ut il.h" 5 #include "chrome/browser/sync_file_system/drive_backend/metadata_db_migration_ut il.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_util.h" 10 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_util.h"
(...skipping 28 matching lines...) Expand all
39 const char kDemotedDirtyIDKeyPrefix[] = "DEMOTED_DIRTY: "; 39 const char kDemotedDirtyIDKeyPrefix[] = "DEMOTED_DIRTY: ";
40 40
41 leveldb::WriteBatch write_batch; 41 leveldb::WriteBatch write_batch;
42 write_batch.Put(kDatabaseVersionKey, "3"); 42 write_batch.Put(kDatabaseVersionKey, "3");
43 43
44 scoped_ptr<leveldb::Iterator> itr(db->NewIterator(leveldb::ReadOptions())); 44 scoped_ptr<leveldb::Iterator> itr(db->NewIterator(leveldb::ReadOptions()));
45 for (itr->SeekToFirst(); itr->Valid(); itr->Next()) { 45 for (itr->SeekToFirst(); itr->Valid(); itr->Next()) {
46 std::string key = itr->key().ToString(); 46 std::string key = itr->key().ToString();
47 47
48 // Do nothing for valid entries in both versions. 48 // Do nothing for valid entries in both versions.
49 if (StartsWithASCII(key, kServiceMetadataKey, true) || 49 if (base::StartsWithASCII(key, kServiceMetadataKey, true) ||
50 StartsWithASCII(key, kFileMetadataKeyPrefix, true) || 50 base::StartsWithASCII(key, kFileMetadataKeyPrefix, true) ||
51 StartsWithASCII(key, kFileTrackerKeyPrefix, true)) { 51 base::StartsWithASCII(key, kFileTrackerKeyPrefix, true)) {
52 continue; 52 continue;
53 } 53 }
54 54
55 // Drop entries used in version 4 only. 55 // Drop entries used in version 4 only.
56 if (StartsWithASCII(key, kAppRootIDByAppIDKeyPrefix, true) || 56 if (base::StartsWithASCII(key, kAppRootIDByAppIDKeyPrefix, true) ||
57 StartsWithASCII(key, kActiveTrackerIDByFileIDKeyPrefix, true) || 57 base::StartsWithASCII(key, kActiveTrackerIDByFileIDKeyPrefix, true) ||
58 StartsWithASCII(key, kTrackerIDByFileIDKeyPrefix, true) || 58 base::StartsWithASCII(key, kTrackerIDByFileIDKeyPrefix, true) ||
59 StartsWithASCII(key, kMultiTrackerByFileIDKeyPrefix, true) || 59 base::StartsWithASCII(key, kMultiTrackerByFileIDKeyPrefix, true) ||
60 StartsWithASCII(key, kActiveTrackerIDByParentAndTitleKeyPrefix, true) || 60 base::StartsWithASCII(key, kActiveTrackerIDByParentAndTitleKeyPrefix,
61 StartsWithASCII(key, kTrackerIDByParentAndTitleKeyPrefix, true) || 61 true) ||
62 StartsWithASCII(key, kMultiBackingParentAndTitleKeyPrefix, true) || 62 base::StartsWithASCII(key, kTrackerIDByParentAndTitleKeyPrefix, true) ||
63 StartsWithASCII(key, kDirtyIDKeyPrefix, true) || 63 base::StartsWithASCII(key, kMultiBackingParentAndTitleKeyPrefix,
64 StartsWithASCII(key, kDemotedDirtyIDKeyPrefix, true)) { 64 true) ||
65 base::StartsWithASCII(key, kDirtyIDKeyPrefix, true) ||
66 base::StartsWithASCII(key, kDemotedDirtyIDKeyPrefix, true)) {
65 write_batch.Delete(key); 67 write_batch.Delete(key);
66 continue; 68 continue;
67 } 69 }
68 70
69 DVLOG(3) << "Unknown key: " << key << " was found."; 71 DVLOG(3) << "Unknown key: " << key << " was found.";
70 } 72 }
71 73
72 return LevelDBStatusToSyncStatusCode( 74 return LevelDBStatusToSyncStatusCode(
73 db->Write(leveldb::WriteOptions(), &write_batch)); 75 db->Write(leveldb::WriteOptions(), &write_batch));
74 } 76 }
75 77
76 } // namespace drive_backend 78 } // namespace drive_backend
77 } // namespace sync_file_system 79 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698