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/api_util.h" | 5 #include "chrome/browser/sync_file_system/drive_backend/api_util.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <sstream> | 9 #include <sstream> |
10 #include <string> | 10 #include <string> |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
480 base::Bind(&APIUtil::DidGetResourceList, AsWeakPtr(), callback)); | 480 base::Bind(&APIUtil::DidGetResourceList, AsWeakPtr(), callback)); |
481 } | 481 } |
482 | 482 |
483 void APIUtil::DownloadFile(const std::string& resource_id, | 483 void APIUtil::DownloadFile(const std::string& resource_id, |
484 const std::string& local_file_md5, | 484 const std::string& local_file_md5, |
485 const base::FilePath& local_file_path, | 485 const base::FilePath& local_file_path, |
486 const DownloadFileCallback& callback) { | 486 const DownloadFileCallback& callback) { |
487 DCHECK(CalledOnValidThread()); | 487 DCHECK(CalledOnValidThread()); |
488 DVLOG(2) << "Downloading file [" << resource_id << "]"; | 488 DVLOG(2) << "Downloading file [" << resource_id << "]"; |
489 | 489 |
490 drive_service_->GetResourceEntry( | 490 drive_service_->GetResourceEntry( |
tzik
2013/07/02 12:34:27
If |local_file_md5| is empty, we might able to ski
kinaba
2013/07/02 13:15:09
yeah, the same goes for Drive side as well.
Can I
kinaba
2013/07/03 02:18:56
Fm, I also thought this is possible, but it turned
tzik
2013/07/03 02:40:42
Hmm, right it's not trivial.
OK, please leave it a
| |
491 resource_id, | 491 resource_id, |
492 base::Bind(&APIUtil::DidGetResourceEntry, | 492 base::Bind(&APIUtil::DidGetResourceEntry, |
493 AsWeakPtr(), | 493 AsWeakPtr(), |
494 base::Bind(&APIUtil::DownloadFileInternal, | 494 base::Bind(&APIUtil::DownloadFileInternal, |
495 AsWeakPtr(), | 495 AsWeakPtr(), |
496 local_file_md5, | 496 local_file_md5, |
497 local_file_path, | 497 local_file_path, |
498 callback))); | 498 callback))); |
499 } | 499 } |
500 | 500 |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
716 // If local file and remote file are same, cancel the download. | 716 // If local file and remote file are same, cancel the download. |
717 if (local_file_md5 == entry->file_md5()) { | 717 if (local_file_md5 == entry->file_md5()) { |
718 callback.Run(google_apis::HTTP_NOT_MODIFIED, | 718 callback.Run(google_apis::HTTP_NOT_MODIFIED, |
719 local_file_md5, | 719 local_file_md5, |
720 entry->file_size(), | 720 entry->file_size(), |
721 entry->updated_time()); | 721 entry->updated_time()); |
722 return; | 722 return; |
723 } | 723 } |
724 | 724 |
725 DVLOG(2) << "Downloading file: " << entry->resource_id(); | 725 DVLOG(2) << "Downloading file: " << entry->resource_id(); |
726 const GURL& download_url = entry->download_url(); | 726 const std::string& resource_id = entry->resource_id(); |
727 drive_service_->DownloadFile(local_file_path, | 727 drive_service_->DownloadFile(local_file_path, |
728 download_url, | 728 resource_id, |
729 base::Bind(&APIUtil::DidDownloadFile, | 729 base::Bind(&APIUtil::DidDownloadFile, |
730 AsWeakPtr(), | 730 AsWeakPtr(), |
731 base::Passed(&entry), | 731 base::Passed(&entry), |
732 callback), | 732 callback), |
733 google_apis::GetContentCallback(), | 733 google_apis::GetContentCallback(), |
734 google_apis::ProgressCallback()); | 734 google_apis::ProgressCallback()); |
735 } | 735 } |
736 | 736 |
737 void APIUtil::DidDownloadFile(scoped_ptr<google_apis::ResourceEntry> entry, | 737 void APIUtil::DidDownloadFile(scoped_ptr<google_apis::ResourceEntry> entry, |
738 const DownloadFileCallback& callback, | 738 const DownloadFileCallback& callback, |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1076 } | 1076 } |
1077 | 1077 |
1078 std::string APIUtil::GetRootResourceId() const { | 1078 std::string APIUtil::GetRootResourceId() const { |
1079 if (IsDriveAPIDisabled()) | 1079 if (IsDriveAPIDisabled()) |
1080 return drive_service_->GetRootResourceId(); | 1080 return drive_service_->GetRootResourceId(); |
1081 return root_resource_id_; | 1081 return root_resource_id_; |
1082 } | 1082 } |
1083 | 1083 |
1084 } // namespace drive_backend | 1084 } // namespace drive_backend |
1085 } // namespace sync_file_system | 1085 } // namespace sync_file_system |
OLD | NEW |