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_wapi_operations.h" | 5 #include "chrome/browser/google_apis/gdata_wapi_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_wapi_parser.h" | 10 #include "chrome/browser/google_apis/gdata_wapi_parser.h" |
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
778 *upload_content = std::string(buf_->data(), end_position_ - start_position_); | 778 *upload_content = std::string(buf_->data(), end_position_ - start_position_); |
779 return true; | 779 return true; |
780 } | 780 } |
781 | 781 |
782 void ResumeUploadOperation::OnURLFetchUploadProgress( | 782 void ResumeUploadOperation::OnURLFetchUploadProgress( |
783 const URLFetcher* source, int64 current, int64 total) { | 783 const URLFetcher* source, int64 current, int64 total) { |
784 // Adjust the progress values according to the range currently uploaded. | 784 // Adjust the progress values according to the range currently uploaded. |
785 NotifyProgress(start_position_ + current, content_length_); | 785 NotifyProgress(start_position_ + current, content_length_); |
786 } | 786 } |
787 | 787 |
| 788 //========================== GetUploadStatusOperation ========================== |
| 789 |
| 790 GetUploadStatusOperation::GetUploadStatusOperation( |
| 791 OperationRegistry* registry, |
| 792 net::URLRequestContextGetter* url_request_context_getter, |
| 793 const UploadRangeCallback& callback, |
| 794 UploadMode upload_mode, |
| 795 const FilePath& drive_file_path, |
| 796 const GURL& upload_url, |
| 797 int64 content_length) |
| 798 : UploadRangeOperationBase(registry, |
| 799 url_request_context_getter, |
| 800 callback, |
| 801 upload_mode, |
| 802 drive_file_path, |
| 803 upload_url), |
| 804 content_length_(content_length) {} |
| 805 |
| 806 GetUploadStatusOperation::~GetUploadStatusOperation() {} |
| 807 |
| 808 std::vector<std::string> |
| 809 GetUploadStatusOperation::GetExtraRequestHeaders() const { |
| 810 // The header looks like |
| 811 // Content-Range: bytes */<content_length> |
| 812 // for example: |
| 813 // Content-Range: bytes */13851821 |
| 814 // Use * for unknown/streaming content length, such as |
| 815 // Content-Range: bytes */* |
| 816 DCHECK_GE(content_length_, -1); |
| 817 |
| 818 std::vector<std::string> headers; |
| 819 headers.push_back( |
| 820 std::string(kUploadContentRange) + "*/" + |
| 821 (content_length_ == -1 ? "*" : base::Int64ToString(content_length_))); |
| 822 return headers; |
| 823 } |
| 824 |
788 } // namespace google_apis | 825 } // namespace google_apis |
OLD | NEW |