| 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 "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 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 | 393 |
| 394 drive_service()->GetFileResource( | 394 drive_service()->GetFileResource( |
| 395 dirty_tracker_->file_id(), | 395 dirty_tracker_->file_id(), |
| 396 base::Bind(&RemoteToLocalSyncer::DidGetRemoteMetadata, | 396 base::Bind(&RemoteToLocalSyncer::DidGetRemoteMetadata, |
| 397 weak_ptr_factory_.GetWeakPtr(), | 397 weak_ptr_factory_.GetWeakPtr(), |
| 398 base::Passed(&token))); | 398 base::Passed(&token))); |
| 399 } | 399 } |
| 400 | 400 |
| 401 void RemoteToLocalSyncer::DidGetRemoteMetadata( | 401 void RemoteToLocalSyncer::DidGetRemoteMetadata( |
| 402 scoped_ptr<SyncTaskToken> token, | 402 scoped_ptr<SyncTaskToken> token, |
| 403 google_apis::GDataErrorCode error, | 403 google_apis::DriveApiErrorCode error, |
| 404 scoped_ptr<google_apis::FileResource> entry) { | 404 scoped_ptr<google_apis::FileResource> entry) { |
| 405 DCHECK(sync_context_->GetWorkerTaskRunner()->RunsTasksOnCurrentThread()); | 405 DCHECK(sync_context_->GetWorkerTaskRunner()->RunsTasksOnCurrentThread()); |
| 406 | 406 |
| 407 SyncStatusCode status = GDataErrorCodeToSyncStatusCode(error); | 407 SyncStatusCode status = DriveApiErrorCodeToSyncStatusCode(error); |
| 408 if (status != SYNC_STATUS_OK && | 408 if (status != SYNC_STATUS_OK && |
| 409 error != google_apis::HTTP_NOT_FOUND) { | 409 error != google_apis::HTTP_NOT_FOUND) { |
| 410 SyncCompleted(token.Pass(), status); | 410 SyncCompleted(token.Pass(), status); |
| 411 return; | 411 return; |
| 412 } | 412 } |
| 413 | 413 |
| 414 if (error == google_apis::HTTP_NOT_FOUND) { | 414 if (error == google_apis::HTTP_NOT_FOUND) { |
| 415 status = metadata_database()->UpdateByDeletedRemoteFile( | 415 status = metadata_database()->UpdateByDeletedRemoteFile( |
| 416 dirty_tracker_->file_id()); | 416 dirty_tracker_->file_id()); |
| 417 SyncCompleted(token.Pass(), status); | 417 SyncCompleted(token.Pass(), status); |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 dirty_tracker_->file_id(), | 649 dirty_tracker_->file_id(), |
| 650 base::Bind(&RemoteToLocalSyncer::DidListFolderContent, | 650 base::Bind(&RemoteToLocalSyncer::DidListFolderContent, |
| 651 weak_ptr_factory_.GetWeakPtr(), | 651 weak_ptr_factory_.GetWeakPtr(), |
| 652 base::Passed(&token), | 652 base::Passed(&token), |
| 653 base::Passed(make_scoped_ptr(new FileIDList)))); | 653 base::Passed(make_scoped_ptr(new FileIDList)))); |
| 654 } | 654 } |
| 655 | 655 |
| 656 void RemoteToLocalSyncer::DidListFolderContent( | 656 void RemoteToLocalSyncer::DidListFolderContent( |
| 657 scoped_ptr<SyncTaskToken> token, | 657 scoped_ptr<SyncTaskToken> token, |
| 658 scoped_ptr<FileIDList> children, | 658 scoped_ptr<FileIDList> children, |
| 659 google_apis::GDataErrorCode error, | 659 google_apis::DriveApiErrorCode error, |
| 660 scoped_ptr<google_apis::FileList> file_list) { | 660 scoped_ptr<google_apis::FileList> file_list) { |
| 661 SyncStatusCode status = GDataErrorCodeToSyncStatusCode(error); | 661 SyncStatusCode status = DriveApiErrorCodeToSyncStatusCode(error); |
| 662 if (status != SYNC_STATUS_OK) { | 662 if (status != SYNC_STATUS_OK) { |
| 663 SyncCompleted(token.Pass(), status); | 663 SyncCompleted(token.Pass(), status); |
| 664 return; | 664 return; |
| 665 } | 665 } |
| 666 | 666 |
| 667 if (!file_list) { | 667 if (!file_list) { |
| 668 NOTREACHED(); | 668 NOTREACHED(); |
| 669 SyncCompleted(token.Pass(), SYNC_STATUS_FAILED); | 669 SyncCompleted(token.Pass(), SYNC_STATUS_FAILED); |
| 670 return; | 670 return; |
| 671 } | 671 } |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 path, remote_metadata_->file_id(), | 793 path, remote_metadata_->file_id(), |
| 794 base::Bind(&RemoteToLocalSyncer::DidDownloadFile, | 794 base::Bind(&RemoteToLocalSyncer::DidDownloadFile, |
| 795 weak_ptr_factory_.GetWeakPtr(), | 795 weak_ptr_factory_.GetWeakPtr(), |
| 796 base::Passed(&token), base::Passed(&file)), | 796 base::Passed(&token), base::Passed(&file)), |
| 797 google_apis::GetContentCallback(), | 797 google_apis::GetContentCallback(), |
| 798 google_apis::ProgressCallback()); | 798 google_apis::ProgressCallback()); |
| 799 } | 799 } |
| 800 | 800 |
| 801 void RemoteToLocalSyncer::DidDownloadFile(scoped_ptr<SyncTaskToken> token, | 801 void RemoteToLocalSyncer::DidDownloadFile(scoped_ptr<SyncTaskToken> token, |
| 802 storage::ScopedFile file, | 802 storage::ScopedFile file, |
| 803 google_apis::GDataErrorCode error, | 803 google_apis::DriveApiErrorCode error, |
| 804 const base::FilePath&) { | 804 const base::FilePath&) { |
| 805 DCHECK(sync_context_->GetWorkerTaskRunner()->RunsTasksOnCurrentThread()); | 805 DCHECK(sync_context_->GetWorkerTaskRunner()->RunsTasksOnCurrentThread()); |
| 806 | 806 |
| 807 SyncStatusCode status = GDataErrorCodeToSyncStatusCode(error); | 807 SyncStatusCode status = DriveApiErrorCodeToSyncStatusCode(error); |
| 808 if (status != SYNC_STATUS_OK) { | 808 if (status != SYNC_STATUS_OK) { |
| 809 SyncCompleted(token.Pass(), status); | 809 SyncCompleted(token.Pass(), status); |
| 810 return; | 810 return; |
| 811 } | 811 } |
| 812 | 812 |
| 813 base::FilePath path = file.path(); | 813 base::FilePath path = file.path(); |
| 814 const std::string md5 = drive::util::GetMd5Digest(path); | 814 const std::string md5 = drive::util::GetMd5Digest(path); |
| 815 if (md5.empty()) { | 815 if (md5.empty()) { |
| 816 SyncCompleted(token.Pass(), SYNC_FILE_ERROR_NOT_FOUND); | 816 SyncCompleted(token.Pass(), SYNC_FILE_ERROR_NOT_FOUND); |
| 817 return; | 817 return; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 860 | 860 |
| 861 SyncStatusCallback RemoteToLocalSyncer::SyncCompletedCallback( | 861 SyncStatusCallback RemoteToLocalSyncer::SyncCompletedCallback( |
| 862 scoped_ptr<SyncTaskToken> token) { | 862 scoped_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 |