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

Side by Side Diff: chrome/browser/sync_file_system/drive_backend/remote_to_local_syncer.h

Issue 1873683002: Convert //chrome/browser/sync_file_system from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
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_REMOTE_TO_LOCAL_SYNCER_H_ 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_REMOTE_TO_LOCAL_SYNCER_H_
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_REMOTE_TO_LOCAL_SYNCER_H_ 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_REMOTE_TO_LOCAL_SYNCER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 30 matching lines...) Expand all
41 41
42 class RemoteToLocalSyncer : public SyncTask { 42 class RemoteToLocalSyncer : public SyncTask {
43 public: 43 public:
44 typedef SyncTaskManager::Continuation Continuation; 44 typedef SyncTaskManager::Continuation Continuation;
45 45
46 // Conflicting trackers will have low priority for RemoteToLocalSyncer so that 46 // Conflicting trackers will have low priority for RemoteToLocalSyncer so that
47 // it should be resolved by LocatToRemoteSyncer. 47 // it should be resolved by LocatToRemoteSyncer.
48 explicit RemoteToLocalSyncer(SyncEngineContext* sync_context); 48 explicit RemoteToLocalSyncer(SyncEngineContext* sync_context);
49 ~RemoteToLocalSyncer() override; 49 ~RemoteToLocalSyncer() override;
50 50
51 void RunPreflight(scoped_ptr<SyncTaskToken> token) override; 51 void RunPreflight(std::unique_ptr<SyncTaskToken> token) override;
52 void RunExclusive(scoped_ptr<SyncTaskToken> token); 52 void RunExclusive(std::unique_ptr<SyncTaskToken> token);
53 53
54 const storage::FileSystemURL& url() const { return url_; } 54 const storage::FileSystemURL& url() const { return url_; }
55 SyncFileType file_type() const { return file_type_; } 55 SyncFileType file_type() const { return file_type_; }
56 SyncAction sync_action() const { return sync_action_; } 56 SyncAction sync_action() const { return sync_action_; }
57 57
58 bool is_sync_root_deletion() const { return sync_root_deletion_; } 58 bool is_sync_root_deletion() const { return sync_root_deletion_; }
59 59
60 private: 60 private:
61 typedef std::vector<std::string> FileIDList; 61 typedef std::vector<std::string> FileIDList;
62 62
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 // # Maybe, this can be decomposed to delete and update. 96 // # Maybe, this can be decomposed to delete and update.
97 // - Dispatch to HandreReorganize(). 97 // - Dispatch to HandreReorganize().
98 // Else, if the folder is a regular file and the md5 in remote metadata does 98 // Else, if the folder is a regular file and the md5 in remote metadata does
99 // not match the md5 in synced metadata: 99 // not match the md5 in synced metadata:
100 // # The file is modified remotely. 100 // # The file is modified remotely.
101 // - Dispatch to HandleContentUpdate(). 101 // - Dispatch to HandleContentUpdate().
102 // Else, if the tracker is a folder and it has needs_folder_listing flag: 102 // Else, if the tracker is a folder and it has needs_folder_listing flag:
103 // - Dispatch to HandleFolderContentListing() 103 // - Dispatch to HandleFolderContentListing()
104 // Else, there should be no change to sync. 104 // Else, there should be no change to sync.
105 // - Dispatch to HandleOfflineSolvable() 105 // - Dispatch to HandleOfflineSolvable()
106 void ResolveRemoteChange(scoped_ptr<SyncTaskToken> token); 106 void ResolveRemoteChange(std::unique_ptr<SyncTaskToken> token);
107 107
108 void MoveToBackground(scoped_ptr<SyncTaskToken> token, 108 void MoveToBackground(std::unique_ptr<SyncTaskToken> token,
109 const Continuation& continuation); 109 const Continuation& continuation);
110 void ContinueAsBackgroundTask(const Continuation& continuation, 110 void ContinueAsBackgroundTask(const Continuation& continuation,
111 scoped_ptr<SyncTaskToken> token); 111 std::unique_ptr<SyncTaskToken> token);
112 112
113 // Handles missing remote metadata case. 113 // Handles missing remote metadata case.
114 // Fetches remote metadata and updates MetadataDatabase by that. The sync 114 // Fetches remote metadata and updates MetadataDatabase by that. The sync
115 // operation itself will be deferred to the next sync round. 115 // operation itself will be deferred to the next sync round.
116 // Note: if the file is not found, it should be handled as if deleted. 116 // Note: if the file is not found, it should be handled as if deleted.
117 void HandleMissingRemoteMetadata(scoped_ptr<SyncTaskToken> token); 117 void HandleMissingRemoteMetadata(std::unique_ptr<SyncTaskToken> token);
118 void DidGetRemoteMetadata(scoped_ptr<SyncTaskToken> token, 118 void DidGetRemoteMetadata(std::unique_ptr<SyncTaskToken> token,
119 google_apis::DriveApiErrorCode error, 119 google_apis::DriveApiErrorCode error,
120 scoped_ptr<google_apis::FileResource> entry); 120 std::unique_ptr<google_apis::FileResource> entry);
121 121
122 // This implements the body of the HandleNewFile and HandleContentUpdate. 122 // This implements the body of the HandleNewFile and HandleContentUpdate.
123 // If the file doesn't have corresponding local file: 123 // If the file doesn't have corresponding local file:
124 // - Dispatch to DownloadFile. 124 // - Dispatch to DownloadFile.
125 // Else, if the local file doesn't have local change: 125 // Else, if the local file doesn't have local change:
126 // - Dispatch to DownloadFile if the local file is a regular file. 126 // - Dispatch to DownloadFile if the local file is a regular file.
127 // - If the local file is a folder, handle this case as a conflict. Lower 127 // - If the local file is a folder, handle this case as a conflict. Lower
128 // the priority of the tracker, and defer further handling to 128 // the priority of the tracker, and defer further handling to
129 // local-to-remote change. 129 // local-to-remote change.
130 // Else: 130 // Else:
131 // # The file has local modification. 131 // # The file has local modification.
132 // - Handle this case as a conflict. Lower the priority of the tracker, and 132 // - Handle this case as a conflict. Lower the priority of the tracker, and
133 // defer further handling to local-to-remote change. 133 // defer further handling to local-to-remote change.
134 void DidPrepareForAddOrUpdateFile(scoped_ptr<SyncTaskToken> token, 134 void DidPrepareForAddOrUpdateFile(std::unique_ptr<SyncTaskToken> token,
135 SyncStatusCode status); 135 SyncStatusCode status);
136 136
137 // Handles remotely added folder. Needs Prepare() call. 137 // Handles remotely added folder. Needs Prepare() call.
138 // TODO(tzik): Write details and implement this. 138 // TODO(tzik): Write details and implement this.
139 void HandleFolderUpdate(scoped_ptr<SyncTaskToken> token); 139 void HandleFolderUpdate(std::unique_ptr<SyncTaskToken> token);
140 void DidPrepareForFolderUpdate(scoped_ptr<SyncTaskToken> token, 140 void DidPrepareForFolderUpdate(std::unique_ptr<SyncTaskToken> token,
141 SyncStatusCode status); 141 SyncStatusCode status);
142 142
143 // Handles deleted remote file. Needs Prepare() call. 143 // Handles deleted remote file. Needs Prepare() call.
144 // If the deleted tracker is the sync-root: 144 // If the deleted tracker is the sync-root:
145 // - TODO(tzik): Needs special handling. 145 // - TODO(tzik): Needs special handling.
146 // Else, if the deleted tracker is a app-root: 146 // Else, if the deleted tracker is a app-root:
147 // - TODO(tzik): Needs special handling. 147 // - TODO(tzik): Needs special handling.
148 // Else, if the local file is already deleted: 148 // Else, if the local file is already deleted:
149 // - Do nothing anymore to the local, call SyncCompleted(). 149 // - Do nothing anymore to the local, call SyncCompleted().
150 // Else, if the local file is modified: 150 // Else, if the local file is modified:
151 // - Do nothing to the local file, call SyncCompleted(). 151 // - Do nothing to the local file, call SyncCompleted().
152 // Else, if the local file is not modified: 152 // Else, if the local file is not modified:
153 // - Delete local file. 153 // - Delete local file.
154 // # Note: if the local file is a folder, delete recursively. 154 // # Note: if the local file is a folder, delete recursively.
155 void HandleDeletion(scoped_ptr<SyncTaskToken> token); 155 void HandleDeletion(std::unique_ptr<SyncTaskToken> token);
156 void DidPrepareForDeletion(scoped_ptr<SyncTaskToken> token, 156 void DidPrepareForDeletion(std::unique_ptr<SyncTaskToken> token,
157 SyncStatusCode status); 157 SyncStatusCode status);
158 158
159 void HandleFileMove(scoped_ptr<SyncTaskToken> token); 159 void HandleFileMove(std::unique_ptr<SyncTaskToken> token);
160 160
161 // Handles new file. Needs Prepare() call. 161 // Handles new file. Needs Prepare() call.
162 void HandleContentUpdate(scoped_ptr<SyncTaskToken> token); 162 void HandleContentUpdate(std::unique_ptr<SyncTaskToken> token);
163 163
164 void ListFolderContent(scoped_ptr<SyncTaskToken> token); 164 void ListFolderContent(std::unique_ptr<SyncTaskToken> token);
165 void DidListFolderContent( 165 void DidListFolderContent(std::unique_ptr<SyncTaskToken> token,
166 scoped_ptr<SyncTaskToken> token, 166 std::unique_ptr<FileIDList> children,
167 scoped_ptr<FileIDList> children, 167 google_apis::DriveApiErrorCode error,
168 google_apis::DriveApiErrorCode error, 168 std::unique_ptr<google_apis::FileList> file_list);
169 scoped_ptr<google_apis::FileList> file_list);
170 169
171 void SyncCompleted(scoped_ptr<SyncTaskToken> token, SyncStatusCode status); 170 void SyncCompleted(std::unique_ptr<SyncTaskToken> token,
172 void FinalizeSync(scoped_ptr<SyncTaskToken> token, SyncStatusCode status); 171 SyncStatusCode status);
172 void FinalizeSync(std::unique_ptr<SyncTaskToken> token,
173 SyncStatusCode status);
173 174
174 void Prepare(const SyncStatusCallback& callback); 175 void Prepare(const SyncStatusCallback& callback);
175 void DidPrepare(const SyncStatusCallback& callback, 176 void DidPrepare(const SyncStatusCallback& callback,
176 SyncStatusCode status, 177 SyncStatusCode status,
177 const SyncFileMetadata& metadata, 178 const SyncFileMetadata& metadata,
178 const FileChangeList& changes); 179 const FileChangeList& changes);
179 180
180 void DeleteLocalFile(scoped_ptr<SyncTaskToken> token); 181 void DeleteLocalFile(std::unique_ptr<SyncTaskToken> token);
181 void DownloadFile(scoped_ptr<SyncTaskToken> token); 182 void DownloadFile(std::unique_ptr<SyncTaskToken> token);
182 void DidDownloadFile(scoped_ptr<SyncTaskToken> token, 183 void DidDownloadFile(std::unique_ptr<SyncTaskToken> token,
183 storage::ScopedFile file, 184 storage::ScopedFile file,
184 google_apis::DriveApiErrorCode error, 185 google_apis::DriveApiErrorCode error,
185 const base::FilePath&); 186 const base::FilePath&);
186 void DidApplyDownload(scoped_ptr<SyncTaskToken> token, 187 void DidApplyDownload(std::unique_ptr<SyncTaskToken> token,
187 storage::ScopedFile, 188 storage::ScopedFile,
188 SyncStatusCode status); 189 SyncStatusCode status);
189 190
190 void CreateFolder(scoped_ptr<SyncTaskToken> token); 191 void CreateFolder(std::unique_ptr<SyncTaskToken> token);
191 192
192 // TODO(tzik): After we convert all callbacks to token-passing style, 193 // TODO(tzik): After we convert all callbacks to token-passing style,
193 // drop this function. 194 // drop this function.
194 SyncStatusCallback SyncCompletedCallback(scoped_ptr<SyncTaskToken> token); 195 SyncStatusCallback SyncCompletedCallback(
196 std::unique_ptr<SyncTaskToken> token);
195 197
196 drive::DriveServiceInterface* drive_service(); 198 drive::DriveServiceInterface* drive_service();
197 MetadataDatabase* metadata_database(); 199 MetadataDatabase* metadata_database();
198 RemoteChangeProcessor* remote_change_processor(); 200 RemoteChangeProcessor* remote_change_processor();
199 201
200 SyncEngineContext* sync_context_; // Not owned. 202 SyncEngineContext* sync_context_; // Not owned.
201 203
202 scoped_ptr<FileTracker> dirty_tracker_; 204 std::unique_ptr<FileTracker> dirty_tracker_;
203 scoped_ptr<FileMetadata> remote_metadata_; 205 std::unique_ptr<FileMetadata> remote_metadata_;
204 206
205 storage::FileSystemURL url_; 207 storage::FileSystemURL url_;
206 SyncFileType file_type_; 208 SyncFileType file_type_;
207 SyncAction sync_action_; 209 SyncAction sync_action_;
208 210
209 bool prepared_; 211 bool prepared_;
210 bool sync_root_deletion_; 212 bool sync_root_deletion_;
211 213
212 scoped_ptr<SyncFileMetadata> local_metadata_; 214 std::unique_ptr<SyncFileMetadata> local_metadata_;
213 scoped_ptr<FileChangeList> local_changes_; 215 std::unique_ptr<FileChangeList> local_changes_;
214 216
215 base::WeakPtrFactory<RemoteToLocalSyncer> weak_ptr_factory_; 217 base::WeakPtrFactory<RemoteToLocalSyncer> weak_ptr_factory_;
216 218
217 DISALLOW_COPY_AND_ASSIGN(RemoteToLocalSyncer); 219 DISALLOW_COPY_AND_ASSIGN(RemoteToLocalSyncer);
218 }; 220 };
219 221
220 } // namespace drive_backend 222 } // namespace drive_backend
221 } // namespace sync_file_system 223 } // namespace sync_file_system
222 224
223 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_REMOTE_TO_LOCAL_SYNCER_ H_ 225 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_REMOTE_TO_LOCAL_SYNCER_ H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698