Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / chrome / browser / sync_file_system / drive_backend_v1 / remote_sync_delegate.h
blob51f4e3bb02c33f71faf6b67f8878846f56f52e9d
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
3 // found in the LICENSE file.
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_
8 #include <string>
10 #include "base/callback.h"
11 #include "base/memory/weak_ptr.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_service.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"
16 #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_file_metadata.h"
19 #include "chrome/browser/sync_file_system/sync_file_system.pb.h"
20 #include "webkit/browser/fileapi/file_system_url.h"
21 #include "webkit/common/blob/scoped_file.h"
23 namespace sync_file_system {
25 class DriveMetadataStore;
26 class RemoteChangeProcessor;
28 namespace drive_backend {
30 class APIUtil;
32 // This class handles RemoteFileSyncService::ProcessRemoteChange for drive
33 // backend, and its instance represents single ProcessRemoteChange operation.
34 // The caller is responsible to own the instance, and can cancel operation by
35 // deleting the instance.
36 class RemoteSyncDelegate : public base::SupportsWeakPtr<RemoteSyncDelegate> {
37 public:
38 typedef RemoteChangeHandler::RemoteChange RemoteChange;
40 RemoteSyncDelegate(
41 DriveFileSyncService* sync_service,
42 const RemoteChange& remote_change);
43 virtual ~RemoteSyncDelegate();
45 void Run(const SyncStatusCallback& callback);
47 const fileapi::FileSystemURL& url() const { return remote_change_.url; }
49 private:
50 void DidPrepareForProcessRemoteChange(const SyncStatusCallback& callback,
51 SyncStatusCode status,
52 const SyncFileMetadata& metadata,
53 const FileChangeList& local_changes);
54 void ApplyRemoteChange(const SyncStatusCallback& callback);
55 void DidApplyRemoteChange(const SyncStatusCallback& callback,
56 SyncStatusCode status);
57 void DeleteMetadata(const SyncStatusCallback& callback);
58 void DownloadFile(const SyncStatusCallback& callback);
59 void DidDownloadFile(const SyncStatusCallback& callback,
60 google_apis::GDataErrorCode error,
61 const std::string& md5_checksum,
62 int64 file_size,
63 const base::Time& updated_time,
64 webkit_blob::ScopedFile downloaded_file);
65 void HandleConflict(const SyncStatusCallback& callback,
66 SyncFileType remote_file_type);
67 void HandleLocalWin(const SyncStatusCallback& callback);
68 void HandleRemoteWin(const SyncStatusCallback& callback,
69 SyncFileType remote_file_type);
70 void HandleManualResolutionCase(const SyncStatusCallback& callback);
71 void DidGetEntryForConflictResolution(
72 const SyncStatusCallback& callback,
73 google_apis::GDataErrorCode error,
74 scoped_ptr<google_apis::ResourceEntry> entry);
75 void ResolveToLocal(const SyncStatusCallback& callback);
76 void DidResolveToLocal(const SyncStatusCallback& callback,
77 SyncStatusCode status);
78 void ResolveToRemote(const SyncStatusCallback& callback);
79 void DidResolveToRemote(const SyncStatusCallback& callback,
80 SyncStatusCode status);
81 void StartOver(const SyncStatusCallback& callback,
82 SyncStatusCode status);
84 void CompleteSync(const SyncStatusCallback& callback,
85 SyncStatusCode status);
86 void AbortSync(const SyncStatusCallback& callback,
87 SyncStatusCode status);
88 void DidFinish(const SyncStatusCallback& callback,
89 SyncStatusCode status);
90 void DispatchCallbackAfterDidFinish(const SyncStatusCallback& callback,
91 SyncStatusCode status);
93 SyncStatusCode GDataErrorCodeToSyncStatusCodeWrapper(
94 google_apis::GDataErrorCode error);
96 DriveMetadataStore* metadata_store();
97 APIUtilInterface* api_util();
98 RemoteChangeHandler* remote_change_handler();
99 RemoteChangeProcessor* remote_change_processor();
100 ConflictResolutionResolver* conflict_resolution_resolver();
102 const FileChange& remote_file_change() const { return remote_change_.change; }
104 DriveFileSyncService* sync_service_; // Not owned.
106 RemoteChange remote_change_;
107 DriveMetadata drive_metadata_;
108 SyncFileMetadata local_metadata_;
109 webkit_blob::ScopedFile temporary_file_;
110 std::string md5_checksum_;
111 SyncAction sync_action_;
112 bool metadata_updated_;
113 bool clear_local_changes_;
115 std::string origin_resource_id_;
117 DISALLOW_COPY_AND_ASSIGN(RemoteSyncDelegate);
120 } // namespace drive_backend
122 } // namespace sync_file_system
124 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_V1_REMOTE_SYNC_DELEGATE_H_