| 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 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_INDEX_H_ | 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_INDEX_H_ |
| 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_INDEX_H_ | 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_INDEX_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <map> | 11 #include <map> |
| 12 #include <set> | 12 #include <set> |
| 13 #include <string> | 13 #include <string> |
| 14 #include <unordered_map> | 14 #include <unordered_map> |
| 15 #include <unordered_set> |
| 15 #include <vector> | 16 #include <vector> |
| 16 | 17 |
| 17 #include "base/containers/hash_tables.h" | |
| 18 #include "base/hash.h" | 18 #include "base/hash.h" |
| 19 #include "base/macros.h" | 19 #include "base/macros.h" |
| 20 #include "chrome/browser/sync_file_system/drive_backend/metadata_database_index_
interface.h" | 20 #include "chrome/browser/sync_file_system/drive_backend/metadata_database_index_
interface.h" |
| 21 #include "chrome/browser/sync_file_system/drive_backend/tracker_id_set.h" | 21 #include "chrome/browser/sync_file_system/drive_backend/tracker_id_set.h" |
| 22 | 22 |
| 23 namespace sync_file_system { | 23 namespace sync_file_system { |
| 24 namespace drive_backend { | 24 namespace drive_backend { |
| 25 | 25 |
| 26 class FileMetadata; | 26 class FileMetadata; |
| 27 class FileTracker; | 27 class FileTracker; |
| 28 class LevelDBWrapper; | 28 class LevelDBWrapper; |
| 29 class ServiceMetadata; | 29 class ServiceMetadata; |
| 30 | 30 |
| 31 } // namespace drive_backend | 31 } // namespace drive_backend |
| 32 } // namespace sync_file_system | 32 } // namespace sync_file_system |
| 33 | 33 |
| 34 namespace BASE_HASH_NAMESPACE { | 34 namespace std { |
| 35 | 35 |
| 36 template<> struct hash<sync_file_system::drive_backend::ParentIDAndTitle> { | 36 template<> struct hash<sync_file_system::drive_backend::ParentIDAndTitle> { |
| 37 std::size_t operator()( | 37 std::size_t operator()( |
| 38 const sync_file_system::drive_backend::ParentIDAndTitle& v) const { | 38 const sync_file_system::drive_backend::ParentIDAndTitle& v) const { |
| 39 return base::HashInts64(v.parent_id, hash<std::string>()(v.title)); | 39 return base::HashInts64(v.parent_id, hash<std::string>()(v.title)); |
| 40 } | 40 } |
| 41 }; | 41 }; |
| 42 | 42 |
| 43 } // namespace BASE_HASH_NAMESPACE | 43 } // namespace std |
| 44 | 44 |
| 45 namespace sync_file_system { | 45 namespace sync_file_system { |
| 46 namespace drive_backend { | 46 namespace drive_backend { |
| 47 | 47 |
| 48 struct DatabaseContents { | 48 struct DatabaseContents { |
| 49 DatabaseContents(); | 49 DatabaseContents(); |
| 50 ~DatabaseContents(); | 50 ~DatabaseContents(); |
| 51 std::vector<std::unique_ptr<FileMetadata>> file_metadata; | 51 std::vector<std::unique_ptr<FileMetadata>> file_metadata; |
| 52 std::vector<std::unique_ptr<FileTracker>> file_trackers; | 52 std::vector<std::unique_ptr<FileTracker>> file_trackers; |
| 53 }; | 53 }; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 int64_t GetLargestChangeID() const override; | 99 int64_t GetLargestChangeID() const override; |
| 100 int64_t GetNextTrackerID() const override; | 100 int64_t GetNextTrackerID() const override; |
| 101 std::vector<std::string> GetRegisteredAppIDs() const override; | 101 std::vector<std::string> GetRegisteredAppIDs() const override; |
| 102 std::vector<int64_t> GetAllTrackerIDs() const override; | 102 std::vector<int64_t> GetAllTrackerIDs() const override; |
| 103 std::vector<std::string> GetAllMetadataIDs() const override; | 103 std::vector<std::string> GetAllMetadataIDs() const override; |
| 104 | 104 |
| 105 private: | 105 private: |
| 106 typedef std::unordered_map<std::string, std::unique_ptr<FileMetadata>> | 106 typedef std::unordered_map<std::string, std::unique_ptr<FileMetadata>> |
| 107 MetadataByID; | 107 MetadataByID; |
| 108 typedef std::unordered_map<int64_t, std::unique_ptr<FileTracker>> TrackerByID; | 108 typedef std::unordered_map<int64_t, std::unique_ptr<FileTracker>> TrackerByID; |
| 109 typedef base::hash_map<std::string, TrackerIDSet> TrackerIDsByFileID; | 109 typedef std::unordered_map<std::string, TrackerIDSet> TrackerIDsByFileID; |
| 110 typedef base::hash_map<std::string, TrackerIDSet> TrackerIDsByTitle; | 110 typedef std::unordered_map<std::string, TrackerIDSet> TrackerIDsByTitle; |
| 111 typedef std::map<int64_t, TrackerIDsByTitle> TrackerIDsByParentAndTitle; | 111 typedef std::map<int64_t, TrackerIDsByTitle> TrackerIDsByParentAndTitle; |
| 112 typedef base::hash_map<std::string, int64_t> TrackerIDByAppID; | 112 typedef std::unordered_map<std::string, int64_t> TrackerIDByAppID; |
| 113 typedef base::hash_set<std::string> FileIDSet; | 113 typedef std::unordered_set<std::string> FileIDSet; |
| 114 typedef base::hash_set<ParentIDAndTitle> PathSet; | 114 typedef std::unordered_set<ParentIDAndTitle> PathSet; |
| 115 typedef std::set<int64_t> DirtyTrackers; | 115 typedef std::set<int64_t> DirtyTrackers; |
| 116 | 116 |
| 117 friend class MetadataDatabaseTest; | 117 friend class MetadataDatabaseTest; |
| 118 | 118 |
| 119 explicit MetadataDatabaseIndex(LevelDBWrapper* db); | 119 explicit MetadataDatabaseIndex(LevelDBWrapper* db); |
| 120 void Initialize(std::unique_ptr<ServiceMetadata> service_metadata, | 120 void Initialize(std::unique_ptr<ServiceMetadata> service_metadata, |
| 121 DatabaseContents* contents); | 121 DatabaseContents* contents); |
| 122 | 122 |
| 123 // Maintains |app_root_by_app_id_|. | 123 // Maintains |app_root_by_app_id_|. |
| 124 void AddToAppIDIndex(const FileTracker& new_tracker); | 124 void AddToAppIDIndex(const FileTracker& new_tracker); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 DirtyTrackers dirty_trackers_; | 161 DirtyTrackers dirty_trackers_; |
| 162 DirtyTrackers demoted_dirty_trackers_; | 162 DirtyTrackers demoted_dirty_trackers_; |
| 163 | 163 |
| 164 DISALLOW_COPY_AND_ASSIGN(MetadataDatabaseIndex); | 164 DISALLOW_COPY_AND_ASSIGN(MetadataDatabaseIndex); |
| 165 }; | 165 }; |
| 166 | 166 |
| 167 } // namespace drive_backend | 167 } // namespace drive_backend |
| 168 } // namespace sync_file_system | 168 } // namespace sync_file_system |
| 169 | 169 |
| 170 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_INDEX
_H_ | 170 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_INDEX
_H_ |
| OLD | NEW |