OLD | NEW |
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 Loading... |
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 (base::StartsWithASCII(key, kServiceMetadataKey, true) || | 49 if (base::StartsWith(key, kServiceMetadataKey, |
50 base::StartsWithASCII(key, kFileMetadataKeyPrefix, true) || | 50 base::CompareCase::SENSITIVE) || |
51 base::StartsWithASCII(key, kFileTrackerKeyPrefix, true)) { | 51 base::StartsWith(key, kFileMetadataKeyPrefix, |
| 52 base::CompareCase::SENSITIVE) || |
| 53 base::StartsWith(key, kFileTrackerKeyPrefix, |
| 54 base::CompareCase::SENSITIVE)) { |
52 continue; | 55 continue; |
53 } | 56 } |
54 | 57 |
55 // Drop entries used in version 4 only. | 58 // Drop entries used in version 4 only. |
56 if (base::StartsWithASCII(key, kAppRootIDByAppIDKeyPrefix, true) || | 59 if (base::StartsWith(key, kAppRootIDByAppIDKeyPrefix, |
57 base::StartsWithASCII(key, kActiveTrackerIDByFileIDKeyPrefix, true) || | 60 base::CompareCase::SENSITIVE) || |
58 base::StartsWithASCII(key, kTrackerIDByFileIDKeyPrefix, true) || | 61 base::StartsWith(key, kActiveTrackerIDByFileIDKeyPrefix, |
59 base::StartsWithASCII(key, kMultiTrackerByFileIDKeyPrefix, true) || | 62 base::CompareCase::SENSITIVE) || |
60 base::StartsWithASCII(key, kActiveTrackerIDByParentAndTitleKeyPrefix, | 63 base::StartsWith(key, kTrackerIDByFileIDKeyPrefix, |
61 true) || | 64 base::CompareCase::SENSITIVE) || |
62 base::StartsWithASCII(key, kTrackerIDByParentAndTitleKeyPrefix, true) || | 65 base::StartsWith(key, kMultiTrackerByFileIDKeyPrefix, |
63 base::StartsWithASCII(key, kMultiBackingParentAndTitleKeyPrefix, | 66 base::CompareCase::SENSITIVE) || |
64 true) || | 67 base::StartsWith(key, kActiveTrackerIDByParentAndTitleKeyPrefix, |
65 base::StartsWithASCII(key, kDirtyIDKeyPrefix, true) || | 68 base::CompareCase::SENSITIVE) || |
66 base::StartsWithASCII(key, kDemotedDirtyIDKeyPrefix, true)) { | 69 base::StartsWith(key, kTrackerIDByParentAndTitleKeyPrefix, |
| 70 base::CompareCase::SENSITIVE) || |
| 71 base::StartsWith(key, kMultiBackingParentAndTitleKeyPrefix, |
| 72 base::CompareCase::SENSITIVE) || |
| 73 base::StartsWith(key, kDirtyIDKeyPrefix, |
| 74 base::CompareCase::SENSITIVE) || |
| 75 base::StartsWith(key, kDemotedDirtyIDKeyPrefix, |
| 76 base::CompareCase::SENSITIVE)) { |
67 write_batch.Delete(key); | 77 write_batch.Delete(key); |
68 continue; | 78 continue; |
69 } | 79 } |
70 | 80 |
71 DVLOG(3) << "Unknown key: " << key << " was found."; | 81 DVLOG(3) << "Unknown key: " << key << " was found."; |
72 } | 82 } |
73 | 83 |
74 return LevelDBStatusToSyncStatusCode( | 84 return LevelDBStatusToSyncStatusCode( |
75 db->Write(leveldb::WriteOptions(), &write_batch)); | 85 db->Write(leveldb::WriteOptions(), &write_batch)); |
76 } | 86 } |
77 | 87 |
78 } // namespace drive_backend | 88 } // namespace drive_backend |
79 } // namespace sync_file_system | 89 } // namespace sync_file_system |
OLD | NEW |