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

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

Issue 558603002: [SyncFS] Make MetadataDatabase operations synchronous (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@01_create
Patch Set: 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
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/remote_to_local_syncer.h " 5 #include "chrome/browser/sync_file_system/drive_backend/remote_to_local_syncer.h "
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/format_macros.h" 10 #include "base/format_macros.h"
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 DCHECK(sync_context_->GetWorkerTaskRunner()->RunsTasksOnCurrentThread()); 308 DCHECK(sync_context_->GetWorkerTaskRunner()->RunsTasksOnCurrentThread());
309 309
310 SyncStatusCode status = GDataErrorCodeToSyncStatusCode(error); 310 SyncStatusCode status = GDataErrorCodeToSyncStatusCode(error);
311 if (status != SYNC_STATUS_OK && 311 if (status != SYNC_STATUS_OK &&
312 error != google_apis::HTTP_NOT_FOUND) { 312 error != google_apis::HTTP_NOT_FOUND) {
313 SyncCompleted(token.Pass(), status); 313 SyncCompleted(token.Pass(), status);
314 return; 314 return;
315 } 315 }
316 316
317 if (error == google_apis::HTTP_NOT_FOUND) { 317 if (error == google_apis::HTTP_NOT_FOUND) {
318 metadata_database()->UpdateByDeletedRemoteFile( 318 status = metadata_database()->UpdateByDeletedRemoteFile(
319 dirty_tracker_->file_id(), SyncCompletedCallback(token.Pass())); 319 dirty_tracker_->file_id());
320 SyncCompleted(token.Pass(), status);
320 return; 321 return;
321 } 322 }
322 323
323 if (!entry) { 324 if (!entry) {
324 NOTREACHED(); 325 NOTREACHED();
325 SyncCompleted(token.Pass(), SYNC_STATUS_FAILED); 326 SyncCompleted(token.Pass(), SYNC_STATUS_FAILED);
326 return; 327 return;
327 } 328 }
328 329
329 metadata_database()->UpdateByFileResource( 330 status = metadata_database()->UpdateByFileResource(*entry);
330 *entry, 331 DidUpdateDatabaseForRemoteMetadata(token.Pass(), status);
peria 2014/09/10 00:24:15 Expand DidUpdateDatabaseForRemoteMetadata() here
tzik 2014/09/10 00:56:54 ditto
331 base::Bind(&RemoteToLocalSyncer::DidUpdateDatabaseForRemoteMetadata,
332 weak_ptr_factory_.GetWeakPtr(),
333 base::Passed(&token)));
334 } 332 }
335 333
336 void RemoteToLocalSyncer::DidUpdateDatabaseForRemoteMetadata( 334 void RemoteToLocalSyncer::DidUpdateDatabaseForRemoteMetadata(
337 scoped_ptr<SyncTaskToken> token, 335 scoped_ptr<SyncTaskToken> token,
338 SyncStatusCode status) { 336 SyncStatusCode status) {
339 if (status != SYNC_STATUS_OK) { 337 if (status != SYNC_STATUS_OK) {
340 SyncCompleted(token.Pass(), status); 338 SyncCompleted(token.Pass(), status);
341 return; 339 return;
342 } 340 }
343 341
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 575
578 if (!file_list->next_link().is_empty()) { 576 if (!file_list->next_link().is_empty()) {
579 drive_service()->GetRemainingFileList( 577 drive_service()->GetRemainingFileList(
580 file_list->next_link(), 578 file_list->next_link(),
581 base::Bind(&RemoteToLocalSyncer::DidListFolderContent, 579 base::Bind(&RemoteToLocalSyncer::DidListFolderContent,
582 weak_ptr_factory_.GetWeakPtr(), 580 weak_ptr_factory_.GetWeakPtr(),
583 base::Passed(&token), base::Passed(&children))); 581 base::Passed(&token), base::Passed(&children)));
584 return; 582 return;
585 } 583 }
586 584
587 metadata_database()->PopulateFolderByChildList( 585 status = metadata_database()->PopulateFolderByChildList(
588 dirty_tracker_->file_id(), *children, 586 dirty_tracker_->file_id(), *children);
589 SyncCompletedCallback(token.Pass())); 587 SyncCompleted(token.Pass(), status);
590 } 588 }
591 589
592 void RemoteToLocalSyncer::SyncCompleted(scoped_ptr<SyncTaskToken> token, 590 void RemoteToLocalSyncer::SyncCompleted(scoped_ptr<SyncTaskToken> token,
593 SyncStatusCode status) { 591 SyncStatusCode status) {
594 token->RecordLog(base::StringPrintf( 592 token->RecordLog(base::StringPrintf(
595 "[Remote -> Local]: Finished: action=%s, tracker=%" PRId64 " status=%s", 593 "[Remote -> Local]: Finished: action=%s, tracker=%" PRId64 " status=%s",
596 SyncActionToString(sync_action_), dirty_tracker_->tracker_id(), 594 SyncActionToString(sync_action_), dirty_tracker_->tracker_id(),
597 SyncStatusCodeToString(status))); 595 SyncStatusCodeToString(status)));
598 596
599 if (sync_root_deletion_) { 597 if (sync_root_deletion_) {
(...skipping 20 matching lines...) Expand all
620 HasDisabledAppRoot(metadata_database(), *dirty_tracker_)) { 618 HasDisabledAppRoot(metadata_database(), *dirty_tracker_)) {
621 // Operations for an inactive tracker don't update file content. 619 // Operations for an inactive tracker don't update file content.
622 if (dirty_tracker_->has_synced_details()) 620 if (dirty_tracker_->has_synced_details())
623 updated_details.set_md5(dirty_tracker_->synced_details().md5()); 621 updated_details.set_md5(dirty_tracker_->synced_details().md5());
624 if (!dirty_tracker_->active()) { 622 if (!dirty_tracker_->active()) {
625 // Keep missing true, as the change hasn't been synced to local. 623 // Keep missing true, as the change hasn't been synced to local.
626 updated_details.clear_md5(); 624 updated_details.clear_md5();
627 updated_details.set_missing(true); 625 updated_details.set_missing(true);
628 } 626 }
629 } 627 }
630 metadata_database()->UpdateTracker( 628
631 dirty_tracker_->tracker_id(), 629 status = metadata_database()->UpdateTracker(
632 updated_details, 630 dirty_tracker_->tracker_id(), updated_details);
633 base::Bind(&RemoteToLocalSyncer::FinalizeSync, 631 FinalizeSync(token.Pass(), status);
peria 2014/09/10 00:24:15 Expand FinalizeSync() here.
tzik 2014/09/10 00:56:54 ditto
634 weak_ptr_factory_.GetWeakPtr(),
635 base::Passed(&token)));
636 } 632 }
637 633
638 void RemoteToLocalSyncer::FinalizeSync(scoped_ptr<SyncTaskToken> token, 634 void RemoteToLocalSyncer::FinalizeSync(scoped_ptr<SyncTaskToken> token,
639 SyncStatusCode status) { 635 SyncStatusCode status) {
640 if (prepared_) { 636 if (prepared_) {
641 remote_change_processor()->FinalizeRemoteSync( 637 remote_change_processor()->FinalizeRemoteSync(
642 url_, false /* clear_local_change */, 638 url_, false /* clear_local_change */,
643 base::Bind(SyncTaskManager::NotifyTaskDone, 639 base::Bind(SyncTaskManager::NotifyTaskDone,
644 base::Passed(&token), status)); 640 base::Passed(&token), status));
645 return; 641 return;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 758
763 SyncStatusCallback RemoteToLocalSyncer::SyncCompletedCallback( 759 SyncStatusCallback RemoteToLocalSyncer::SyncCompletedCallback(
764 scoped_ptr<SyncTaskToken> token) { 760 scoped_ptr<SyncTaskToken> token) {
765 return base::Bind(&RemoteToLocalSyncer::SyncCompleted, 761 return base::Bind(&RemoteToLocalSyncer::SyncCompleted,
766 weak_ptr_factory_.GetWeakPtr(), 762 weak_ptr_factory_.GetWeakPtr(),
767 base::Passed(&token)); 763 base::Passed(&token));
768 } 764 }
769 765
770 } // namespace drive_backend 766 } // namespace drive_backend
771 } // namespace sync_file_system 767 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698