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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 // we find the folder in the Drive root folder, handle it as the sync-root | 57 // we find the folder in the Drive root folder, handle it as the sync-root |
58 // folder. | 58 // folder. |
59 // - Create the remote sync-root folder if we don't have. | 59 // - Create the remote sync-root folder if we don't have. |
60 // - Detach the remote sync-root folder from its parent if it has. | 60 // - Detach the remote sync-root folder from its parent if it has. |
61 // - Fetch the folder contents of the remote sync-root folder. | 61 // - Fetch the folder contents of the remote sync-root folder. |
62 // The contents are likely registered as app-root folders, but handle them | 62 // The contents are likely registered as app-root folders, but handle them |
63 // as regular inactive folders until they are registered explicitly. | 63 // as regular inactive folders until they are registered explicitly. |
64 // - Populate database with the largest change ID, the sync-root folder and | 64 // - Populate database with the largest change ID, the sync-root folder and |
65 // its contents. | 65 // its contents. |
66 // | 66 // |
67 class SyncEngineInitializer : public SequentialSyncTask { | 67 class SyncEngineInitializer : public SyncTask { |
68 public: | 68 public: |
69 SyncEngineInitializer(SyncEngineContext* sync_context, | 69 SyncEngineInitializer(SyncEngineContext* sync_context, |
70 base::SequencedTaskRunner* task_runner, | 70 base::SequencedTaskRunner* task_runner, |
71 drive::DriveServiceInterface* drive_service, | 71 drive::DriveServiceInterface* drive_service, |
72 const base::FilePath& database_path, | 72 const base::FilePath& database_path, |
73 leveldb::Env* env_override); | 73 leveldb::Env* env_override); |
74 virtual ~SyncEngineInitializer(); | 74 virtual ~SyncEngineInitializer(); |
75 virtual void RunSequential(const SyncStatusCallback& callback) OVERRIDE; | 75 virtual void Run(scoped_ptr<SyncTaskToken> token) OVERRIDE; |
76 | 76 |
77 scoped_ptr<MetadataDatabase> PassMetadataDatabase(); | 77 scoped_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 DidCreateMetadataDatabase(const SyncStatusCallback& callback, | 82 void DidCreateMetadataDatabase(scoped_ptr<SyncTaskToken> token, |
83 SyncStatusCode status, | 83 SyncStatusCode status, |
84 scoped_ptr<MetadataDatabase> instance); | 84 scoped_ptr<MetadataDatabase> instance); |
85 | 85 |
86 void GetAboutResource(const SyncStatusCallback& callback); | 86 void GetAboutResource(scoped_ptr<SyncTaskToken> token); |
87 void DidGetAboutResource( | 87 void DidGetAboutResource( |
88 const SyncStatusCallback& callback, | 88 scoped_ptr<SyncTaskToken> token, |
89 google_apis::GDataErrorCode error, | 89 google_apis::GDataErrorCode error, |
90 scoped_ptr<google_apis::AboutResource> about_resource); | 90 scoped_ptr<google_apis::AboutResource> about_resource); |
91 void FindSyncRoot(const SyncStatusCallback& callback); | 91 void FindSyncRoot(scoped_ptr<SyncTaskToken> token); |
92 void DidFindSyncRoot(const SyncStatusCallback& callback, | 92 void DidFindSyncRoot(scoped_ptr<SyncTaskToken> token, |
93 google_apis::GDataErrorCode error, | 93 google_apis::GDataErrorCode error, |
94 scoped_ptr<google_apis::ResourceList> resource_list); | 94 scoped_ptr<google_apis::ResourceList> resource_list); |
95 void CreateSyncRoot(const SyncStatusCallback& callback); | 95 void CreateSyncRoot(scoped_ptr<SyncTaskToken> token); |
96 void DidCreateSyncRoot(const SyncStatusCallback& callback, | 96 void DidCreateSyncRoot(scoped_ptr<SyncTaskToken> token, |
97 google_apis::GDataErrorCode error, | 97 google_apis::GDataErrorCode error, |
98 scoped_ptr<google_apis::ResourceEntry> entry); | 98 scoped_ptr<google_apis::ResourceEntry> entry); |
99 void DetachSyncRoot(const SyncStatusCallback& callback); | 99 void DetachSyncRoot(scoped_ptr<SyncTaskToken> token); |
100 void DidDetachSyncRoot(const SyncStatusCallback& callback, | 100 void DidDetachSyncRoot(scoped_ptr<SyncTaskToken> token, |
101 google_apis::GDataErrorCode error); | 101 google_apis::GDataErrorCode error); |
102 void ListAppRootFolders(const SyncStatusCallback& callback); | 102 void ListAppRootFolders(scoped_ptr<SyncTaskToken> token); |
103 void DidListAppRootFolders( | 103 void DidListAppRootFolders( |
104 const SyncStatusCallback& callback, | 104 scoped_ptr<SyncTaskToken> token, |
105 google_apis::GDataErrorCode error, | 105 google_apis::GDataErrorCode error, |
106 scoped_ptr<google_apis::ResourceList> resource_list); | 106 scoped_ptr<google_apis::ResourceList> resource_list); |
107 void PopulateDatabase(const SyncStatusCallback& callback); | 107 void PopulateDatabase(scoped_ptr<SyncTaskToken> token); |
108 void DidPopulateDatabase(const SyncStatusCallback& callback, | 108 void DidPopulateDatabase(scoped_ptr<SyncTaskToken> token, |
109 SyncStatusCode status); | 109 SyncStatusCode status); |
110 | 110 |
111 SyncEngineContext* sync_context_; // Not owned. | 111 SyncEngineContext* sync_context_; // Not owned. |
112 leveldb::Env* env_override_; | 112 leveldb::Env* env_override_; |
113 | 113 |
114 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 114 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
115 drive::DriveServiceInterface* drive_service_; | 115 drive::DriveServiceInterface* drive_service_; |
116 google_apis::CancelCallback cancel_callback_; | 116 google_apis::CancelCallback cancel_callback_; |
117 base::FilePath database_path_; | 117 base::FilePath database_path_; |
118 | 118 |
119 int find_sync_root_retry_count_; | 119 int find_sync_root_retry_count_; |
120 | 120 |
121 scoped_ptr<MetadataDatabase> metadata_database_; | 121 scoped_ptr<MetadataDatabase> metadata_database_; |
122 ScopedVector<google_apis::ResourceEntry> app_root_folders_; | 122 ScopedVector<google_apis::ResourceEntry> app_root_folders_; |
123 | 123 |
124 int64 largest_change_id_; | 124 int64 largest_change_id_; |
125 std::string root_folder_id_; | 125 std::string root_folder_id_; |
126 | 126 |
127 scoped_ptr<google_apis::ResourceEntry> sync_root_folder_; | 127 scoped_ptr<google_apis::ResourceEntry> sync_root_folder_; |
128 | 128 |
129 base::WeakPtrFactory<SyncEngineInitializer> weak_ptr_factory_; | 129 base::WeakPtrFactory<SyncEngineInitializer> weak_ptr_factory_; |
130 | 130 |
131 DISALLOW_COPY_AND_ASSIGN(SyncEngineInitializer); | 131 DISALLOW_COPY_AND_ASSIGN(SyncEngineInitializer); |
132 }; | 132 }; |
133 | 133 |
134 } // namespace drive_backend | 134 } // namespace drive_backend |
135 } // namespace sync_file_system | 135 } // namespace sync_file_system |
136 | 136 |
137 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_ENGINE_INITIALIZER
_H_ | 137 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_ENGINE_INITIALIZER
_H_ |
OLD | NEW |