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

Side by Side Diff: chrome/browser/sync_file_system/drive_backend/conflict_resolver.cc

Issue 558603002: [SyncFS] Make MetadataDatabase operations synchronous (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@01_create
Patch Set: +TODO Created 6 years, 3 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
« no previous file with comments | « no previous file | chrome/browser/sync_file_system/drive_backend/conflict_resolver_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "chrome/browser/sync_file_system/drive_backend/conflict_resolver.h" 5 #include "chrome/browser/sync_file_system/drive_backend/conflict_resolver.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/format_macros.h" 8 #include "base/format_macros.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 SyncTaskManager::NotifyTaskDone(token.Pass(), status); 261 SyncTaskManager::NotifyTaskDone(token.Pass(), status);
262 return; 262 return;
263 } 263 }
264 264
265 deleted_file_ids_.push_back(file_id); 265 deleted_file_ids_.push_back(file_id);
266 if (!non_primary_file_ids_.empty()) { 266 if (!non_primary_file_ids_.empty()) {
267 RemoveNonPrimaryFiles(token.Pass()); 267 RemoveNonPrimaryFiles(token.Pass());
268 return; 268 return;
269 } 269 }
270 270
271 metadata_database()->UpdateByDeletedRemoteFileList( 271 status = metadata_database()->UpdateByDeletedRemoteFileList(
272 deleted_file_ids_, SyncTaskToken::WrapToCallback(token.Pass())); 272 deleted_file_ids_);
273 SyncTaskManager::NotifyTaskDone(token.Pass(), status);
273 } 274 }
274 275
275 bool ConflictResolver::IsContextReady() { 276 bool ConflictResolver::IsContextReady() {
276 return sync_context_->GetDriveService() && 277 return sync_context_->GetDriveService() &&
277 sync_context_->GetMetadataDatabase(); 278 sync_context_->GetMetadataDatabase();
278 } 279 }
279 280
280 void ConflictResolver::UpdateFileMetadata( 281 void ConflictResolver::UpdateFileMetadata(
281 const std::string& file_id, 282 const std::string& file_id,
282 scoped_ptr<SyncTaskToken> token) { 283 scoped_ptr<SyncTaskToken> token) {
283 drive_service()->GetFileResource( 284 drive_service()->GetFileResource(
284 file_id, 285 file_id,
285 base::Bind(&ConflictResolver::DidGetRemoteMetadata, 286 base::Bind(&ConflictResolver::DidGetRemoteMetadata,
286 weak_ptr_factory_.GetWeakPtr(), file_id, 287 weak_ptr_factory_.GetWeakPtr(), file_id,
287 base::Passed(&token))); 288 base::Passed(&token)));
288 } 289 }
289 290
290 void ConflictResolver::DidGetRemoteMetadata( 291 void ConflictResolver::DidGetRemoteMetadata(
291 const std::string& file_id, 292 const std::string& file_id,
292 scoped_ptr<SyncTaskToken> token, 293 scoped_ptr<SyncTaskToken> token,
293 google_apis::GDataErrorCode error, 294 google_apis::GDataErrorCode error,
294 scoped_ptr<google_apis::FileResource> entry) { 295 scoped_ptr<google_apis::FileResource> entry) {
295 SyncStatusCode status = GDataErrorCodeToSyncStatusCode(error); 296 SyncStatusCode status = GDataErrorCodeToSyncStatusCode(error);
296 if (status != SYNC_STATUS_OK && error != google_apis::HTTP_NOT_FOUND) { 297 if (status != SYNC_STATUS_OK && error != google_apis::HTTP_NOT_FOUND) {
297 SyncTaskManager::NotifyTaskDone(token.Pass(), status); 298 SyncTaskManager::NotifyTaskDone(token.Pass(), status);
298 return; 299 return;
299 } 300 }
300 301
301 if (error != google_apis::HTTP_NOT_FOUND) { 302 if (error != google_apis::HTTP_NOT_FOUND) {
302 metadata_database()->UpdateByDeletedRemoteFile( 303 status = metadata_database()->UpdateByDeletedRemoteFile(file_id);
303 file_id, SyncTaskToken::WrapToCallback(token.Pass())); 304 SyncTaskManager::NotifyTaskDone(token.Pass(), status);
304 return; 305 return;
305 } 306 }
306 307
307 if (!entry) { 308 if (!entry) {
308 NOTREACHED(); 309 NOTREACHED();
309 SyncTaskManager::NotifyTaskDone(token.Pass(), SYNC_STATUS_FAILED); 310 SyncTaskManager::NotifyTaskDone(token.Pass(), SYNC_STATUS_FAILED);
310 return; 311 return;
311 } 312 }
312 313
313 metadata_database()->UpdateByFileResource( 314 status = metadata_database()->UpdateByFileResource(*entry);
314 *entry, SyncTaskToken::WrapToCallback(token.Pass())); 315 SyncTaskManager::NotifyTaskDone(token.Pass(), status);
315 } 316 }
316 317
317 drive::DriveServiceInterface* ConflictResolver::drive_service() { 318 drive::DriveServiceInterface* ConflictResolver::drive_service() {
318 set_used_network(true); 319 set_used_network(true);
319 return sync_context_->GetDriveService(); 320 return sync_context_->GetDriveService();
320 } 321 }
321 322
322 MetadataDatabase* ConflictResolver::metadata_database() { 323 MetadataDatabase* ConflictResolver::metadata_database() {
323 return sync_context_->GetMetadataDatabase(); 324 return sync_context_->GetMetadataDatabase();
324 } 325 }
325 326
326 } // namespace drive_backend 327 } // namespace drive_backend
327 } // namespace sync_file_system 328 } // namespace sync_file_system
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sync_file_system/drive_backend/conflict_resolver_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698