| 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 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_RESOURCE_METADATA_STORAGE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_RESOURCE_METADATA_STORAGE_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_RESOURCE_METADATA_STORAGE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_RESOURCE_METADATA_STORAGE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 // Used to implement Advance(). | 98 // Used to implement Advance(). |
| 99 void AdvanceInternal(); | 99 void AdvanceInternal(); |
| 100 | 100 |
| 101 scoped_ptr<leveldb::Iterator> it_; | 101 scoped_ptr<leveldb::Iterator> it_; |
| 102 std::string id_; | 102 std::string id_; |
| 103 FileCacheEntry entry_; | 103 FileCacheEntry entry_; |
| 104 | 104 |
| 105 DISALLOW_COPY_AND_ASSIGN(CacheEntryIterator); | 105 DISALLOW_COPY_AND_ASSIGN(CacheEntryIterator); |
| 106 }; | 106 }; |
| 107 | 107 |
| 108 // Cache information recovered from trashed DB. |
| 109 struct RecoveredCacheInfo { |
| 110 RecoveredCacheInfo(); |
| 111 ~RecoveredCacheInfo(); |
| 112 |
| 113 bool is_dirty; |
| 114 std::string md5; |
| 115 std::string title; |
| 116 }; |
| 117 typedef std::map<std::string, RecoveredCacheInfo> RecoveredCacheInfoMap; |
| 118 |
| 108 // Returns true if the DB was successfully upgraded to the newest version. | 119 // Returns true if the DB was successfully upgraded to the newest version. |
| 109 static bool UpgradeOldDB(const base::FilePath& directory_path, | 120 static bool UpgradeOldDB(const base::FilePath& directory_path, |
| 110 const ResourceIdCanonicalizer& id_canonicalizer); | 121 const ResourceIdCanonicalizer& id_canonicalizer); |
| 111 | 122 |
| 112 ResourceMetadataStorage(const base::FilePath& directory_path, | 123 ResourceMetadataStorage(const base::FilePath& directory_path, |
| 113 base::SequencedTaskRunner* blocking_task_runner); | 124 base::SequencedTaskRunner* blocking_task_runner); |
| 114 | 125 |
| 115 const base::FilePath& directory_path() const { return directory_path_; } | 126 const base::FilePath& directory_path() const { return directory_path_; } |
| 116 | 127 |
| 117 // Returns true when cache entries were not loaded to the DB during | 128 // Returns true when cache entries were not loaded to the DB during |
| 118 // initialization. | 129 // initialization. |
| 119 bool cache_file_scan_is_needed() const { return cache_file_scan_is_needed_; } | 130 bool cache_file_scan_is_needed() const { return cache_file_scan_is_needed_; } |
| 120 | 131 |
| 121 // Destroys this object. | 132 // Destroys this object. |
| 122 void Destroy(); | 133 void Destroy(); |
| 123 | 134 |
| 124 // Initializes this object. | 135 // Initializes this object. |
| 125 bool Initialize(); | 136 bool Initialize(); |
| 126 | 137 |
| 127 // Collects FileCacheEntry from trashed resource map DB. | 138 // Collects cache info from trashed resource map DB. |
| 128 void RecoverCacheEntriesFromTrashedResourceMap( | 139 void RecoverCacheInfoFromTrashedResourceMap(RecoveredCacheInfoMap* out_info); |
| 129 std::map<std::string, FileCacheEntry>* out_entries); | |
| 130 | 140 |
| 131 // Sets the largest changestamp. | 141 // Sets the largest changestamp. |
| 132 bool SetLargestChangestamp(int64 largest_changestamp); | 142 bool SetLargestChangestamp(int64 largest_changestamp); |
| 133 | 143 |
| 134 // Gets the largest changestamp. | 144 // Gets the largest changestamp. |
| 135 int64 GetLargestChangestamp(); | 145 int64 GetLargestChangestamp(); |
| 136 | 146 |
| 137 // Puts the entry to this storage. | 147 // Puts the entry to this storage. |
| 138 bool PutEntry(const ResourceEntry& entry); | 148 bool PutEntry(const ResourceEntry& entry); |
| 139 | 149 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 | 211 |
| 202 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; | 212 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; |
| 203 | 213 |
| 204 DISALLOW_COPY_AND_ASSIGN(ResourceMetadataStorage); | 214 DISALLOW_COPY_AND_ASSIGN(ResourceMetadataStorage); |
| 205 }; | 215 }; |
| 206 | 216 |
| 207 } // namespace internal | 217 } // namespace internal |
| 208 } // namespace drive | 218 } // namespace drive |
| 209 | 219 |
| 210 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_RESOURCE_METADATA_STORAGE_H_ | 220 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_RESOURCE_METADATA_STORAGE_H_ |
| OLD | NEW |