| Index: components/cronet/android/url_request_adapter.cc
|
| diff --git a/components/cronet/android/url_request_adapter.cc b/components/cronet/android/url_request_adapter.cc
|
| index 8ab88a2f3cd766629e0033c3f231381992528f13..b2beefa63a5713e915f7aad2337ac40b10f0ea5a 100644
|
| --- a/components/cronet/android/url_request_adapter.cc
|
| +++ b/components/cronet/android/url_request_adapter.cc
|
| @@ -27,7 +27,8 @@ URLRequestAdapter::URLRequestAdapter(URLRequestContextAdapter* context,
|
| error_code_(0),
|
| http_status_code_(0),
|
| canceled_(false),
|
| - expected_size_(0) {
|
| + expected_size_(0),
|
| + chunked_upload_(false) {
|
| context_ = context;
|
| delegate_ = delegate;
|
| url_ = url;
|
| @@ -62,6 +63,23 @@ void URLRequestAdapter::SetUploadChannel(JNIEnv* env, int64 content_length) {
|
| net::UploadDataStream::CreateWithReader(reader.Pass(), 0));
|
| }
|
|
|
| +void URLRequestAdapter::EnableChunkedUpload() {
|
| + chunked_upload_ = true;
|
| +}
|
| +
|
| +void URLRequestAdapter::AppendChunkToUpload(const char* bytes,
|
| + int bytes_len,
|
| + bool is_last_chunk) {
|
| + VLOG(1) << "AppendChunk, len: " << bytes_len << ", last: " << is_last_chunk;
|
| + context_->GetNetworkTaskRunner()->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(&URLRequestAdapter::OnAppendChunk,
|
| + base::Unretained(this),
|
| + bytes,
|
| + bytes_len,
|
| + is_last_chunk));
|
| +}
|
| +
|
| std::string URLRequestAdapter::GetHeader(const std::string& name) const {
|
| std::string value;
|
| if (url_request_ != NULL) {
|
| @@ -84,6 +102,15 @@ void URLRequestAdapter::Start() {
|
| base::Unretained(this)));
|
| }
|
|
|
| +void URLRequestAdapter::OnAppendChunk(const char* bytes,
|
| + int bytes_len,
|
| + bool is_last_chunk) {
|
| + if (url_request_ != NULL) {
|
| + url_request_->AppendChunkToUpload(bytes, bytes_len, is_last_chunk);
|
| + delegate_->OnAppendChunkCompleted(this);
|
| + }
|
| +}
|
| +
|
| void URLRequestAdapter::OnInitiateConnection() {
|
| if (canceled_) {
|
| return;
|
| @@ -106,8 +133,11 @@ void URLRequestAdapter::OnInitiateConnection() {
|
| net::HttpRequestHeaders::kUserAgent, user_agent, true /* override */);
|
| }
|
|
|
| - if (upload_data_stream_)
|
| + if (upload_data_stream_) {
|
| url_request_->set_upload(upload_data_stream_.Pass());
|
| + } else if (chunked_upload_) {
|
| + url_request_->EnableChunkedUpload();
|
| + }
|
|
|
| url_request_->SetPriority(priority_);
|
|
|
|
|