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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 enum UpdateOption { | 126 enum UpdateOption { |
127 UPDATE_TRACKER_FOR_UNSYNCED_FILE, | 127 UPDATE_TRACKER_FOR_UNSYNCED_FILE, |
128 UPDATE_TRACKER_FOR_SYNCED_FILE, | 128 UPDATE_TRACKER_FOR_SYNCED_FILE, |
129 }; | 129 }; |
130 | 130 |
131 // The entry point of the MetadataDatabase for production code. | 131 // The entry point of the MetadataDatabase for production code. |
132 // If |env_override| is non-NULL, internal LevelDB uses |env_override| instead | 132 // If |env_override| is non-NULL, internal LevelDB uses |env_override| instead |
133 // of leveldb::Env::Default(). Use leveldb::MemEnv in test code for faster | 133 // of leveldb::Env::Default(). Use leveldb::MemEnv in test code for faster |
134 // testing. | 134 // testing. |
135 static void Create( | 135 static void Create( |
136 const scoped_refptr<base::SequencedTaskRunner>& worker_task_runner, | |
137 const base::FilePath& database_path, | 136 const base::FilePath& database_path, |
138 leveldb::Env* env_override, | 137 leveldb::Env* env_override, |
139 const CreateCallback& callback); | 138 const CreateCallback& callback); |
140 static SyncStatusCode CreateForTesting( | 139 static SyncStatusCode CreateForTesting( |
141 scoped_ptr<LevelDBWrapper> db, | 140 scoped_ptr<LevelDBWrapper> db, |
142 bool enable_on_disk_index, | 141 bool enable_on_disk_index, |
143 scoped_ptr<MetadataDatabase>* metadata_database_out); | 142 scoped_ptr<MetadataDatabase>* metadata_database_out); |
144 | 143 |
145 ~MetadataDatabase(); | 144 ~MetadataDatabase(); |
146 | 145 |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 // Clears dirty flag of trackers that can be cleared without external | 348 // Clears dirty flag of trackers that can be cleared without external |
350 // interactien. | 349 // interactien. |
351 void SweepDirtyTrackers(const std::vector<std::string>& file_ids, | 350 void SweepDirtyTrackers(const std::vector<std::string>& file_ids, |
352 const SyncStatusCallback& callback); | 351 const SyncStatusCallback& callback); |
353 | 352 |
354 private: | 353 private: |
355 friend class MetadataDatabaseTest; | 354 friend class MetadataDatabaseTest; |
356 struct CreateParam; | 355 struct CreateParam; |
357 | 356 |
358 MetadataDatabase( | 357 MetadataDatabase( |
359 const scoped_refptr<base::SequencedTaskRunner>& worker_task_runner, | |
360 const base::FilePath& database_path, | 358 const base::FilePath& database_path, |
361 bool enable_on_disk_index, | 359 bool enable_on_disk_index, |
362 leveldb::Env* env_override); | 360 leveldb::Env* env_override); |
363 static void CreateOnWorkerTaskRunner( | 361 static void CreateOnWorkerTaskRunner( |
364 scoped_ptr<CreateParam> create_param, | 362 scoped_ptr<CreateParam> create_param, |
365 const CreateCallback& callback); | 363 const CreateCallback& callback); |
366 SyncStatusCode Initialize(); | 364 SyncStatusCode Initialize(); |
367 | 365 |
368 // Database manipulation methods. | 366 // Database manipulation methods. |
369 void RegisterTrackerAsAppRoot(const std::string& app_id, | 367 void RegisterTrackerAsAppRoot(const std::string& app_id, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 scoped_ptr<base::ListValue> DumpTrackers(); | 402 scoped_ptr<base::ListValue> DumpTrackers(); |
405 scoped_ptr<base::ListValue> DumpMetadata(); | 403 scoped_ptr<base::ListValue> DumpMetadata(); |
406 | 404 |
407 void AttachSyncRoot(const google_apis::FileResource& sync_root_folder); | 405 void AttachSyncRoot(const google_apis::FileResource& sync_root_folder); |
408 void AttachInitialAppRoot(const google_apis::FileResource& app_root_folder); | 406 void AttachInitialAppRoot(const google_apis::FileResource& app_root_folder); |
409 | 407 |
410 void ForceActivateTrackerByPath(int64 parent_tracker_id, | 408 void ForceActivateTrackerByPath(int64 parent_tracker_id, |
411 const std::string& title, | 409 const std::string& title, |
412 const std::string& file_id); | 410 const std::string& file_id); |
413 | 411 |
414 void DetachFromSequence(); | |
415 bool CanClearDirty(const FileTracker& tracker); | 412 bool CanClearDirty(const FileTracker& tracker); |
416 | 413 |
417 scoped_refptr<base::SequencedTaskRunner> worker_task_runner_; | |
418 base::FilePath database_path_; | 414 base::FilePath database_path_; |
419 leveldb::Env* env_override_; | 415 leveldb::Env* env_override_; |
420 scoped_ptr<LevelDBWrapper> db_; | 416 scoped_ptr<LevelDBWrapper> db_; |
421 | 417 |
422 bool enable_on_disk_index_; | 418 bool enable_on_disk_index_; |
423 | 419 |
424 int64 largest_known_change_id_; | 420 int64 largest_known_change_id_; |
425 | 421 |
426 scoped_ptr<MetadataDatabaseIndexInterface> index_; | 422 scoped_ptr<MetadataDatabaseIndexInterface> index_; |
427 | 423 |
428 base::WeakPtrFactory<MetadataDatabase> weak_ptr_factory_; | 424 base::WeakPtrFactory<MetadataDatabase> weak_ptr_factory_; |
429 | 425 |
430 base::SequenceChecker worker_sequence_checker_; | |
431 | |
432 DISALLOW_COPY_AND_ASSIGN(MetadataDatabase); | 426 DISALLOW_COPY_AND_ASSIGN(MetadataDatabase); |
433 }; | 427 }; |
434 | 428 |
435 } // namespace drive_backend | 429 } // namespace drive_backend |
436 } // namespace sync_file_system | 430 } // namespace sync_file_system |
437 | 431 |
438 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_H_ | 432 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_H_ |
OLD | NEW |