Chromium Code Reviews| 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_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_H_ | 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_H_ |
| 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_H_ | 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 187 void UpdateByChangeList(ScopedVector<google_apis::ChangeResource> changes, | 187 void UpdateByChangeList(ScopedVector<google_apis::ChangeResource> changes, |
| 188 const SyncStatusCallback& callback); | 188 const SyncStatusCallback& callback); |
| 189 | 189 |
| 190 // Adds |child_file_ids| to |folder_id| as its children. | 190 // Adds |child_file_ids| to |folder_id| as its children. |
| 191 // This method affects the active tracker only. | 191 // This method affects the active tracker only. |
| 192 // If the tracker has no further change to sync, unmarks its dirty flag. | 192 // If the tracker has no further change to sync, unmarks its dirty flag. |
| 193 void PopulateFolder(const std::string& folder_id, | 193 void PopulateFolder(const std::string& folder_id, |
| 194 const FileIDList& child_file_ids, | 194 const FileIDList& child_file_ids, |
| 195 const SyncStatusCallback& callback); | 195 const SyncStatusCallback& callback); |
| 196 | 196 |
| 197 // Update |synced_details| of the tracker to |updated_details|. | |
|
kinuko
2013/08/27 07:47:05
nit: to -> with
tzik
2013/08/30 05:51:57
Done.
| |
| 198 void UpdateTracker(int64 tracker_id, | |
| 199 const FileDetails& updated_details, | |
| 200 const SyncStatusCallback& callback); | |
| 201 | |
| 197 private: | 202 private: |
| 198 struct DirtyTrackerComparator { | 203 struct DirtyTrackerComparator { |
| 199 bool operator()(const FileTracker* left, | 204 bool operator()(const FileTracker* left, |
| 200 const FileTracker* right) const; | 205 const FileTracker* right) const; |
| 201 }; | 206 }; |
| 202 | 207 |
| 203 typedef std::set<FileTracker*, DirtyTrackerComparator> DirtyTrackers; | 208 typedef std::set<FileTracker*, DirtyTrackerComparator> DirtyTrackers; |
| 204 | 209 |
| 205 friend class MetadataDatabaseTest; | 210 friend class MetadataDatabaseTest; |
| 206 | 211 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 225 void MakeAppRootEnabled(int64 tracker_id, leveldb::WriteBatch* batch); | 230 void MakeAppRootEnabled(int64 tracker_id, leveldb::WriteBatch* batch); |
| 226 | 231 |
| 227 void UnregisterTrackerAsAppRoot(const std::string& app_id, | 232 void UnregisterTrackerAsAppRoot(const std::string& app_id, |
| 228 leveldb::WriteBatch* batch); | 233 leveldb::WriteBatch* batch); |
| 229 void RemoveAllDescendantTrackers(int64 root_tracker_id, | 234 void RemoveAllDescendantTrackers(int64 root_tracker_id, |
| 230 leveldb::WriteBatch* batch); | 235 leveldb::WriteBatch* batch); |
| 231 | 236 |
| 232 void CreateTrackerForParentAndFileID(const FileTracker& parent_tracker, | 237 void CreateTrackerForParentAndFileID(const FileTracker& parent_tracker, |
| 233 const std::string& file_id, | 238 const std::string& file_id, |
| 234 leveldb::WriteBatch* batch); | 239 leveldb::WriteBatch* batch); |
| 240 void RemoveTracker(int64 tracker_id, leveldb::WriteBatch* batch); | |
| 235 void RemoveTrackerIgnoringSiblings(int64 tracker_id, | 241 void RemoveTrackerIgnoringSiblings(int64 tracker_id, |
| 236 leveldb::WriteBatch* batch); | 242 leveldb::WriteBatch* batch); |
| 243 void RemoveTrackerInternal(int64 tracker_id, | |
| 244 leveldb::WriteBatch* batch, | |
| 245 bool ignore_name_conflicted_trackers); | |
| 237 void MaybeAddTrackersForNewFile(const FileMetadata& file, | 246 void MaybeAddTrackersForNewFile(const FileMetadata& file, |
| 238 leveldb::WriteBatch* batch); | 247 leveldb::WriteBatch* batch); |
| 239 | 248 |
| 240 void MarkTrackerSetDirty(TrackerSet* trackers, | 249 void MarkTrackerSetDirty(TrackerSet* trackers, |
| 241 leveldb::WriteBatch* batch); | 250 leveldb::WriteBatch* batch); |
| 242 void MarkTrackersDirtyByFileID(const std::string& file_id, | 251 void MarkTrackersDirtyByFileID(const std::string& file_id, |
| 243 leveldb::WriteBatch* batch); | 252 leveldb::WriteBatch* batch); |
| 244 void MarkTrackersDirtyByPath(int64 parent_tracker_id, | 253 void MarkTrackersDirtyByPath(int64 parent_tracker_id, |
| 245 const std::string& title, | 254 const std::string& title, |
| 246 leveldb::WriteBatch* batch); | 255 leveldb::WriteBatch* batch); |
| 247 | 256 |
| 248 void EraseTrackerFromFileIDIndex(FileTracker* tracker, | 257 void EraseTrackerFromFileIDIndex(FileTracker* tracker, |
| 249 leveldb::WriteBatch* batch); | 258 leveldb::WriteBatch* batch); |
| 250 void EraseTrackerFromPathIndex(FileTracker* tracker); | 259 void EraseTrackerFromPathIndex(FileTracker* tracker); |
| 251 void EraseFileFromDatabase(const std::string& file_id, | 260 void EraseFileFromDatabase(const std::string& file_id, |
| 252 leveldb::WriteBatch* batch); | 261 leveldb::WriteBatch* batch); |
| 253 | 262 |
| 254 int64 GetNextTrackerID(leveldb::WriteBatch* batch); | 263 int64 GetNextTrackerID(leveldb::WriteBatch* batch); |
| 255 | 264 |
| 256 void RecursiveMarkTrackerAsDirty(int64 root_tracker_id, | 265 void RecursiveMarkTrackerAsDirty(int64 root_tracker_id, |
| 257 leveldb::WriteBatch* batch); | 266 leveldb::WriteBatch* batch); |
| 267 bool CanActivateTracker(const FileTracker& tracker); | |
| 258 bool ShouldKeepDirty(const FileTracker& tracker) const; | 268 bool ShouldKeepDirty(const FileTracker& tracker) const; |
| 259 | 269 |
| 270 bool HasDisabledAppRoot(const FileTracker& tracker) const; | |
| 271 bool HasActiveTrackerForFileID(const std::string& file_id) const; | |
| 272 bool HasActiveTrackerForPath(int64 parent_tracker, | |
| 273 const std::string& title) const; | |
| 274 | |
| 275 void UpdateTrackerTitle(FileTracker* tracker, | |
| 276 const std::string& new_title, | |
| 277 leveldb::WriteBatch* batch); | |
| 278 | |
| 260 void WriteToDatabase(scoped_ptr<leveldb::WriteBatch> batch, | 279 void WriteToDatabase(scoped_ptr<leveldb::WriteBatch> batch, |
| 261 const SyncStatusCallback& callback); | 280 const SyncStatusCallback& callback); |
| 262 | 281 |
| 263 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 282 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
| 264 scoped_ptr<leveldb::DB> db_; | 283 scoped_ptr<leveldb::DB> db_; |
| 265 | 284 |
| 266 scoped_ptr<ServiceMetadata> service_metadata_; | 285 scoped_ptr<ServiceMetadata> service_metadata_; |
| 267 | 286 |
| 268 FileByID file_by_id_; // Owned. | 287 FileByID file_by_id_; // Owned. |
| 269 TrackerByID tracker_by_id_; // Owned. | 288 TrackerByID tracker_by_id_; // Owned. |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 291 | 310 |
| 292 base::WeakPtrFactory<MetadataDatabase> weak_ptr_factory_; | 311 base::WeakPtrFactory<MetadataDatabase> weak_ptr_factory_; |
| 293 | 312 |
| 294 DISALLOW_COPY_AND_ASSIGN(MetadataDatabase); | 313 DISALLOW_COPY_AND_ASSIGN(MetadataDatabase); |
| 295 }; | 314 }; |
| 296 | 315 |
| 297 } // namespace drive_backend | 316 } // namespace drive_backend |
| 298 } // namespace sync_file_system | 317 } // namespace sync_file_system |
| 299 | 318 |
| 300 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_H_ | 319 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_H_ |
| OLD | NEW |