| 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_LOCAL_TO_REMOTE_SYNCER_H_ | 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_LOCAL_TO_REMOTE_SYNCER_H_ |
| 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_LOCAL_TO_REMOTE_SYNCER_H_ | 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_LOCAL_TO_REMOTE_SYNCER_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/scoped_ptr.h" | |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "chrome/browser/sync_file_system/drive_backend/sync_task.h" | 15 #include "chrome/browser/sync_file_system/drive_backend/sync_task.h" |
| 16 #include "chrome/browser/sync_file_system/file_change.h" | 16 #include "chrome/browser/sync_file_system/file_change.h" |
| 17 #include "chrome/browser/sync_file_system/sync_action.h" | 17 #include "chrome/browser/sync_file_system/sync_action.h" |
| 18 #include "chrome/browser/sync_file_system/sync_file_metadata.h" | 18 #include "chrome/browser/sync_file_system/sync_file_metadata.h" |
| 19 #include "google_apis/drive/drive_api_error_codes.h" | 19 #include "google_apis/drive/drive_api_error_codes.h" |
| 20 | 20 |
| 21 namespace drive { | 21 namespace drive { |
| 22 class DriveServiceInterface; | 22 class DriveServiceInterface; |
| 23 class DriveUploaderInterface; | 23 class DriveUploaderInterface; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 34 namespace drive_backend { | 34 namespace drive_backend { |
| 35 | 35 |
| 36 class FileDetails; | 36 class FileDetails; |
| 37 class FileTracker; | 37 class FileTracker; |
| 38 class FolderCreator; | 38 class FolderCreator; |
| 39 class MetadataDatabase; | 39 class MetadataDatabase; |
| 40 class SyncEngineContext; | 40 class SyncEngineContext; |
| 41 | 41 |
| 42 class LocalToRemoteSyncer : public SyncTask { | 42 class LocalToRemoteSyncer : public SyncTask { |
| 43 public: | 43 public: |
| 44 typedef base::Callback<void(scoped_ptr<SyncTaskToken>)> Continuation; | 44 typedef base::Callback<void(std::unique_ptr<SyncTaskToken>)> Continuation; |
| 45 | 45 |
| 46 LocalToRemoteSyncer(SyncEngineContext* sync_context, | 46 LocalToRemoteSyncer(SyncEngineContext* sync_context, |
| 47 const SyncFileMetadata& local_metadata, | 47 const SyncFileMetadata& local_metadata, |
| 48 const FileChange& local_change, | 48 const FileChange& local_change, |
| 49 const base::FilePath& local_path, | 49 const base::FilePath& local_path, |
| 50 const storage::FileSystemURL& url); | 50 const storage::FileSystemURL& url); |
| 51 ~LocalToRemoteSyncer() override; | 51 ~LocalToRemoteSyncer() override; |
| 52 void RunPreflight(scoped_ptr<SyncTaskToken> token) override; | 52 void RunPreflight(std::unique_ptr<SyncTaskToken> token) override; |
| 53 | 53 |
| 54 const storage::FileSystemURL& url() const { return url_; } | 54 const storage::FileSystemURL& url() const { return url_; } |
| 55 const base::FilePath& target_path() const { return target_path_; } | 55 const base::FilePath& target_path() const { return target_path_; } |
| 56 SyncFileType file_type() const { return file_type_; } | 56 SyncFileType file_type() const { return file_type_; } |
| 57 SyncAction sync_action() const { return sync_action_; } | 57 SyncAction sync_action() const { return sync_action_; } |
| 58 bool needs_remote_change_listing() const { | 58 bool needs_remote_change_listing() const { |
| 59 return needs_remote_change_listing_; | 59 return needs_remote_change_listing_; |
| 60 } | 60 } |
| 61 | 61 |
| 62 private: | 62 private: |
| 63 void MoveToBackground(const Continuation& continuation, | 63 void MoveToBackground(const Continuation& continuation, |
| 64 scoped_ptr<SyncTaskToken> token); | 64 std::unique_ptr<SyncTaskToken> token); |
| 65 void ContinueAsBackgroundTask(const Continuation& continuation, | 65 void ContinueAsBackgroundTask(const Continuation& continuation, |
| 66 scoped_ptr<SyncTaskToken> token); | 66 std::unique_ptr<SyncTaskToken> token); |
| 67 void SyncCompleted(scoped_ptr<SyncTaskToken> token, | 67 void SyncCompleted(std::unique_ptr<SyncTaskToken> token, |
| 68 SyncStatusCode status); | 68 SyncStatusCode status); |
| 69 | 69 |
| 70 void HandleConflict(scoped_ptr<SyncTaskToken> token); | 70 void HandleConflict(std::unique_ptr<SyncTaskToken> token); |
| 71 void HandleExistingRemoteFile(scoped_ptr<SyncTaskToken> token); | 71 void HandleExistingRemoteFile(std::unique_ptr<SyncTaskToken> token); |
| 72 | 72 |
| 73 void UpdateTrackerForReusedFolder(const FileDetails& details, | 73 void UpdateTrackerForReusedFolder(const FileDetails& details, |
| 74 scoped_ptr<SyncTaskToken> token); | 74 std::unique_ptr<SyncTaskToken> token); |
| 75 | 75 |
| 76 void DeleteRemoteFile(scoped_ptr<SyncTaskToken> token); | 76 void DeleteRemoteFile(std::unique_ptr<SyncTaskToken> token); |
| 77 void DidDeleteRemoteFile(scoped_ptr<SyncTaskToken> token, | 77 void DidDeleteRemoteFile(std::unique_ptr<SyncTaskToken> token, |
| 78 google_apis::DriveApiErrorCode error); | 78 google_apis::DriveApiErrorCode error); |
| 79 | 79 |
| 80 void UploadExistingFile(scoped_ptr<SyncTaskToken> token); | 80 void UploadExistingFile(std::unique_ptr<SyncTaskToken> token); |
| 81 void DidUploadExistingFile(scoped_ptr<SyncTaskToken> token, | 81 void DidUploadExistingFile(std::unique_ptr<SyncTaskToken> token, |
| 82 google_apis::DriveApiErrorCode error, | 82 google_apis::DriveApiErrorCode error, |
| 83 const GURL&, | 83 const GURL&, |
| 84 scoped_ptr<google_apis::FileResource>); | 84 std::unique_ptr<google_apis::FileResource>); |
| 85 void UpdateRemoteMetadata(const std::string& file_id, | 85 void UpdateRemoteMetadata(const std::string& file_id, |
| 86 scoped_ptr<SyncTaskToken> token); | 86 std::unique_ptr<SyncTaskToken> token); |
| 87 void DidGetRemoteMetadata(const std::string& file_id, | 87 void DidGetRemoteMetadata(const std::string& file_id, |
| 88 scoped_ptr<SyncTaskToken> token, | 88 std::unique_ptr<SyncTaskToken> token, |
| 89 google_apis::DriveApiErrorCode error, | 89 google_apis::DriveApiErrorCode error, |
| 90 scoped_ptr<google_apis::FileResource> entry); | 90 std::unique_ptr<google_apis::FileResource> entry); |
| 91 | 91 |
| 92 void UploadNewFile(scoped_ptr<SyncTaskToken> token); | 92 void UploadNewFile(std::unique_ptr<SyncTaskToken> token); |
| 93 void DidUploadNewFile(scoped_ptr<SyncTaskToken> token, | 93 void DidUploadNewFile(std::unique_ptr<SyncTaskToken> token, |
| 94 google_apis::DriveApiErrorCode error, | 94 google_apis::DriveApiErrorCode error, |
| 95 const GURL& upload_location, | 95 const GURL& upload_location, |
| 96 scoped_ptr<google_apis::FileResource> entry); | 96 std::unique_ptr<google_apis::FileResource> entry); |
| 97 | 97 |
| 98 void CreateRemoteFolder(scoped_ptr<SyncTaskToken> token); | 98 void CreateRemoteFolder(std::unique_ptr<SyncTaskToken> token); |
| 99 void DidCreateRemoteFolder(scoped_ptr<SyncTaskToken> token, | 99 void DidCreateRemoteFolder(std::unique_ptr<SyncTaskToken> token, |
| 100 const std::string& file_id, | 100 const std::string& file_id, |
| 101 SyncStatusCode status); | 101 SyncStatusCode status); |
| 102 void DidDetachResourceForCreationConflict( | 102 void DidDetachResourceForCreationConflict( |
| 103 scoped_ptr<SyncTaskToken> token, | 103 std::unique_ptr<SyncTaskToken> token, |
| 104 google_apis::DriveApiErrorCode error); | 104 google_apis::DriveApiErrorCode error); |
| 105 | 105 |
| 106 bool IsContextReady(); | 106 bool IsContextReady(); |
| 107 drive::DriveServiceInterface* drive_service(); | 107 drive::DriveServiceInterface* drive_service(); |
| 108 drive::DriveUploaderInterface* drive_uploader(); | 108 drive::DriveUploaderInterface* drive_uploader(); |
| 109 MetadataDatabase* metadata_database(); | 109 MetadataDatabase* metadata_database(); |
| 110 | 110 |
| 111 SyncEngineContext* sync_context_; // Not owned. | 111 SyncEngineContext* sync_context_; // Not owned. |
| 112 | 112 |
| 113 FileChange local_change_; | 113 FileChange local_change_; |
| 114 bool local_is_missing_; | 114 bool local_is_missing_; |
| 115 base::FilePath local_path_; | 115 base::FilePath local_path_; |
| 116 storage::FileSystemURL url_; | 116 storage::FileSystemURL url_; |
| 117 SyncFileType file_type_; | 117 SyncFileType file_type_; |
| 118 SyncAction sync_action_; | 118 SyncAction sync_action_; |
| 119 | 119 |
| 120 scoped_ptr<FileTracker> remote_file_tracker_; | 120 std::unique_ptr<FileTracker> remote_file_tracker_; |
| 121 scoped_ptr<FileTracker> remote_parent_folder_tracker_; | 121 std::unique_ptr<FileTracker> remote_parent_folder_tracker_; |
| 122 base::FilePath target_path_; | 122 base::FilePath target_path_; |
| 123 int64_t remote_file_change_id_; | 123 int64_t remote_file_change_id_; |
| 124 | 124 |
| 125 bool retry_on_success_; | 125 bool retry_on_success_; |
| 126 bool needs_remote_change_listing_; | 126 bool needs_remote_change_listing_; |
| 127 | 127 |
| 128 scoped_ptr<FolderCreator> folder_creator_; | 128 std::unique_ptr<FolderCreator> folder_creator_; |
| 129 | 129 |
| 130 base::WeakPtrFactory<LocalToRemoteSyncer> weak_ptr_factory_; | 130 base::WeakPtrFactory<LocalToRemoteSyncer> weak_ptr_factory_; |
| 131 | 131 |
| 132 DISALLOW_COPY_AND_ASSIGN(LocalToRemoteSyncer); | 132 DISALLOW_COPY_AND_ASSIGN(LocalToRemoteSyncer); |
| 133 }; | 133 }; |
| 134 | 134 |
| 135 } // namespace drive_backend | 135 } // namespace drive_backend |
| 136 } // namespace sync_file_system | 136 } // namespace sync_file_system |
| 137 | 137 |
| 138 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_LOCAL_TO_REMOTE_SYNCER_
H_ | 138 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_LOCAL_TO_REMOTE_SYNCER_
H_ |
| OLD | NEW |