| OLD | NEW |
| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 dirty_tracker_->file_id(), | 403 dirty_tracker_->file_id(), |
| 404 base::Bind(&RemoteToLocalSyncer::DidGetRemoteMetadata, | 404 base::Bind(&RemoteToLocalSyncer::DidGetRemoteMetadata, |
| 405 weak_ptr_factory_.GetWeakPtr(), | 405 weak_ptr_factory_.GetWeakPtr(), |
| 406 base::Passed(&token))); | 406 base::Passed(&token))); |
| 407 } | 407 } |
| 408 | 408 |
| 409 void RemoteToLocalSyncer::DidGetRemoteMetadata( | 409 void RemoteToLocalSyncer::DidGetRemoteMetadata( |
| 410 std::unique_ptr<SyncTaskToken> token, | 410 std::unique_ptr<SyncTaskToken> token, |
| 411 google_apis::DriveApiErrorCode error, | 411 google_apis::DriveApiErrorCode error, |
| 412 std::unique_ptr<google_apis::FileResource> entry) { | 412 std::unique_ptr<google_apis::FileResource> entry) { |
| 413 DCHECK(sync_context_->GetWorkerTaskRunner()->RunsTasksOnCurrentThread()); | 413 DCHECK(sync_context_->GetWorkerTaskRunner()->RunsTasksInCurrentSequence()); |
| 414 | 414 |
| 415 SyncStatusCode status = DriveApiErrorCodeToSyncStatusCode(error); | 415 SyncStatusCode status = DriveApiErrorCodeToSyncStatusCode(error); |
| 416 if (status != SYNC_STATUS_OK && | 416 if (status != SYNC_STATUS_OK && |
| 417 error != google_apis::HTTP_NOT_FOUND) { | 417 error != google_apis::HTTP_NOT_FOUND) { |
| 418 SyncCompleted(std::move(token), status); | 418 SyncCompleted(std::move(token), status); |
| 419 return; | 419 return; |
| 420 } | 420 } |
| 421 | 421 |
| 422 if (error == google_apis::HTTP_NOT_FOUND) { | 422 if (error == google_apis::HTTP_NOT_FOUND) { |
| 423 status = metadata_database()->UpdateByDeletedRemoteFile( | 423 status = metadata_database()->UpdateByDeletedRemoteFile( |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 777 } | 777 } |
| 778 | 778 |
| 779 void RemoteToLocalSyncer::DeleteLocalFile( | 779 void RemoteToLocalSyncer::DeleteLocalFile( |
| 780 std::unique_ptr<SyncTaskToken> token) { | 780 std::unique_ptr<SyncTaskToken> token) { |
| 781 remote_change_processor()->ApplyRemoteChange( | 781 remote_change_processor()->ApplyRemoteChange( |
| 782 FileChange(FileChange::FILE_CHANGE_DELETE, SYNC_FILE_TYPE_UNKNOWN), | 782 FileChange(FileChange::FILE_CHANGE_DELETE, SYNC_FILE_TYPE_UNKNOWN), |
| 783 base::FilePath(), url_, SyncCompletedCallback(std::move(token))); | 783 base::FilePath(), url_, SyncCompletedCallback(std::move(token))); |
| 784 } | 784 } |
| 785 | 785 |
| 786 void RemoteToLocalSyncer::DownloadFile(std::unique_ptr<SyncTaskToken> token) { | 786 void RemoteToLocalSyncer::DownloadFile(std::unique_ptr<SyncTaskToken> token) { |
| 787 DCHECK(sync_context_->GetWorkerTaskRunner()->RunsTasksOnCurrentThread()); | 787 DCHECK(sync_context_->GetWorkerTaskRunner()->RunsTasksInCurrentSequence()); |
| 788 | 788 |
| 789 storage::ScopedFile file = CreateTemporaryFile( | 789 storage::ScopedFile file = CreateTemporaryFile( |
| 790 make_scoped_refptr(sync_context_->GetWorkerTaskRunner())); | 790 make_scoped_refptr(sync_context_->GetWorkerTaskRunner())); |
| 791 | 791 |
| 792 base::FilePath path = file.path(); | 792 base::FilePath path = file.path(); |
| 793 drive_service()->DownloadFile( | 793 drive_service()->DownloadFile( |
| 794 path, remote_metadata_->file_id(), | 794 path, remote_metadata_->file_id(), |
| 795 base::Bind(&RemoteToLocalSyncer::DidDownloadFile, | 795 base::Bind(&RemoteToLocalSyncer::DidDownloadFile, |
| 796 weak_ptr_factory_.GetWeakPtr(), | 796 weak_ptr_factory_.GetWeakPtr(), |
| 797 base::Passed(&token), base::Passed(&file)), | 797 base::Passed(&token), base::Passed(&file)), |
| 798 google_apis::GetContentCallback(), | 798 google_apis::GetContentCallback(), |
| 799 google_apis::ProgressCallback()); | 799 google_apis::ProgressCallback()); |
| 800 } | 800 } |
| 801 | 801 |
| 802 void RemoteToLocalSyncer::DidDownloadFile(std::unique_ptr<SyncTaskToken> token, | 802 void RemoteToLocalSyncer::DidDownloadFile(std::unique_ptr<SyncTaskToken> token, |
| 803 storage::ScopedFile file, | 803 storage::ScopedFile file, |
| 804 google_apis::DriveApiErrorCode error, | 804 google_apis::DriveApiErrorCode error, |
| 805 const base::FilePath&) { | 805 const base::FilePath&) { |
| 806 DCHECK(sync_context_->GetWorkerTaskRunner()->RunsTasksOnCurrentThread()); | 806 DCHECK(sync_context_->GetWorkerTaskRunner()->RunsTasksInCurrentSequence()); |
| 807 | 807 |
| 808 SyncStatusCode status = DriveApiErrorCodeToSyncStatusCode(error); | 808 SyncStatusCode status = DriveApiErrorCodeToSyncStatusCode(error); |
| 809 if (status != SYNC_STATUS_OK) { | 809 if (status != SYNC_STATUS_OK) { |
| 810 SyncCompleted(std::move(token), status); | 810 SyncCompleted(std::move(token), status); |
| 811 return; | 811 return; |
| 812 } | 812 } |
| 813 | 813 |
| 814 base::FilePath path = file.path(); | 814 base::FilePath path = file.path(); |
| 815 const std::string md5 = drive::util::GetMd5Digest(path, nullptr); | 815 const std::string md5 = drive::util::GetMd5Digest(path, nullptr); |
| 816 if (md5.empty()) { | 816 if (md5.empty()) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 860 | 860 |
| 861 SyncStatusCallback RemoteToLocalSyncer::SyncCompletedCallback( | 861 SyncStatusCallback RemoteToLocalSyncer::SyncCompletedCallback( |
| 862 std::unique_ptr<SyncTaskToken> token) { | 862 std::unique_ptr<SyncTaskToken> token) { |
| 863 return base::Bind(&RemoteToLocalSyncer::SyncCompleted, | 863 return base::Bind(&RemoteToLocalSyncer::SyncCompleted, |
| 864 weak_ptr_factory_.GetWeakPtr(), | 864 weak_ptr_factory_.GetWeakPtr(), |
| 865 base::Passed(&token)); | 865 base::Passed(&token)); |
| 866 } | 866 } |
| 867 | 867 |
| 868 } // namespace drive_backend | 868 } // namespace drive_backend |
| 869 } // namespace sync_file_system | 869 } // namespace sync_file_system |
| OLD | NEW |