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

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: +TODO 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
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 class APIUtil;
nhiroki 2013/05/17 06:02:14 nit: you may want to add a blank line between 21 a
tzik 2013/05/17 07:49:25 Done.
23
24 // This class handles ApplyLocalChange in LocalChangeProcessor, and its instance
25 // represents single ApplyLocalChange operation.
26 // The caller is responsible to own the instance, and can cancel operation by
27 // deleting the instance or |sync_service|.
28 class LocalChangeProcessorDelegate {
29 public:
30 typedef RemoteChangeHandler::RemoteChange RemoteChange;
31
32 LocalChangeProcessorDelegate(
33 base::WeakPtr<DriveFileSyncService> sync_service,
34 const FileChange& change,
35 const base::FilePath& local_file_path,
36 const SyncFileMetadata& local_file_metadata,
37 const fileapi::FileSystemURL& url);
38 ~LocalChangeProcessorDelegate();
39
40 void Run(const SyncStatusCallback& callback);
41
42 private:
43 void DidGetOriginRoot(const SyncStatusCallback& callback,
44 SyncStatusCode status,
45 const std::string& resource_id);
46 void UploadNewFile(const SyncStatusCallback& callback);
47 void DidUploadNewFile(const SyncStatusCallback& callback,
48 google_apis::GDataErrorCode error,
49 const std::string& resource_id,
50 const std::string& md5);
51 void CreateDirectory(const SyncStatusCallback& callback);
52 void DidCreateDirectory(
53 const SyncStatusCallback& callback,
54 google_apis::GDataErrorCode error,
55 const std::string& resource_id);
56 void UploadExistingFile(const SyncStatusCallback& callback);
57 void DidUploadExistingFile(
58 const SyncStatusCallback& callback,
59 google_apis::GDataErrorCode error,
60 const std::string& resource_id,
61 const std::string& md5);
62 void DeleteFile(const SyncStatusCallback& callback);
63 void DeleteDirectory(const SyncStatusCallback& callback);
64 void DidDeleteFile(const SyncStatusCallback& callback,
65 google_apis::GDataErrorCode error);
66 void ResolveToLocal(const SyncStatusCallback& callback);
67 void DidDeleteFileToResolveToLocal(
68 const SyncStatusCallback& callback,
69 google_apis::GDataErrorCode error);
70 void ResolveToRemote(const SyncStatusCallback& callback);
71 void DidResolveToRemote(const SyncStatusCallback& callback,
72 SyncStatusCode status);
73 void DidApplyLocalChange(
74 const SyncStatusCallback& callback,
75 const google_apis::GDataErrorCode error,
76 SyncStatusCode status);
77
78 // Metadata manipulation.
79 void UpdateMetadata(const std::string& resource_id,
80 const std::string& md5,
81 DriveMetadata::ResourceType type,
82 const SyncStatusCallback& callback);
83 void ResetMetadataMD5(const SyncStatusCallback& callback);
84 void SetMetadataToBeFetched(DriveMetadata::ResourceType type,
85 const SyncStatusCallback& callback);
86 void DeleteMetadata(const SyncStatusCallback& callback);
87 void SetMetadataConflict(const SyncStatusCallback& callback);
88
89 // Conflict handling.
90 void HandleCreationConflict(
91 const std::string& resource_id,
92 DriveMetadata::ResourceType type,
93 const SyncStatusCallback& callback);
94 void HandleConflict(const SyncStatusCallback& callback);
95 void DidGetEntryForConflictResolution(
96 const SyncStatusCallback& callback,
97 google_apis::GDataErrorCode error,
98 scoped_ptr<google_apis::ResourceEntry> entry);
99
100 void HandleManualResolutionCase(const SyncStatusCallback& callback);
101 void HandleLocalWinCase(const SyncStatusCallback& callback);
102 void HandleRemoteWinCase(const SyncStatusCallback& callback);
103 void StartOver(const SyncStatusCallback& callback, SyncStatusCode status);
104
105 SyncStatusCode GDataErrorCodeToSyncStatusCodeWrapper(
106 google_apis::GDataErrorCode error);
107
108 DriveMetadataStore* metadata_store();
109 drive::APIUtilInterface* api_util();
110 RemoteChangeHandler* remote_change_handler();
111
112 base::WeakPtr<DriveFileSyncService> sync_service_;
113
114 fileapi::FileSystemURL url_;
115 FileChange local_change_;
116 base::FilePath local_path_;
117 SyncFileMetadata local_metadata_;
118 DriveMetadata drive_metadata_;
119 bool has_drive_metadata_;
120 RemoteChange remote_change_;
121 bool has_remote_change_;
122
123 std::string origin_resource_id_;
124
125 base::WeakPtrFactory<LocalChangeProcessorDelegate> weak_factory_;
126
127 DISALLOW_COPY_AND_ASSIGN(LocalChangeProcessorDelegate);
128 };
129
130 } // namespace drive
131 } // namespace sync_file_system
132
133 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_LOCAL_CHANGE_PROCESSOR_DELEGATE _H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698