| 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_REMOTE_TO_LOCAL_SYNCER_H_ | 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_REMOTE_TO_LOCAL_SYNCER_H_ |
| 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_REMOTE_TO_LOCAL_SYNCER_H_ | 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_REMOTE_TO_LOCAL_SYNCER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 // Else, if the tracker is a folder and it has needs_folder_listing flag: | 99 // Else, if the tracker is a folder and it has needs_folder_listing flag: |
| 100 // - Dispatch to HandleFolderContentListing() | 100 // - Dispatch to HandleFolderContentListing() |
| 101 // Else, there should be no change to sync. | 101 // Else, there should be no change to sync. |
| 102 // - Dispatch to HandleOfflineSolvable() | 102 // - Dispatch to HandleOfflineSolvable() |
| 103 void ResolveRemoteChange(scoped_ptr<SyncTaskToken> token); | 103 void ResolveRemoteChange(scoped_ptr<SyncTaskToken> token); |
| 104 | 104 |
| 105 // Handles missing remote metadata case. | 105 // Handles missing remote metadata case. |
| 106 // Fetches remote metadata and updates MetadataDatabase by that. The sync | 106 // Fetches remote metadata and updates MetadataDatabase by that. The sync |
| 107 // operation itself will be deferred to the next sync round. | 107 // operation itself will be deferred to the next sync round. |
| 108 // Note: if the file is not found, it should be handled as if deleted. | 108 // Note: if the file is not found, it should be handled as if deleted. |
| 109 void HandleMissingRemoteMetadata(const SyncStatusCallback& callback); | 109 void HandleMissingRemoteMetadata(scoped_ptr<SyncTaskToken> token); |
| 110 void DidGetRemoteMetadata(const SyncStatusCallback& callback, | 110 void DidGetRemoteMetadata(scoped_ptr<SyncTaskToken> token, |
| 111 google_apis::GDataErrorCode error, | 111 google_apis::GDataErrorCode error, |
| 112 scoped_ptr<google_apis::FileResource> entry); | 112 scoped_ptr<google_apis::FileResource> entry); |
| 113 void DidUpdateDatabaseForRemoteMetadata(const SyncStatusCallback& callback, | 113 void DidUpdateDatabaseForRemoteMetadata(scoped_ptr<SyncTaskToken> token, |
| 114 SyncStatusCode status); | 114 SyncStatusCode status); |
| 115 | 115 |
| 116 // This implements the body of the HandleNewFile and HandleContentUpdate. | 116 // This implements the body of the HandleNewFile and HandleContentUpdate. |
| 117 // If the file doesn't have corresponding local file: | 117 // If the file doesn't have corresponding local file: |
| 118 // - Dispatch to DownloadFile. | 118 // - Dispatch to DownloadFile. |
| 119 // Else, if the local file doesn't have local change: | 119 // Else, if the local file doesn't have local change: |
| 120 // - Dispatch to DownloadFile if the local file is a regular file. | 120 // - Dispatch to DownloadFile if the local file is a regular file. |
| 121 // - If the local file is a folder, handle this case as a conflict. Lower | 121 // - If the local file is a folder, handle this case as a conflict. Lower |
| 122 // the priority of the tracker, and defer further handling to | 122 // the priority of the tracker, and defer further handling to |
| 123 // local-to-remote change. | 123 // local-to-remote change. |
| 124 // Else: | 124 // Else: |
| 125 // # The file has local modification. | 125 // # The file has local modification. |
| 126 // - Handle this case as a conflict. Lower the priority of the tracker, and | 126 // - Handle this case as a conflict. Lower the priority of the tracker, and |
| 127 // defer further handling to local-to-remote change. | 127 // defer further handling to local-to-remote change. |
| 128 void DidPrepareForAddOrUpdateFile(const SyncStatusCallback& callback, | 128 void DidPrepareForAddOrUpdateFile(scoped_ptr<SyncTaskToken> token, |
| 129 SyncStatusCode status); | 129 SyncStatusCode status); |
| 130 | 130 |
| 131 // Handles remotely added folder. Needs Prepare() call. | 131 // Handles remotely added folder. Needs Prepare() call. |
| 132 // TODO(tzik): Write details and implement this. | 132 // TODO(tzik): Write details and implement this. |
| 133 void HandleFolderUpdate(const SyncStatusCallback& callback); | 133 void HandleFolderUpdate(scoped_ptr<SyncTaskToken> token); |
| 134 void DidPrepareForFolderUpdate(const SyncStatusCallback& callback, | 134 void DidPrepareForFolderUpdate(scoped_ptr<SyncTaskToken> token, |
| 135 SyncStatusCode status); | 135 SyncStatusCode status); |
| 136 | 136 |
| 137 void HandleSyncRootDeletion(const SyncStatusCallback& callback); | 137 void HandleSyncRootDeletion(scoped_ptr<SyncTaskToken> token); |
| 138 | 138 |
| 139 // Handles deleted remote file. Needs Prepare() call. | 139 // Handles deleted remote file. Needs Prepare() call. |
| 140 // If the deleted tracker is the sync-root: | 140 // If the deleted tracker is the sync-root: |
| 141 // - TODO(tzik): Needs special handling. | 141 // - TODO(tzik): Needs special handling. |
| 142 // Else, if the deleted tracker is a app-root: | 142 // Else, if the deleted tracker is a app-root: |
| 143 // - TODO(tzik): Needs special handling. | 143 // - TODO(tzik): Needs special handling. |
| 144 // Else, if the local file is already deleted: | 144 // Else, if the local file is already deleted: |
| 145 // - Do nothing anymore to the local, call SyncCompleted(). | 145 // - Do nothing anymore to the local, call SyncCompleted(). |
| 146 // Else, if the local file is modified: | 146 // Else, if the local file is modified: |
| 147 // - Do nothing to the local file, call SyncCompleted(). | 147 // - Do nothing to the local file, call SyncCompleted(). |
| 148 // Else, if the local file is not modified: | 148 // Else, if the local file is not modified: |
| 149 // - Delete local file. | 149 // - Delete local file. |
| 150 // # Note: if the local file is a folder, delete recursively. | 150 // # Note: if the local file is a folder, delete recursively. |
| 151 void HandleDeletion(const SyncStatusCallback& callback); | 151 void HandleDeletion(scoped_ptr<SyncTaskToken> token); |
| 152 void DidPrepareForDeletion(const SyncStatusCallback& callback, | 152 void DidPrepareForDeletion(scoped_ptr<SyncTaskToken> token, |
| 153 SyncStatusCode status); | 153 SyncStatusCode status); |
| 154 | 154 |
| 155 // Handles new file. Needs Prepare() call. | 155 // Handles new file. Needs Prepare() call. |
| 156 void HandleContentUpdate(const SyncStatusCallback& callback); | 156 void HandleContentUpdate(scoped_ptr<SyncTaskToken> token); |
| 157 | 157 |
| 158 void ListFolderContent(const SyncStatusCallback& callback); | 158 void ListFolderContent(scoped_ptr<SyncTaskToken> token); |
| 159 void DidListFolderContent( | 159 void DidListFolderContent( |
| 160 const SyncStatusCallback& callback, | 160 scoped_ptr<SyncTaskToken> token, |
| 161 scoped_ptr<FileIDList> children, | 161 scoped_ptr<FileIDList> children, |
| 162 google_apis::GDataErrorCode error, | 162 google_apis::GDataErrorCode error, |
| 163 scoped_ptr<google_apis::FileList> file_list); | 163 scoped_ptr<google_apis::FileList> file_list); |
| 164 | 164 |
| 165 void SyncCompleted(scoped_ptr<SyncTaskToken> token, SyncStatusCode status); | 165 void SyncCompleted(scoped_ptr<SyncTaskToken> token, SyncStatusCode status); |
| 166 void FinalizeSync(scoped_ptr<SyncTaskToken> token, SyncStatusCode status); | 166 void FinalizeSync(scoped_ptr<SyncTaskToken> token, SyncStatusCode status); |
| 167 | 167 |
| 168 void Prepare(const SyncStatusCallback& callback); | 168 void Prepare(const SyncStatusCallback& callback); |
| 169 void DidPrepare(const SyncStatusCallback& callback, | 169 void DidPrepare(const SyncStatusCallback& callback, |
| 170 SyncStatusCode status, | 170 SyncStatusCode status, |
| 171 const SyncFileMetadata& metadata, | 171 const SyncFileMetadata& metadata, |
| 172 const FileChangeList& changes); | 172 const FileChangeList& changes); |
| 173 | 173 |
| 174 void DeleteLocalFile(const SyncStatusCallback& callback); | 174 void DeleteLocalFile(scoped_ptr<SyncTaskToken> token); |
| 175 void DownloadFile(const SyncStatusCallback& callback); | 175 void DownloadFile(scoped_ptr<SyncTaskToken> token); |
| 176 void DidDownloadFile(const SyncStatusCallback& callback, | 176 void DidDownloadFile(scoped_ptr<SyncTaskToken> token, |
| 177 webkit_blob::ScopedFile file, | 177 webkit_blob::ScopedFile file, |
| 178 google_apis::GDataErrorCode error, | 178 google_apis::GDataErrorCode error, |
| 179 const base::FilePath&); | 179 const base::FilePath&); |
| 180 void DidApplyDownload(const SyncStatusCallback& callback, | 180 void DidApplyDownload(scoped_ptr<SyncTaskToken> token, |
| 181 webkit_blob::ScopedFile, | 181 webkit_blob::ScopedFile, |
| 182 SyncStatusCode status); | 182 SyncStatusCode status); |
| 183 | 183 |
| 184 void CreateFolder(const SyncStatusCallback& callback); | 184 void CreateFolder(scoped_ptr<SyncTaskToken> token); |
| 185 | 185 |
| 186 // TODO(tzik): After we convert all callbacks to token-passing style, | 186 // TODO(tzik): After we convert all callbacks to token-passing style, |
| 187 // drop this function. | 187 // drop this function. |
| 188 SyncStatusCallback SyncCompletedCallback(scoped_ptr<SyncTaskToken> token); | 188 SyncStatusCallback SyncCompletedCallback(scoped_ptr<SyncTaskToken> token); |
| 189 | 189 |
| 190 drive::DriveServiceInterface* drive_service(); | 190 drive::DriveServiceInterface* drive_service(); |
| 191 MetadataDatabase* metadata_database(); | 191 MetadataDatabase* metadata_database(); |
| 192 RemoteChangeProcessor* remote_change_processor(); | 192 RemoteChangeProcessor* remote_change_processor(); |
| 193 | 193 |
| 194 SyncEngineContext* sync_context_; // Not owned. | 194 SyncEngineContext* sync_context_; // Not owned. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 207 | 207 |
| 208 base::WeakPtrFactory<RemoteToLocalSyncer> weak_ptr_factory_; | 208 base::WeakPtrFactory<RemoteToLocalSyncer> weak_ptr_factory_; |
| 209 | 209 |
| 210 DISALLOW_COPY_AND_ASSIGN(RemoteToLocalSyncer); | 210 DISALLOW_COPY_AND_ASSIGN(RemoteToLocalSyncer); |
| 211 }; | 211 }; |
| 212 | 212 |
| 213 } // namespace drive_backend | 213 } // namespace drive_backend |
| 214 } // namespace sync_file_system | 214 } // namespace sync_file_system |
| 215 | 215 |
| 216 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_REMOTE_TO_LOCAL_SYNCER_
H_ | 216 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_REMOTE_TO_LOCAL_SYNCER_
H_ |
| OLD | NEW |