Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: chrome/browser/sync_file_system/drive/local_change_processor_delegate.h

Issue 14977008: [SyncFileSystem] Separate out ApplyLocalChange from DriveFileSyncService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: style fix Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/sync_file_system/drive/local_change_processor_delegate.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_LOCAL_CHANGE_PROCESSOR_DELEGATE_H_
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_LOCAL_CHANGE_PROCESSOR_DELEGATE_H_
7
8 #include "base/callback.h"
9 #include "base/memory/weak_ptr.h"
10 #include "chrome/browser/sync_file_system/drive_file_sync_service.h"
11 #include "chrome/browser/sync_file_system/sync_file_system.pb.h"
12 #include "webkit/fileapi/file_system_url.h"
13 #include "webkit/fileapi/syncable/file_change.h"
14 #include "webkit/fileapi/syncable/sync_callbacks.h"
15 #include "webkit/fileapi/syncable/sync_file_metadata.h"
16
17 namespace sync_file_system {
18
19 class DriveMetadataStore;
20
21 namespace drive {
22
23 class APIUtil;
24
25 // This class handles ApplyLocalChange in LocalChangeProcessor, and its instance
26 // represents single ApplyLocalChange operation.
27 // The caller is responsible to own the instance, and can cancel operation by
28 // deleting the instance or |sync_service|.
29 class LocalChangeProcessorDelegate {
30 public:
31 typedef RemoteChangeHandler::RemoteChange RemoteChange;
32
33 LocalChangeProcessorDelegate(
34 base::WeakPtr<DriveFileSyncService> sync_service,
35 const FileChange& change,
36 const base::FilePath& local_file_path,
37 const SyncFileMetadata& local_file_metadata,
38 const fileapi::FileSystemURL& url);
39 ~LocalChangeProcessorDelegate();
40
41 void Run(const SyncStatusCallback& callback);
42
43 private:
44 void DidGetOriginRoot(const SyncStatusCallback& callback,
45 SyncStatusCode status,
46 const std::string& resource_id);
47 void UploadNewFile(const SyncStatusCallback& callback);
48 void DidUploadNewFile(const SyncStatusCallback& callback,
49 google_apis::GDataErrorCode error,
50 const std::string& resource_id,
51 const std::string& md5);
52 void CreateDirectory(const SyncStatusCallback& callback);
53 void DidCreateDirectory(
54 const SyncStatusCallback& callback,
55 google_apis::GDataErrorCode error,
56 const std::string& resource_id);
57 void UploadExistingFile(const SyncStatusCallback& callback);
58 void DidUploadExistingFile(
59 const SyncStatusCallback& callback,
60 google_apis::GDataErrorCode error,
61 const std::string& resource_id,
62 const std::string& md5);
63 void DeleteFile(const SyncStatusCallback& callback);
64 void DeleteDirectory(const SyncStatusCallback& callback);
65 void DidDeleteFile(const SyncStatusCallback& callback,
66 google_apis::GDataErrorCode error);
67 void ResolveToLocal(const SyncStatusCallback& callback);
68 void DidDeleteFileToResolveToLocal(
69 const SyncStatusCallback& callback,
70 google_apis::GDataErrorCode error);
71 void ResolveToRemote(const SyncStatusCallback& callback);
72 void DidResolveToRemote(const SyncStatusCallback& callback,
73 SyncStatusCode status);
74 void DidApplyLocalChange(
75 const SyncStatusCallback& callback,
76 const google_apis::GDataErrorCode error,
77 SyncStatusCode status);
78
79 // Metadata manipulation.
80 void UpdateMetadata(const std::string& resource_id,
81 const std::string& md5,
82 DriveMetadata::ResourceType type,
83 const SyncStatusCallback& callback);
84 void ResetMetadataMD5(const SyncStatusCallback& callback);
85 void SetMetadataToBeFetched(DriveMetadata::ResourceType type,
86 const SyncStatusCallback& callback);
87 void DeleteMetadata(const SyncStatusCallback& callback);
88 void SetMetadataConflict(const SyncStatusCallback& callback);
89
90 // Conflict handling.
91 void HandleCreationConflict(
92 const std::string& resource_id,
93 DriveMetadata::ResourceType type,
94 const SyncStatusCallback& callback);
95 void HandleConflict(const SyncStatusCallback& callback);
96 void DidGetEntryForConflictResolution(
97 const SyncStatusCallback& callback,
98 google_apis::GDataErrorCode error,
99 scoped_ptr<google_apis::ResourceEntry> entry);
100
101 void HandleManualResolutionCase(const SyncStatusCallback& callback);
102 void HandleLocalWinCase(const SyncStatusCallback& callback);
103 void HandleRemoteWinCase(const SyncStatusCallback& callback);
104 void StartOver(const SyncStatusCallback& callback, SyncStatusCode status);
105
106 SyncStatusCode GDataErrorCodeToSyncStatusCodeWrapper(
107 google_apis::GDataErrorCode error);
108
109 DriveMetadataStore* metadata_store();
110 drive::APIUtilInterface* api_util();
111 RemoteChangeHandler* remote_change_handler();
112
113 base::WeakPtr<DriveFileSyncService> sync_service_;
114
115 fileapi::FileSystemURL url_;
116 FileChange local_change_;
117 base::FilePath local_path_;
118 SyncFileMetadata local_metadata_;
119 DriveMetadata drive_metadata_;
120 bool has_drive_metadata_;
121 RemoteChange remote_change_;
122 bool has_remote_change_;
123
124 std::string origin_resource_id_;
125
126 base::WeakPtrFactory<LocalChangeProcessorDelegate> weak_factory_;
127
128 DISALLOW_COPY_AND_ASSIGN(LocalChangeProcessorDelegate);
129 };
130
131 } // namespace drive
132 } // namespace sync_file_system
133
134 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_LOCAL_CHANGE_PROCESSOR_DELEGATE _H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sync_file_system/drive/local_change_processor_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698