OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_database_index_
on_disk.h" | 5 #include "chrome/browser/sync_file_system/drive_backend/metadata_database_index_
on_disk.h" |
6 | 6 |
7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 if (!RemovePrefix(itr->key().ToString(), kFileTrackerKeyPrefix, nullptr)) | 216 if (!RemovePrefix(itr->key().ToString(), kFileTrackerKeyPrefix, nullptr)) |
217 break; | 217 break; |
218 | 218 |
219 std::unique_ptr<FileTracker> tracker(new FileTracker); | 219 std::unique_ptr<FileTracker> tracker(new FileTracker); |
220 if (!tracker->ParseFromString(itr->value().ToString())) { | 220 if (!tracker->ParseFromString(itr->value().ToString())) { |
221 util::Log(logging::LOG_WARNING, FROM_HERE, | 221 util::Log(logging::LOG_WARNING, FROM_HERE, |
222 "Failed to parse a Tracker"); | 222 "Failed to parse a Tracker"); |
223 continue; | 223 continue; |
224 } | 224 } |
225 | 225 |
226 if (ContainsKey(visited_trackers, tracker->tracker_id())) { | 226 if (base::ContainsKey(visited_trackers, tracker->tracker_id())) { |
227 referred_file_ids.insert(tracker->file_id()); | 227 referred_file_ids.insert(tracker->file_id()); |
228 } else { | 228 } else { |
229 PutFileTrackerDeletionToDB(tracker->tracker_id(), db); | 229 PutFileTrackerDeletionToDB(tracker->tracker_id(), db); |
230 } | 230 } |
231 } | 231 } |
232 } | 232 } |
233 | 233 |
234 // Delete all unreferred metadata. | 234 // Delete all unreferred metadata. |
235 { | 235 { |
236 std::unique_ptr<LevelDBWrapper::Iterator> itr = db->NewIterator(); | 236 std::unique_ptr<LevelDBWrapper::Iterator> itr = db->NewIterator(); |
237 for (itr->Seek(kFileMetadataKeyPrefix); itr->Valid(); itr->Next()) { | 237 for (itr->Seek(kFileMetadataKeyPrefix); itr->Valid(); itr->Next()) { |
238 if (!RemovePrefix(itr->key().ToString(), kFileMetadataKeyPrefix, nullptr)) | 238 if (!RemovePrefix(itr->key().ToString(), kFileMetadataKeyPrefix, nullptr)) |
239 break; | 239 break; |
240 | 240 |
241 std::unique_ptr<FileMetadata> metadata(new FileMetadata); | 241 std::unique_ptr<FileMetadata> metadata(new FileMetadata); |
242 if (!metadata->ParseFromString(itr->value().ToString())) { | 242 if (!metadata->ParseFromString(itr->value().ToString())) { |
243 util::Log(logging::LOG_WARNING, FROM_HERE, | 243 util::Log(logging::LOG_WARNING, FROM_HERE, |
244 "Failed to parse a Tracker"); | 244 "Failed to parse a Tracker"); |
245 continue; | 245 continue; |
246 } | 246 } |
247 | 247 |
248 if (!ContainsKey(referred_file_ids, metadata->file_id())) | 248 if (!base::ContainsKey(referred_file_ids, metadata->file_id())) |
249 PutFileMetadataDeletionToDB(metadata->file_id(), db); | 249 PutFileMetadataDeletionToDB(metadata->file_id(), db); |
250 } | 250 } |
251 } | 251 } |
252 } | 252 } |
253 | 253 |
254 } // namespace | 254 } // namespace |
255 | 255 |
256 // static | 256 // static |
257 std::unique_ptr<MetadataDatabaseIndexOnDisk> | 257 std::unique_ptr<MetadataDatabaseIndexOnDisk> |
258 MetadataDatabaseIndexOnDisk::Create(LevelDBWrapper* db) { | 258 MetadataDatabaseIndexOnDisk::Create(LevelDBWrapper* db) { |
(...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1212 for (itr->Seek(prefix); itr->Valid();) { | 1212 for (itr->Seek(prefix); itr->Valid();) { |
1213 const std::string key = itr->key().ToString(); | 1213 const std::string key = itr->key().ToString(); |
1214 if (!base::StartsWith(key, prefix, base::CompareCase::SENSITIVE)) | 1214 if (!base::StartsWith(key, prefix, base::CompareCase::SENSITIVE)) |
1215 break; | 1215 break; |
1216 itr->Delete(); | 1216 itr->Delete(); |
1217 } | 1217 } |
1218 } | 1218 } |
1219 | 1219 |
1220 } // namespace drive_backend | 1220 } // namespace drive_backend |
1221 } // namespace sync_file_system | 1221 } // namespace sync_file_system |
OLD | NEW |