| 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_V1_REMOTE_SYNC_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_V1_REMOTE_SYNC_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_V1_REMOTE_SYNC_DELEGATE_H_ | 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_V1_REMOTE_SYNC_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "chrome/browser/sync_file_system/drive_backend_v1/api_util.h" | 12 #include "chrome/browser/sync_file_system/drive_backend_v1/api_util.h" |
| 13 #include "chrome/browser/sync_file_system/drive_backend_v1/drive_file_sync_servi
ce.h" | 13 #include "chrome/browser/sync_file_system/drive_backend_v1/drive_file_sync_servi
ce.h" |
| 14 #include "chrome/browser/sync_file_system/drive_backend_v1/drive_metadata_store.
h" | 14 #include "chrome/browser/sync_file_system/drive_backend_v1/drive_metadata_store.
h" |
| 15 #include "chrome/browser/sync_file_system/file_change.h" | 15 #include "chrome/browser/sync_file_system/file_change.h" |
| 16 #include "chrome/browser/sync_file_system/sync_action.h" | 16 #include "chrome/browser/sync_file_system/sync_action.h" |
| 17 #include "chrome/browser/sync_file_system/sync_callbacks.h" | 17 #include "chrome/browser/sync_file_system/sync_callbacks.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 "chrome/browser/sync_file_system/sync_file_system.pb.h" | 19 #include "chrome/browser/sync_file_system/sync_file_system.pb.h" |
| 20 #include "webkit/browser/fileapi/file_system_url.h" | 20 #include "storage/browser/fileapi/file_system_url.h" |
| 21 #include "webkit/common/blob/scoped_file.h" | 21 #include "storage/common/blob/scoped_file.h" |
| 22 | 22 |
| 23 namespace sync_file_system { | 23 namespace sync_file_system { |
| 24 | 24 |
| 25 class DriveMetadataStore; | 25 class DriveMetadataStore; |
| 26 class RemoteChangeProcessor; | 26 class RemoteChangeProcessor; |
| 27 | 27 |
| 28 namespace drive_backend { | 28 namespace drive_backend { |
| 29 | 29 |
| 30 class APIUtil; | 30 class APIUtil; |
| 31 | 31 |
| 32 // This class handles RemoteFileSyncService::ProcessRemoteChange for drive | 32 // This class handles RemoteFileSyncService::ProcessRemoteChange for drive |
| 33 // backend, and its instance represents single ProcessRemoteChange operation. | 33 // backend, and its instance represents single ProcessRemoteChange operation. |
| 34 // The caller is responsible to own the instance, and can cancel operation by | 34 // The caller is responsible to own the instance, and can cancel operation by |
| 35 // deleting the instance. | 35 // deleting the instance. |
| 36 class RemoteSyncDelegate : public base::SupportsWeakPtr<RemoteSyncDelegate> { | 36 class RemoteSyncDelegate : public base::SupportsWeakPtr<RemoteSyncDelegate> { |
| 37 public: | 37 public: |
| 38 typedef RemoteChangeHandler::RemoteChange RemoteChange; | 38 typedef RemoteChangeHandler::RemoteChange RemoteChange; |
| 39 | 39 |
| 40 RemoteSyncDelegate( | 40 RemoteSyncDelegate( |
| 41 DriveFileSyncService* sync_service, | 41 DriveFileSyncService* sync_service, |
| 42 const RemoteChange& remote_change); | 42 const RemoteChange& remote_change); |
| 43 virtual ~RemoteSyncDelegate(); | 43 virtual ~RemoteSyncDelegate(); |
| 44 | 44 |
| 45 void Run(const SyncStatusCallback& callback); | 45 void Run(const SyncStatusCallback& callback); |
| 46 | 46 |
| 47 const fileapi::FileSystemURL& url() const { return remote_change_.url; } | 47 const storage::FileSystemURL& url() const { return remote_change_.url; } |
| 48 | 48 |
| 49 private: | 49 private: |
| 50 void DidPrepareForProcessRemoteChange(const SyncStatusCallback& callback, | 50 void DidPrepareForProcessRemoteChange(const SyncStatusCallback& callback, |
| 51 SyncStatusCode status, | 51 SyncStatusCode status, |
| 52 const SyncFileMetadata& metadata, | 52 const SyncFileMetadata& metadata, |
| 53 const FileChangeList& local_changes); | 53 const FileChangeList& local_changes); |
| 54 void ApplyRemoteChange(const SyncStatusCallback& callback); | 54 void ApplyRemoteChange(const SyncStatusCallback& callback); |
| 55 void DidApplyRemoteChange(const SyncStatusCallback& callback, | 55 void DidApplyRemoteChange(const SyncStatusCallback& callback, |
| 56 SyncStatusCode status); | 56 SyncStatusCode status); |
| 57 void DeleteMetadata(const SyncStatusCallback& callback); | 57 void DeleteMetadata(const SyncStatusCallback& callback); |
| 58 void DownloadFile(const SyncStatusCallback& callback); | 58 void DownloadFile(const SyncStatusCallback& callback); |
| 59 void DidDownloadFile(const SyncStatusCallback& callback, | 59 void DidDownloadFile(const SyncStatusCallback& callback, |
| 60 google_apis::GDataErrorCode error, | 60 google_apis::GDataErrorCode error, |
| 61 const std::string& md5_checksum, | 61 const std::string& md5_checksum, |
| 62 int64 file_size, | 62 int64 file_size, |
| 63 const base::Time& updated_time, | 63 const base::Time& updated_time, |
| 64 webkit_blob::ScopedFile downloaded_file); | 64 storage::ScopedFile downloaded_file); |
| 65 void HandleConflict(const SyncStatusCallback& callback, | 65 void HandleConflict(const SyncStatusCallback& callback, |
| 66 SyncFileType remote_file_type); | 66 SyncFileType remote_file_type); |
| 67 void HandleLocalWin(const SyncStatusCallback& callback); | 67 void HandleLocalWin(const SyncStatusCallback& callback); |
| 68 void HandleRemoteWin(const SyncStatusCallback& callback, | 68 void HandleRemoteWin(const SyncStatusCallback& callback, |
| 69 SyncFileType remote_file_type); | 69 SyncFileType remote_file_type); |
| 70 void HandleManualResolutionCase(const SyncStatusCallback& callback); | 70 void HandleManualResolutionCase(const SyncStatusCallback& callback); |
| 71 void DidGetEntryForConflictResolution( | 71 void DidGetEntryForConflictResolution( |
| 72 const SyncStatusCallback& callback, | 72 const SyncStatusCallback& callback, |
| 73 google_apis::GDataErrorCode error, | 73 google_apis::GDataErrorCode error, |
| 74 scoped_ptr<google_apis::ResourceEntry> entry); | 74 scoped_ptr<google_apis::ResourceEntry> entry); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 99 RemoteChangeProcessor* remote_change_processor(); | 99 RemoteChangeProcessor* remote_change_processor(); |
| 100 ConflictResolutionResolver* conflict_resolution_resolver(); | 100 ConflictResolutionResolver* conflict_resolution_resolver(); |
| 101 | 101 |
| 102 const FileChange& remote_file_change() const { return remote_change_.change; } | 102 const FileChange& remote_file_change() const { return remote_change_.change; } |
| 103 | 103 |
| 104 DriveFileSyncService* sync_service_; // Not owned. | 104 DriveFileSyncService* sync_service_; // Not owned. |
| 105 | 105 |
| 106 RemoteChange remote_change_; | 106 RemoteChange remote_change_; |
| 107 DriveMetadata drive_metadata_; | 107 DriveMetadata drive_metadata_; |
| 108 SyncFileMetadata local_metadata_; | 108 SyncFileMetadata local_metadata_; |
| 109 webkit_blob::ScopedFile temporary_file_; | 109 storage::ScopedFile temporary_file_; |
| 110 std::string md5_checksum_; | 110 std::string md5_checksum_; |
| 111 SyncAction sync_action_; | 111 SyncAction sync_action_; |
| 112 bool metadata_updated_; | 112 bool metadata_updated_; |
| 113 bool clear_local_changes_; | 113 bool clear_local_changes_; |
| 114 | 114 |
| 115 std::string origin_resource_id_; | 115 std::string origin_resource_id_; |
| 116 | 116 |
| 117 DISALLOW_COPY_AND_ASSIGN(RemoteSyncDelegate); | 117 DISALLOW_COPY_AND_ASSIGN(RemoteSyncDelegate); |
| 118 }; | 118 }; |
| 119 | 119 |
| 120 } // namespace drive_backend | 120 } // namespace drive_backend |
| 121 | 121 |
| 122 } // namespace sync_file_system | 122 } // namespace sync_file_system |
| 123 | 123 |
| 124 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_V1_REMOTE_SYNC_DELEGATE
_H_ | 124 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_V1_REMOTE_SYNC_DELEGATE
_H_ |
| OLD | NEW |