| 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_SYNC_ENGINE_INITIALIZER_H_ | 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_ENGINE_INITIALIZER_H_ |
| 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_ENGINE_INITIALIZER_H_ | 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_ENGINE_INITIALIZER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> |
| 10 #include <string> | 11 #include <string> |
| 11 | 12 |
| 12 #include "base/macros.h" | 13 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | |
| 15 #include "base/memory/scoped_vector.h" | 15 #include "base/memory/scoped_vector.h" |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "chrome/browser/sync_file_system/drive_backend/sync_task.h" | 17 #include "chrome/browser/sync_file_system/drive_backend/sync_task.h" |
| 18 #include "chrome/browser/sync_file_system/sync_callbacks.h" | 18 #include "chrome/browser/sync_file_system/sync_callbacks.h" |
| 19 #include "google_apis/drive/drive_api_error_codes.h" | 19 #include "google_apis/drive/drive_api_error_codes.h" |
| 20 #include "google_apis/drive/drive_common_callbacks.h" | 20 #include "google_apis/drive/drive_common_callbacks.h" |
| 21 | 21 |
| 22 namespace drive { | 22 namespace drive { |
| 23 class DriveServiceInterface; | 23 class DriveServiceInterface; |
| 24 } | 24 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 // as regular inactive folders until they are registered explicitly. | 65 // as regular inactive folders until they are registered explicitly. |
| 66 // - Populate database with the largest change ID, the sync-root folder and | 66 // - Populate database with the largest change ID, the sync-root folder and |
| 67 // its contents. | 67 // its contents. |
| 68 // | 68 // |
| 69 class SyncEngineInitializer : public SyncTask { | 69 class SyncEngineInitializer : public SyncTask { |
| 70 public: | 70 public: |
| 71 SyncEngineInitializer(SyncEngineContext* sync_context, | 71 SyncEngineInitializer(SyncEngineContext* sync_context, |
| 72 const base::FilePath& database_path, | 72 const base::FilePath& database_path, |
| 73 leveldb::Env* env_override); | 73 leveldb::Env* env_override); |
| 74 ~SyncEngineInitializer() override; | 74 ~SyncEngineInitializer() override; |
| 75 void RunPreflight(scoped_ptr<SyncTaskToken> token) override; | 75 void RunPreflight(std::unique_ptr<SyncTaskToken> token) override; |
| 76 | 76 |
| 77 scoped_ptr<MetadataDatabase> PassMetadataDatabase(); | 77 std::unique_ptr<MetadataDatabase> PassMetadataDatabase(); |
| 78 | 78 |
| 79 private: | 79 private: |
| 80 typedef base::Callback<void(const SyncStatusCallback& callback)> Task; | 80 typedef base::Callback<void(const SyncStatusCallback& callback)> Task; |
| 81 | 81 |
| 82 void GetAboutResource(scoped_ptr<SyncTaskToken> token); | 82 void GetAboutResource(std::unique_ptr<SyncTaskToken> token); |
| 83 void DidGetAboutResource( | 83 void DidGetAboutResource( |
| 84 scoped_ptr<SyncTaskToken> token, | 84 std::unique_ptr<SyncTaskToken> token, |
| 85 google_apis::DriveApiErrorCode error, | 85 google_apis::DriveApiErrorCode error, |
| 86 scoped_ptr<google_apis::AboutResource> about_resource); | 86 std::unique_ptr<google_apis::AboutResource> about_resource); |
| 87 void FindSyncRoot(scoped_ptr<SyncTaskToken> token); | 87 void FindSyncRoot(std::unique_ptr<SyncTaskToken> token); |
| 88 void DidFindSyncRoot(scoped_ptr<SyncTaskToken> token, | 88 void DidFindSyncRoot(std::unique_ptr<SyncTaskToken> token, |
| 89 google_apis::DriveApiErrorCode error, | 89 google_apis::DriveApiErrorCode error, |
| 90 scoped_ptr<google_apis::FileList> file_list); | 90 std::unique_ptr<google_apis::FileList> file_list); |
| 91 void CreateSyncRoot(scoped_ptr<SyncTaskToken> token); | 91 void CreateSyncRoot(std::unique_ptr<SyncTaskToken> token); |
| 92 void DidCreateSyncRoot(scoped_ptr<SyncTaskToken> token, | 92 void DidCreateSyncRoot(std::unique_ptr<SyncTaskToken> token, |
| 93 google_apis::DriveApiErrorCode error, | 93 google_apis::DriveApiErrorCode error, |
| 94 scoped_ptr<google_apis::FileResource> entry); | 94 std::unique_ptr<google_apis::FileResource> entry); |
| 95 void DetachSyncRoot(scoped_ptr<SyncTaskToken> token); | 95 void DetachSyncRoot(std::unique_ptr<SyncTaskToken> token); |
| 96 void DidDetachSyncRoot(scoped_ptr<SyncTaskToken> token, | 96 void DidDetachSyncRoot(std::unique_ptr<SyncTaskToken> token, |
| 97 google_apis::DriveApiErrorCode error); | 97 google_apis::DriveApiErrorCode error); |
| 98 void ListAppRootFolders(scoped_ptr<SyncTaskToken> token); | 98 void ListAppRootFolders(std::unique_ptr<SyncTaskToken> token); |
| 99 void DidListAppRootFolders( | 99 void DidListAppRootFolders(std::unique_ptr<SyncTaskToken> token, |
| 100 scoped_ptr<SyncTaskToken> token, | 100 google_apis::DriveApiErrorCode error, |
| 101 google_apis::DriveApiErrorCode error, | 101 std::unique_ptr<google_apis::FileList> file_list); |
| 102 scoped_ptr<google_apis::FileList> file_list); | 102 void PopulateDatabase(std::unique_ptr<SyncTaskToken> token); |
| 103 void PopulateDatabase(scoped_ptr<SyncTaskToken> token); | |
| 104 | 103 |
| 105 SyncEngineContext* sync_context_; // Not owned. | 104 SyncEngineContext* sync_context_; // Not owned. |
| 106 leveldb::Env* env_override_; | 105 leveldb::Env* env_override_; |
| 107 | 106 |
| 108 google_apis::CancelCallback cancel_callback_; | 107 google_apis::CancelCallback cancel_callback_; |
| 109 base::FilePath database_path_; | 108 base::FilePath database_path_; |
| 110 | 109 |
| 111 int find_sync_root_retry_count_; | 110 int find_sync_root_retry_count_; |
| 112 | 111 |
| 113 scoped_ptr<MetadataDatabase> metadata_database_; | 112 std::unique_ptr<MetadataDatabase> metadata_database_; |
| 114 ScopedVector<google_apis::FileResource> app_root_folders_; | 113 ScopedVector<google_apis::FileResource> app_root_folders_; |
| 115 | 114 |
| 116 int64_t largest_change_id_; | 115 int64_t largest_change_id_; |
| 117 std::string root_folder_id_; | 116 std::string root_folder_id_; |
| 118 | 117 |
| 119 scoped_ptr<google_apis::FileResource> sync_root_folder_; | 118 std::unique_ptr<google_apis::FileResource> sync_root_folder_; |
| 120 | 119 |
| 121 base::WeakPtrFactory<SyncEngineInitializer> weak_ptr_factory_; | 120 base::WeakPtrFactory<SyncEngineInitializer> weak_ptr_factory_; |
| 122 | 121 |
| 123 DISALLOW_COPY_AND_ASSIGN(SyncEngineInitializer); | 122 DISALLOW_COPY_AND_ASSIGN(SyncEngineInitializer); |
| 124 }; | 123 }; |
| 125 | 124 |
| 126 } // namespace drive_backend | 125 } // namespace drive_backend |
| 127 } // namespace sync_file_system | 126 } // namespace sync_file_system |
| 128 | 127 |
| 129 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_ENGINE_INITIALIZER
_H_ | 128 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_ENGINE_INITIALIZER
_H_ |
| OLD | NEW |