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 <unordered_set> |
| 8 |
7 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
8 #include "base/logging.h" | 10 #include "base/logging.h" |
9 #include "base/macros.h" | 11 #include "base/macros.h" |
10 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
11 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
12 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
13 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants.
h" | 15 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants.
h" |
14 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_util.h" | 16 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_util.h" |
15 #include "chrome/browser/sync_file_system/drive_backend/leveldb_wrapper.h" | 17 #include "chrome/browser/sync_file_system/drive_backend/leveldb_wrapper.h" |
16 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.pb.h" | 18 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.pb.h" |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 } | 204 } |
203 | 205 |
204 AppendContents( | 206 AppendContents( |
205 LookUpMap(trackers_by_parent, tracker_id, std::set<int64_t>()), | 207 LookUpMap(trackers_by_parent, tracker_id, std::set<int64_t>()), |
206 &pending); | 208 &pending); |
207 } | 209 } |
208 } | 210 } |
209 | 211 |
210 // Delete all unreachable trackers, and list all |file_id| referred by | 212 // Delete all unreachable trackers, and list all |file_id| referred by |
211 // remained trackers. | 213 // remained trackers. |
212 base::hash_set<std::string> referred_file_ids; | 214 std::unordered_set<std::string> referred_file_ids; |
213 { | 215 { |
214 std::unique_ptr<LevelDBWrapper::Iterator> itr = db->NewIterator(); | 216 std::unique_ptr<LevelDBWrapper::Iterator> itr = db->NewIterator(); |
215 for (itr->Seek(kFileTrackerKeyPrefix); itr->Valid(); itr->Next()) { | 217 for (itr->Seek(kFileTrackerKeyPrefix); itr->Valid(); itr->Next()) { |
216 if (!RemovePrefix(itr->key().ToString(), kFileTrackerKeyPrefix, nullptr)) | 218 if (!RemovePrefix(itr->key().ToString(), kFileTrackerKeyPrefix, nullptr)) |
217 break; | 219 break; |
218 | 220 |
219 std::unique_ptr<FileTracker> tracker(new FileTracker); | 221 std::unique_ptr<FileTracker> tracker(new FileTracker); |
220 if (!tracker->ParseFromString(itr->value().ToString())) { | 222 if (!tracker->ParseFromString(itr->value().ToString())) { |
221 util::Log(logging::LOG_WARNING, FROM_HERE, | 223 util::Log(logging::LOG_WARNING, FROM_HERE, |
222 "Failed to parse a Tracker"); | 224 "Failed to parse a Tracker"); |
(...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1212 for (itr->Seek(prefix); itr->Valid();) { | 1214 for (itr->Seek(prefix); itr->Valid();) { |
1213 const std::string key = itr->key().ToString(); | 1215 const std::string key = itr->key().ToString(); |
1214 if (!base::StartsWith(key, prefix, base::CompareCase::SENSITIVE)) | 1216 if (!base::StartsWith(key, prefix, base::CompareCase::SENSITIVE)) |
1215 break; | 1217 break; |
1216 itr->Delete(); | 1218 itr->Delete(); |
1217 } | 1219 } |
1218 } | 1220 } |
1219 | 1221 |
1220 } // namespace drive_backend | 1222 } // namespace drive_backend |
1221 } // namespace sync_file_system | 1223 } // namespace sync_file_system |
OLD | NEW |