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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 const CreateCallback& callback); | 127 const CreateCallback& callback); |
128 ~MetadataDatabase(); | 128 ~MetadataDatabase(); |
129 | 129 |
130 int64 GetLargestFetchedChangeID() const; | 130 int64 GetLargestFetchedChangeID() const; |
131 int64 GetSyncRootTrackerID() const; | 131 int64 GetSyncRootTrackerID() const; |
132 bool HasSyncRoot() const; | 132 bool HasSyncRoot() const; |
133 | 133 |
134 // Returns all file metadata for the given |app_id|. | 134 // Returns all file metadata for the given |app_id|. |
135 scoped_ptr<base::ListValue> DumpFiles(const std::string& app_id); | 135 scoped_ptr<base::ListValue> DumpFiles(const std::string& app_id); |
136 | 136 |
| 137 // Returns all database data. |
| 138 scoped_ptr<base::ListValue> DumpDatabase(); |
| 139 |
137 // TODO(tzik): Move GetLargestKnownChangeID() to private section, and hide its | 140 // TODO(tzik): Move GetLargestKnownChangeID() to private section, and hide its |
138 // handling in the class, instead of letting user do. | 141 // handling in the class, instead of letting user do. |
139 // | 142 // |
140 // Gets / updates the largest known change ID. | 143 // Gets / updates the largest known change ID. |
141 // The largest known change ID is on-memory and not persist over restart. | 144 // The largest known change ID is on-memory and not persist over restart. |
142 // This is supposed to use when a task fetches ChangeList in parallel to other | 145 // This is supposed to use when a task fetches ChangeList in parallel to other |
143 // operation. When a task starts fetching paged ChangeList one by one, it | 146 // operation. When a task starts fetching paged ChangeList one by one, it |
144 // should update the largest known change ID on the first round and background | 147 // should update the largest known change ID on the first round and background |
145 // remaining fetch job. | 148 // remaining fetch job. |
146 // Then, when other tasks that update FileMetadata by UpdateByFileResource, | 149 // Then, when other tasks that update FileMetadata by UpdateByFileResource, |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 bool FindTrackersByParentAndTitle( | 222 bool FindTrackersByParentAndTitle( |
220 int64 parent_tracker_id, | 223 int64 parent_tracker_id, |
221 const std::string& title, | 224 const std::string& title, |
222 TrackerSet* trackers) const; | 225 TrackerSet* trackers) const; |
223 | 226 |
224 // Builds the file path for the given tracker. Returns true on success. | 227 // Builds the file path for the given tracker. Returns true on success. |
225 // |path| can be NULL. | 228 // |path| can be NULL. |
226 // The file path is relative to app-root and have a leading path separator. | 229 // The file path is relative to app-root and have a leading path separator. |
227 bool BuildPathForTracker(int64 tracker_id, base::FilePath* path) const; | 230 bool BuildPathForTracker(int64 tracker_id, base::FilePath* path) const; |
228 | 231 |
| 232 // Builds the file path for the given tracker for display purpose. |
| 233 // This may return a path ending with '<unknown>' if the given tracker does |
| 234 // not have title information (yet). This may return an empty path. |
| 235 base::FilePath BuildDisplayPathForTracker(const FileTracker& tracker) const; |
| 236 |
229 // Returns false if no registered app exists associated to |app_id|. | 237 // Returns false if no registered app exists associated to |app_id|. |
230 // If |full_path| is active, assigns the tracker of |full_path| to |tracker|. | 238 // If |full_path| is active, assigns the tracker of |full_path| to |tracker|. |
231 // Otherwise, assigns the nearest active ancestor to |full_path| to |tracker|. | 239 // Otherwise, assigns the nearest active ancestor to |full_path| to |tracker|. |
232 // Also, assigns the full path of |tracker| to |path|. | 240 // Also, assigns the full path of |tracker| to |path|. |
233 bool FindNearestActiveAncestor(const std::string& app_id, | 241 bool FindNearestActiveAncestor(const std::string& app_id, |
234 const base::FilePath& full_path, | 242 const base::FilePath& full_path, |
235 FileTracker* tracker, | 243 FileTracker* tracker, |
236 base::FilePath* path) const; | 244 base::FilePath* path) const; |
237 | 245 |
238 // Updates database by |changes|. | 246 // Updates database by |changes|. |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 | 403 |
396 void UpdateByFileMetadata(const tracked_objects::Location& from_where, | 404 void UpdateByFileMetadata(const tracked_objects::Location& from_where, |
397 scoped_ptr<FileMetadata> file, | 405 scoped_ptr<FileMetadata> file, |
398 leveldb::WriteBatch* batch); | 406 leveldb::WriteBatch* batch); |
399 | 407 |
400 void WriteToDatabase(scoped_ptr<leveldb::WriteBatch> batch, | 408 void WriteToDatabase(scoped_ptr<leveldb::WriteBatch> batch, |
401 const SyncStatusCallback& callback); | 409 const SyncStatusCallback& callback); |
402 | 410 |
403 bool HasNewerFileMetadata(const std::string& file_id, int64 change_id); | 411 bool HasNewerFileMetadata(const std::string& file_id, int64 change_id); |
404 | 412 |
| 413 scoped_ptr<base::ListValue> DumpTrackers(); |
| 414 scoped_ptr<base::ListValue> DumpMetadata(); |
| 415 |
405 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 416 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
406 scoped_ptr<leveldb::DB> db_; | 417 scoped_ptr<leveldb::DB> db_; |
407 | 418 |
408 scoped_ptr<ServiceMetadata> service_metadata_; | 419 scoped_ptr<ServiceMetadata> service_metadata_; |
409 int64 largest_known_change_id_; | 420 int64 largest_known_change_id_; |
410 | 421 |
411 FileByID file_by_id_; // Owned. | 422 FileByID file_by_id_; // Owned. |
412 TrackerByID tracker_by_id_; // Owned. | 423 TrackerByID tracker_by_id_; // Owned. |
413 | 424 |
414 // Maps FileID to trackers. The active tracker must be unique per FileID. | 425 // Maps FileID to trackers. The active tracker must be unique per FileID. |
(...skipping 20 matching lines...) Expand all Loading... |
435 | 446 |
436 base::WeakPtrFactory<MetadataDatabase> weak_ptr_factory_; | 447 base::WeakPtrFactory<MetadataDatabase> weak_ptr_factory_; |
437 | 448 |
438 DISALLOW_COPY_AND_ASSIGN(MetadataDatabase); | 449 DISALLOW_COPY_AND_ASSIGN(MetadataDatabase); |
439 }; | 450 }; |
440 | 451 |
441 } // namespace drive_backend | 452 } // namespace drive_backend |
442 } // namespace sync_file_system | 453 } // namespace sync_file_system |
443 | 454 |
444 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_H_ | 455 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_H_ |
OLD | NEW |