| 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 |
| 11 #include "base/memory/scoped_vector.h" | 11 #include "base/memory/scoped_vector.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.pb.h" | 13 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.pb.h" |
| 14 #include "chrome/browser/sync_file_system/drive_backend/sync_task.h" | 14 #include "chrome/browser/sync_file_system/drive_backend/sync_task.h" |
| 15 #include "chrome/browser/sync_file_system/drive_backend/sync_task_manager.h" |
| 15 #include "chrome/browser/sync_file_system/remote_change_processor.h" | 16 #include "chrome/browser/sync_file_system/remote_change_processor.h" |
| 16 #include "chrome/browser/sync_file_system/sync_action.h" | 17 #include "chrome/browser/sync_file_system/sync_action.h" |
| 17 #include "chrome/browser/sync_file_system/sync_callbacks.h" | 18 #include "chrome/browser/sync_file_system/sync_callbacks.h" |
| 18 #include "chrome/browser/sync_file_system/sync_file_metadata.h" | 19 #include "chrome/browser/sync_file_system/sync_file_metadata.h" |
| 19 #include "google_apis/drive/gdata_errorcode.h" | 20 #include "google_apis/drive/gdata_errorcode.h" |
| 20 #include "storage/browser/fileapi/file_system_url.h" | 21 #include "storage/browser/fileapi/file_system_url.h" |
| 21 | 22 |
| 22 namespace drive { | 23 namespace drive { |
| 23 class DriveServiceInterface; | 24 class DriveServiceInterface; |
| 24 } | 25 } |
| 25 | 26 |
| 26 namespace google_apis { | 27 namespace google_apis { |
| 27 class FileList; | 28 class FileList; |
| 28 class FileResource; | 29 class FileResource; |
| 29 class ResourceEntry; | 30 class ResourceEntry; |
| 30 } | 31 } |
| 31 | 32 |
| 32 namespace storage { | 33 namespace storage { |
| 33 class ScopedFile; | 34 class ScopedFile; |
| 34 } | 35 } |
| 35 | 36 |
| 36 namespace sync_file_system { | 37 namespace sync_file_system { |
| 37 namespace drive_backend { | 38 namespace drive_backend { |
| 38 | 39 |
| 39 class MetadataDatabase; | 40 class MetadataDatabase; |
| 40 class SyncEngineContext; | 41 class SyncEngineContext; |
| 41 | 42 |
| 42 class RemoteToLocalSyncer : public SyncTask { | 43 class RemoteToLocalSyncer : public SyncTask { |
| 43 public: | 44 public: |
| 45 typedef SyncTaskManager::Continuation Continuation; |
| 46 |
| 44 // Conflicting trackers will have low priority for RemoteToLocalSyncer so that | 47 // Conflicting trackers will have low priority for RemoteToLocalSyncer so that |
| 45 // it should be resolved by LocatToRemoteSyncer. | 48 // it should be resolved by LocatToRemoteSyncer. |
| 46 explicit RemoteToLocalSyncer(SyncEngineContext* sync_context); | 49 explicit RemoteToLocalSyncer(SyncEngineContext* sync_context); |
| 47 virtual ~RemoteToLocalSyncer(); | 50 virtual ~RemoteToLocalSyncer(); |
| 48 | 51 |
| 49 virtual void RunPreflight(scoped_ptr<SyncTaskToken> token) OVERRIDE; | 52 virtual void RunPreflight(scoped_ptr<SyncTaskToken> token) OVERRIDE; |
| 50 void RunExclusive(scoped_ptr<SyncTaskToken> token); | 53 void RunExclusive(scoped_ptr<SyncTaskToken> token); |
| 51 | 54 |
| 52 const storage::FileSystemURL& url() const { return url_; } | 55 const storage::FileSystemURL& url() const { return url_; } |
| 53 SyncAction sync_action() const { return sync_action_; } | 56 SyncAction sync_action() const { return sync_action_; } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 // Else, if the folder is a regular file and the md5 in remote metadata does | 98 // Else, if the folder is a regular file and the md5 in remote metadata does |
| 96 // not match the md5 in synced metadata: | 99 // not match the md5 in synced metadata: |
| 97 // # The file is modified remotely. | 100 // # The file is modified remotely. |
| 98 // - Dispatch to HandleContentUpdate(). | 101 // - Dispatch to HandleContentUpdate(). |
| 99 // Else, if the tracker is a folder and it has needs_folder_listing flag: | 102 // Else, if the tracker is a folder and it has needs_folder_listing flag: |
| 100 // - Dispatch to HandleFolderContentListing() | 103 // - Dispatch to HandleFolderContentListing() |
| 101 // Else, there should be no change to sync. | 104 // Else, there should be no change to sync. |
| 102 // - Dispatch to HandleOfflineSolvable() | 105 // - Dispatch to HandleOfflineSolvable() |
| 103 void ResolveRemoteChange(scoped_ptr<SyncTaskToken> token); | 106 void ResolveRemoteChange(scoped_ptr<SyncTaskToken> token); |
| 104 | 107 |
| 108 void MoveToBackground(scoped_ptr<SyncTaskToken> token, |
| 109 const Continuation& continuation); |
| 110 void ContinueAsBackgroundTask(const Continuation& continuation, |
| 111 scoped_ptr<SyncTaskToken> token); |
| 112 |
| 105 // Handles missing remote metadata case. | 113 // Handles missing remote metadata case. |
| 106 // Fetches remote metadata and updates MetadataDatabase by that. The sync | 114 // Fetches remote metadata and updates MetadataDatabase by that. The sync |
| 107 // operation itself will be deferred to the next sync round. | 115 // 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. | 116 // Note: if the file is not found, it should be handled as if deleted. |
| 109 void HandleMissingRemoteMetadata(scoped_ptr<SyncTaskToken> token); | 117 void HandleMissingRemoteMetadata(scoped_ptr<SyncTaskToken> token); |
| 110 void DidGetRemoteMetadata(scoped_ptr<SyncTaskToken> token, | 118 void DidGetRemoteMetadata(scoped_ptr<SyncTaskToken> token, |
| 111 google_apis::GDataErrorCode error, | 119 google_apis::GDataErrorCode error, |
| 112 scoped_ptr<google_apis::FileResource> entry); | 120 scoped_ptr<google_apis::FileResource> entry); |
| 113 | 121 |
| 114 // This implements the body of the HandleNewFile and HandleContentUpdate. | 122 // This implements the body of the HandleNewFile and HandleContentUpdate. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 125 // defer further handling to local-to-remote change. | 133 // defer further handling to local-to-remote change. |
| 126 void DidPrepareForAddOrUpdateFile(scoped_ptr<SyncTaskToken> token, | 134 void DidPrepareForAddOrUpdateFile(scoped_ptr<SyncTaskToken> token, |
| 127 SyncStatusCode status); | 135 SyncStatusCode status); |
| 128 | 136 |
| 129 // Handles remotely added folder. Needs Prepare() call. | 137 // Handles remotely added folder. Needs Prepare() call. |
| 130 // TODO(tzik): Write details and implement this. | 138 // TODO(tzik): Write details and implement this. |
| 131 void HandleFolderUpdate(scoped_ptr<SyncTaskToken> token); | 139 void HandleFolderUpdate(scoped_ptr<SyncTaskToken> token); |
| 132 void DidPrepareForFolderUpdate(scoped_ptr<SyncTaskToken> token, | 140 void DidPrepareForFolderUpdate(scoped_ptr<SyncTaskToken> token, |
| 133 SyncStatusCode status); | 141 SyncStatusCode status); |
| 134 | 142 |
| 135 void HandleSyncRootDeletion(scoped_ptr<SyncTaskToken> token); | |
| 136 | |
| 137 // Handles deleted remote file. Needs Prepare() call. | 143 // Handles deleted remote file. Needs Prepare() call. |
| 138 // If the deleted tracker is the sync-root: | 144 // If the deleted tracker is the sync-root: |
| 139 // - TODO(tzik): Needs special handling. | 145 // - TODO(tzik): Needs special handling. |
| 140 // Else, if the deleted tracker is a app-root: | 146 // Else, if the deleted tracker is a app-root: |
| 141 // - TODO(tzik): Needs special handling. | 147 // - TODO(tzik): Needs special handling. |
| 142 // Else, if the local file is already deleted: | 148 // Else, if the local file is already deleted: |
| 143 // - Do nothing anymore to the local, call SyncCompleted(). | 149 // - Do nothing anymore to the local, call SyncCompleted(). |
| 144 // Else, if the local file is modified: | 150 // Else, if the local file is modified: |
| 145 // - Do nothing to the local file, call SyncCompleted(). | 151 // - Do nothing to the local file, call SyncCompleted(). |
| 146 // Else, if the local file is not modified: | 152 // Else, if the local file is not modified: |
| 147 // - Delete local file. | 153 // - Delete local file. |
| 148 // # Note: if the local file is a folder, delete recursively. | 154 // # Note: if the local file is a folder, delete recursively. |
| 149 void HandleDeletion(scoped_ptr<SyncTaskToken> token); | 155 void HandleDeletion(scoped_ptr<SyncTaskToken> token); |
| 150 void DidPrepareForDeletion(scoped_ptr<SyncTaskToken> token, | 156 void DidPrepareForDeletion(scoped_ptr<SyncTaskToken> token, |
| 151 SyncStatusCode status); | 157 SyncStatusCode status); |
| 152 | 158 |
| 159 void HandleFileMove(scoped_ptr<SyncTaskToken> token); |
| 160 |
| 153 // Handles new file. Needs Prepare() call. | 161 // Handles new file. Needs Prepare() call. |
| 154 void HandleContentUpdate(scoped_ptr<SyncTaskToken> token); | 162 void HandleContentUpdate(scoped_ptr<SyncTaskToken> token); |
| 155 | 163 |
| 156 void ListFolderContent(scoped_ptr<SyncTaskToken> token); | 164 void ListFolderContent(scoped_ptr<SyncTaskToken> token); |
| 157 void DidListFolderContent( | 165 void DidListFolderContent( |
| 158 scoped_ptr<SyncTaskToken> token, | 166 scoped_ptr<SyncTaskToken> token, |
| 159 scoped_ptr<FileIDList> children, | 167 scoped_ptr<FileIDList> children, |
| 160 google_apis::GDataErrorCode error, | 168 google_apis::GDataErrorCode error, |
| 161 scoped_ptr<google_apis::FileList> file_list); | 169 scoped_ptr<google_apis::FileList> file_list); |
| 162 | 170 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 | 213 |
| 206 base::WeakPtrFactory<RemoteToLocalSyncer> weak_ptr_factory_; | 214 base::WeakPtrFactory<RemoteToLocalSyncer> weak_ptr_factory_; |
| 207 | 215 |
| 208 DISALLOW_COPY_AND_ASSIGN(RemoteToLocalSyncer); | 216 DISALLOW_COPY_AND_ASSIGN(RemoteToLocalSyncer); |
| 209 }; | 217 }; |
| 210 | 218 |
| 211 } // namespace drive_backend | 219 } // namespace drive_backend |
| 212 } // namespace sync_file_system | 220 } // namespace sync_file_system |
| 213 | 221 |
| 214 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_REMOTE_TO_LOCAL_SYNCER_
H_ | 222 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_REMOTE_TO_LOCAL_SYNCER_
H_ |
| OLD | NEW |