Chromium Code Reviews| Index: net/url_request/url_fetcher_core.cc |
| diff --git a/net/url_request/url_fetcher_core.cc b/net/url_request/url_fetcher_core.cc |
| index fc218835646f018556ec3916ecb20f937126e4de..049d481b0d6674881ba149e69f1e8522471be607 100644 |
| --- a/net/url_request/url_fetcher_core.cc |
| +++ b/net/url_request/url_fetcher_core.cc |
| @@ -338,17 +338,27 @@ void URLFetcherCore::Stop() { |
| void URLFetcherCore::SetUploadData(const std::string& upload_content_type, |
| const std::string& upload_content) { |
| + scoped_ptr<UploadElementReader> reader( |
| + UploadOwnedBytesElementReader::CreateWithString(upload_content)); |
| + SetUploadDataStream( |
| + upload_content_type, |
| + make_scoped_ptr(UploadDataStream::CreateWithReader(reader.Pass(), 0))); |
| +} |
| + |
| +void URLFetcherCore::SetUploadDataStream( |
| + const std::string& upload_content_type, |
| + scoped_ptr<UploadDataStream> upload_content) { |
| DCHECK(!is_chunked_upload_); |
|
mmenke
2013/01/11 16:25:40
DCHECK(!upload_content);
Also maybe DCHECK(upload
mattm
2013/01/11 21:42:02
Done.
|
| upload_content_type_ = upload_content_type; |
| - upload_content_ = upload_content; |
| + upload_content_ = upload_content.Pass(); |
| } |
| void URLFetcherCore::SetChunkedUpload(const std::string& content_type) { |
| DCHECK(is_chunked_upload_ || |
| (upload_content_type_.empty() && |
| - upload_content_.empty())); |
| + !upload_content_)); |
| upload_content_type_ = content_type; |
| - upload_content_.clear(); |
| + upload_content_.reset(); |
| is_chunked_upload_ = true; |
| } |
| @@ -738,13 +748,8 @@ void URLFetcherCore::StartURLRequest() { |
| request_type_ == URLFetcher::POST ? "POST" : "PUT"); |
| extra_request_headers_.SetHeader(HttpRequestHeaders::kContentType, |
| upload_content_type_); |
| - if (!upload_content_.empty()) { |
| - scoped_ptr<UploadElementReader> reader(new UploadBytesElementReader( |
| - upload_content_.data(), upload_content_.size())); |
| - request_->set_upload(make_scoped_ptr( |
| - UploadDataStream::CreateWithReader(reader.Pass(), 0))); |
| - } |
| - |
| + if (upload_content_) |
| + request_->set_upload(upload_content_.Pass()); |
| current_upload_bytes_ = -1; |
| // TODO(kinaba): http://crbug.com/118103. Implement upload callback in the |
| // layer and avoid using timer here. |
| @@ -1017,7 +1022,7 @@ void URLFetcherCore::InformDelegateUploadProgress() { |
| current_upload_bytes_ = current; |
| int64 total = -1; |
| if (!is_chunked_upload_) |
| - total = static_cast<int64>(upload_content_.size()); |
| + total = static_cast<int64>(request_->get_upload()->size()); |
|
hashimoto
2013/01/11 06:07:38
This change introduces a little difference to the
mattm
2013/01/11 21:42:02
Done.
|
| delegate_task_runner_->PostTask( |
| FROM_HERE, |
| base::Bind( |