OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/google_apis/gdata_operations.h" | 5 #include "chrome/browser/google_apis/gdata_operations.h" |
6 | 6 |
7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/google_apis/gdata_util.h" | 10 #include "chrome/browser/google_apis/gdata_util.h" |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 //============================ DownloadFileOperation =========================== | 287 //============================ DownloadFileOperation =========================== |
288 | 288 |
289 DownloadFileOperation::DownloadFileOperation( | 289 DownloadFileOperation::DownloadFileOperation( |
290 OperationRegistry* registry, | 290 OperationRegistry* registry, |
291 const DownloadActionCallback& download_action_callback, | 291 const DownloadActionCallback& download_action_callback, |
292 const GetContentCallback& get_content_callback, | 292 const GetContentCallback& get_content_callback, |
293 const GURL& document_url, | 293 const GURL& document_url, |
294 const FilePath& virtual_path, | 294 const FilePath& virtual_path, |
295 const FilePath& output_file_path) | 295 const FilePath& output_file_path) |
296 : UrlFetchOperationBase(registry, | 296 : UrlFetchOperationBase(registry, |
297 OperationRegistry::OPERATION_DOWNLOAD, | 297 OPERATION_DOWNLOAD, |
298 virtual_path), | 298 virtual_path), |
299 download_action_callback_(download_action_callback), | 299 download_action_callback_(download_action_callback), |
300 get_content_callback_(get_content_callback), | 300 get_content_callback_(get_content_callback), |
301 document_url_(document_url) { | 301 document_url_(document_url) { |
302 // Make sure we download the content into a temp file. | 302 // Make sure we download the content into a temp file. |
303 if (output_file_path.empty()) | 303 if (output_file_path.empty()) |
304 save_temp_file_ = true; | 304 save_temp_file_ = true; |
305 else | 305 else |
306 output_file_path_ = output_file_path; | 306 output_file_path_ = output_file_path; |
307 } | 307 } |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 return headers; | 683 return headers; |
684 } | 684 } |
685 | 685 |
686 //=========================== InitiateUploadOperation ========================== | 686 //=========================== InitiateUploadOperation ========================== |
687 | 687 |
688 InitiateUploadOperation::InitiateUploadOperation( | 688 InitiateUploadOperation::InitiateUploadOperation( |
689 OperationRegistry* registry, | 689 OperationRegistry* registry, |
690 const InitiateUploadCallback& callback, | 690 const InitiateUploadCallback& callback, |
691 const InitiateUploadParams& params) | 691 const InitiateUploadParams& params) |
692 : UrlFetchOperationBase(registry, | 692 : UrlFetchOperationBase(registry, |
693 OperationRegistry::OPERATION_UPLOAD, | 693 OPERATION_UPLOAD, |
694 params.virtual_path), | 694 params.virtual_path), |
695 callback_(callback), | 695 callback_(callback), |
696 params_(params), | 696 params_(params), |
697 initiate_upload_url_(chrome_common_net::AppendOrReplaceQueryParameter( | 697 initiate_upload_url_(chrome_common_net::AppendOrReplaceQueryParameter( |
698 params.upload_location, | 698 params.upload_location, |
699 kUploadParamConvertKey, | 699 kUploadParamConvertKey, |
700 kUploadParamConvertValue)) { | 700 kUploadParamConvertValue)) { |
701 } | 701 } |
702 | 702 |
703 InitiateUploadOperation::~InitiateUploadOperation() {} | 703 InitiateUploadOperation::~InitiateUploadOperation() {} |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 return true; | 788 return true; |
789 } | 789 } |
790 | 790 |
791 //============================ ResumeUploadOperation =========================== | 791 //============================ ResumeUploadOperation =========================== |
792 | 792 |
793 ResumeUploadOperation::ResumeUploadOperation( | 793 ResumeUploadOperation::ResumeUploadOperation( |
794 OperationRegistry* registry, | 794 OperationRegistry* registry, |
795 const ResumeUploadCallback& callback, | 795 const ResumeUploadCallback& callback, |
796 const ResumeUploadParams& params) | 796 const ResumeUploadParams& params) |
797 : UrlFetchOperationBase(registry, | 797 : UrlFetchOperationBase(registry, |
798 OperationRegistry::OPERATION_UPLOAD, | 798 OPERATION_UPLOAD, |
799 params.virtual_path), | 799 params.virtual_path), |
800 callback_(callback), | 800 callback_(callback), |
801 params_(params), | 801 params_(params), |
802 last_chunk_completed_(false) { | 802 last_chunk_completed_(false) { |
803 } | 803 } |
804 | 804 |
805 ResumeUploadOperation::~ResumeUploadOperation() {} | 805 ResumeUploadOperation::~ResumeUploadOperation() {} |
806 | 806 |
807 GURL ResumeUploadOperation::GetURL() const { | 807 GURL ResumeUploadOperation::GetURL() const { |
808 return params_.upload_location; | 808 return params_.upload_location; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
872 OnProcessURLFetchResultsComplete( | 872 OnProcessURLFetchResultsComplete( |
873 last_chunk_completed_ || code == HTTP_RESUME_INCOMPLETE); | 873 last_chunk_completed_ || code == HTTP_RESUME_INCOMPLETE); |
874 } | 874 } |
875 | 875 |
876 void ResumeUploadOperation::NotifyStartToOperationRegistry() { | 876 void ResumeUploadOperation::NotifyStartToOperationRegistry() { |
877 NotifyResume(); | 877 NotifyResume(); |
878 } | 878 } |
879 | 879 |
880 void ResumeUploadOperation::NotifySuccessToOperationRegistry() { | 880 void ResumeUploadOperation::NotifySuccessToOperationRegistry() { |
881 if (last_chunk_completed_) | 881 if (last_chunk_completed_) |
882 NotifyFinish(OperationRegistry::OPERATION_COMPLETED); | 882 NotifyFinish(OPERATION_COMPLETED); |
883 else | 883 else |
884 NotifySuspend(); | 884 NotifySuspend(); |
885 } | 885 } |
886 | 886 |
887 void ResumeUploadOperation::RunCallbackOnPrematureFailure(GDataErrorCode code) { | 887 void ResumeUploadOperation::RunCallbackOnPrematureFailure(GDataErrorCode code) { |
888 scoped_ptr<DocumentEntry> entry; | 888 scoped_ptr<DocumentEntry> entry; |
889 if (!callback_.is_null()) | 889 if (!callback_.is_null()) |
890 callback_.Run(ResumeUploadResponse(code, 0, 0), entry.Pass()); | 890 callback_.Run(ResumeUploadResponse(code, 0, 0), entry.Pass()); |
891 } | 891 } |
892 | 892 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1008 OnProcessURLFetchResultsComplete(code == HTTP_SUCCESS); | 1008 OnProcessURLFetchResultsComplete(code == HTTP_SUCCESS); |
1009 } | 1009 } |
1010 | 1010 |
1011 void GetContactPhotoOperation::RunCallbackOnPrematureFailure( | 1011 void GetContactPhotoOperation::RunCallbackOnPrematureFailure( |
1012 GDataErrorCode code) { | 1012 GDataErrorCode code) { |
1013 scoped_ptr<std::string> data(new std::string); | 1013 scoped_ptr<std::string> data(new std::string); |
1014 callback_.Run(code, data.Pass()); | 1014 callback_.Run(code, data.Pass()); |
1015 } | 1015 } |
1016 | 1016 |
1017 } // namespace gdata | 1017 } // namespace gdata |
OLD | NEW |