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/local_to_remote_syncer.h
" | 5 #include "chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer.h
" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 } | 491 } |
492 | 492 |
493 SyncCompleted(token.Pass(), SYNC_STATUS_OK); | 493 SyncCompleted(token.Pass(), SYNC_STATUS_OK); |
494 } | 494 } |
495 | 495 |
496 void LocalToRemoteSyncer::UploadExistingFile(scoped_ptr<SyncTaskToken> token) { | 496 void LocalToRemoteSyncer::UploadExistingFile(scoped_ptr<SyncTaskToken> token) { |
497 DCHECK(remote_file_tracker_); | 497 DCHECK(remote_file_tracker_); |
498 DCHECK(remote_file_tracker_->has_synced_details()); | 498 DCHECK(remote_file_tracker_->has_synced_details()); |
499 DCHECK(sync_context_->GetWorkerTaskRunner()->RunsTasksOnCurrentThread()); | 499 DCHECK(sync_context_->GetWorkerTaskRunner()->RunsTasksOnCurrentThread()); |
500 | 500 |
501 base::Callback<void(const std::string&)> did_calculate_callback = | 501 const std::string local_file_md5 = drive::util::GetMd5Digest(local_path_); |
502 base::Bind(&LocalToRemoteSyncer::DidGetMD5ForUpload, | |
503 weak_ptr_factory_.GetWeakPtr(), base::Passed(&token)); | |
504 | |
505 sync_context_->GetFileTaskRunner()->PostTask( | |
506 FROM_HERE, | |
507 CreateComposedFunction( | |
508 base::Bind(&drive::util::GetMd5Digest, local_path_), | |
509 RelayCallbackToTaskRunner( | |
510 sync_context_->GetWorkerTaskRunner(), FROM_HERE, | |
511 did_calculate_callback))); | |
512 } | |
513 | |
514 void LocalToRemoteSyncer::DidGetMD5ForUpload( | |
515 scoped_ptr<SyncTaskToken> token, | |
516 const std::string& local_file_md5) { | |
517 if (local_file_md5 == remote_file_tracker_->synced_details().md5()) { | 502 if (local_file_md5 == remote_file_tracker_->synced_details().md5()) { |
518 // Local file is not changed. | 503 // Local file is not changed. |
519 SyncCompleted(token.Pass(), SYNC_STATUS_OK); | 504 SyncCompleted(token.Pass(), SYNC_STATUS_OK); |
520 return; | 505 return; |
521 } | 506 } |
522 | 507 |
523 sync_action_ = SYNC_ACTION_UPDATED; | 508 sync_action_ = SYNC_ACTION_UPDATED; |
524 | 509 |
525 drive::DriveUploader::UploadExistingFileOptions options; | 510 drive::DriveUploader::UploadExistingFileOptions options; |
526 options.etag = remote_file_tracker_->synced_details().etag(); | 511 options.etag = remote_file_tracker_->synced_details().etag(); |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 set_used_network(true); | 773 set_used_network(true); |
789 return sync_context_->GetDriveUploader(); | 774 return sync_context_->GetDriveUploader(); |
790 } | 775 } |
791 | 776 |
792 MetadataDatabase* LocalToRemoteSyncer::metadata_database() { | 777 MetadataDatabase* LocalToRemoteSyncer::metadata_database() { |
793 return sync_context_->GetMetadataDatabase(); | 778 return sync_context_->GetMetadataDatabase(); |
794 } | 779 } |
795 | 780 |
796 } // namespace drive_backend | 781 } // namespace drive_backend |
797 } // namespace sync_file_system | 782 } // namespace sync_file_system |
OLD | NEW |