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

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

Issue 236313009: [SyncFS] Post tasks between SyncEngine and SyncWorker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Work for comments Created 6 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 #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/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 void RemoteToLocalSyncer::DeleteLocalFile(const SyncStatusCallback& callback) { 664 void RemoteToLocalSyncer::DeleteLocalFile(const SyncStatusCallback& callback) {
665 remote_change_processor()->ApplyRemoteChange( 665 remote_change_processor()->ApplyRemoteChange(
666 FileChange(FileChange::FILE_CHANGE_DELETE, SYNC_FILE_TYPE_UNKNOWN), 666 FileChange(FileChange::FILE_CHANGE_DELETE, SYNC_FILE_TYPE_UNKNOWN),
667 base::FilePath(), 667 base::FilePath(),
668 url_, 668 url_,
669 callback); 669 callback);
670 } 670 }
671 671
672 void RemoteToLocalSyncer::DownloadFile(const SyncStatusCallback& callback) { 672 void RemoteToLocalSyncer::DownloadFile(const SyncStatusCallback& callback) {
673 base::PostTaskAndReplyWithResult( 673 base::PostTaskAndReplyWithResult(
674 sync_context_->GetBlockingTaskRunner(), FROM_HERE, 674 sync_context_->GetFileTaskRunner(), FROM_HERE,
675 base::Bind(&sync_file_system::drive_backend::CreateTemporaryFile, 675 base::Bind(&sync_file_system::drive_backend::CreateTemporaryFile,
676 make_scoped_refptr(sync_context_->GetBlockingTaskRunner())), 676 make_scoped_refptr(sync_context_->GetFileTaskRunner())),
677 base::Bind(&RemoteToLocalSyncer::DidCreateTemporaryFileForDownload, 677 base::Bind(&RemoteToLocalSyncer::DidCreateTemporaryFileForDownload,
678 weak_ptr_factory_.GetWeakPtr(), callback)); 678 weak_ptr_factory_.GetWeakPtr(), callback));
679 } 679 }
680 680
681 void RemoteToLocalSyncer::DidCreateTemporaryFileForDownload( 681 void RemoteToLocalSyncer::DidCreateTemporaryFileForDownload(
682 const SyncStatusCallback& callback, 682 const SyncStatusCallback& callback,
683 webkit_blob::ScopedFile file) { 683 webkit_blob::ScopedFile file) {
684 base::FilePath path = file.path(); 684 base::FilePath path = file.path();
685 drive_service()->DownloadFile( 685 drive_service()->DownloadFile(
686 path, remote_metadata_->file_id(), 686 path, remote_metadata_->file_id(),
687 base::Bind(&RemoteToLocalSyncer::DidDownloadFile, 687 base::Bind(&RemoteToLocalSyncer::DidDownloadFile,
688 weak_ptr_factory_.GetWeakPtr(), 688 weak_ptr_factory_.GetWeakPtr(),
689 callback, base::Passed(&file)), 689 callback, base::Passed(&file)),
690 google_apis::GetContentCallback(), 690 google_apis::GetContentCallback(),
691 google_apis::ProgressCallback()); 691 google_apis::ProgressCallback());
692 } 692 }
693 693
694 void RemoteToLocalSyncer::DidDownloadFile(const SyncStatusCallback& callback, 694 void RemoteToLocalSyncer::DidDownloadFile(const SyncStatusCallback& callback,
695 webkit_blob::ScopedFile file, 695 webkit_blob::ScopedFile file,
696 google_apis::GDataErrorCode error, 696 google_apis::GDataErrorCode error,
697 const base::FilePath&) { 697 const base::FilePath&) {
698 SyncStatusCode status = GDataErrorCodeToSyncStatusCode(error); 698 SyncStatusCode status = GDataErrorCodeToSyncStatusCode(error);
699 if (status != SYNC_STATUS_OK) { 699 if (status != SYNC_STATUS_OK) {
700 callback.Run(status); 700 callback.Run(status);
701 return; 701 return;
702 } 702 }
703 703
704 base::FilePath path = file.path(); 704 base::FilePath path = file.path();
705 base::PostTaskAndReplyWithResult( 705 base::PostTaskAndReplyWithResult(
706 sync_context_->GetBlockingTaskRunner(), FROM_HERE, 706 sync_context_->GetFileTaskRunner(), FROM_HERE,
707 base::Bind(&drive::util::GetMd5Digest, path), 707 base::Bind(&drive::util::GetMd5Digest, path),
708 base::Bind(&RemoteToLocalSyncer::DidCalculateMD5ForDownload, 708 base::Bind(&RemoteToLocalSyncer::DidCalculateMD5ForDownload,
709 weak_ptr_factory_.GetWeakPtr(), 709 weak_ptr_factory_.GetWeakPtr(),
710 callback, base::Passed(&file))); 710 callback, base::Passed(&file)));
711 } 711 }
712 712
713 void RemoteToLocalSyncer::DidCalculateMD5ForDownload( 713 void RemoteToLocalSyncer::DidCalculateMD5ForDownload(
714 const SyncStatusCallback& callback, 714 const SyncStatusCallback& callback,
715 webkit_blob::ScopedFile file, 715 webkit_blob::ScopedFile file,
716 const std::string& md5) { 716 const std::string& md5) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 return sync_context_->GetMetadataDatabase(); 762 return sync_context_->GetMetadataDatabase();
763 } 763 }
764 764
765 RemoteChangeProcessor* RemoteToLocalSyncer::remote_change_processor() { 765 RemoteChangeProcessor* RemoteToLocalSyncer::remote_change_processor() {
766 DCHECK(sync_context_->GetRemoteChangeProcessor()); 766 DCHECK(sync_context_->GetRemoteChangeProcessor());
767 return sync_context_->GetRemoteChangeProcessor(); 767 return sync_context_->GetRemoteChangeProcessor();
768 } 768 }
769 769
770 } // namespace drive_backend 770 } // namespace drive_backend
771 } // namespace sync_file_system 771 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698