| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "url_request_adapter.h" | 5 #include "url_request_adapter.h" |
| 6 | 6 |
| 7 #include <stddef.h> |
| 7 #include <string.h> | 8 #include <string.h> |
| 8 | 9 |
| 9 #include "base/bind.h" | 10 #include "base/bind.h" |
| 10 #include "base/location.h" | 11 #include "base/location.h" |
| 11 #include "base/logging.h" | 12 #include "base/logging.h" |
| 12 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 13 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 14 #include "components/cronet/android/url_request_context_adapter.h" | 15 #include "components/cronet/android/url_request_context_adapter.h" |
| 15 #include "components/cronet/android/wrapped_channel_upload_element_reader.h" | 16 #include "components/cronet/android/wrapped_channel_upload_element_reader.h" |
| 16 #include "net/base/elements_upload_data_stream.h" | 17 #include "net/base/elements_upload_data_stream.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 } | 58 } |
| 58 | 59 |
| 59 void URLRequestAdapter::SetUploadContent(const char* bytes, int bytes_len) { | 60 void URLRequestAdapter::SetUploadContent(const char* bytes, int bytes_len) { |
| 60 std::vector<char> data(bytes, bytes + bytes_len); | 61 std::vector<char> data(bytes, bytes + bytes_len); |
| 61 scoped_ptr<net::UploadElementReader> reader( | 62 scoped_ptr<net::UploadElementReader> reader( |
| 62 new net::UploadOwnedBytesElementReader(&data)); | 63 new net::UploadOwnedBytesElementReader(&data)); |
| 63 upload_data_stream_ = | 64 upload_data_stream_ = |
| 64 net::ElementsUploadDataStream::CreateWithReader(reader.Pass(), 0); | 65 net::ElementsUploadDataStream::CreateWithReader(reader.Pass(), 0); |
| 65 } | 66 } |
| 66 | 67 |
| 67 void URLRequestAdapter::SetUploadChannel(JNIEnv* env, int64 content_length) { | 68 void URLRequestAdapter::SetUploadChannel(JNIEnv* env, int64_t content_length) { |
| 68 scoped_ptr<net::UploadElementReader> reader( | 69 scoped_ptr<net::UploadElementReader> reader( |
| 69 new WrappedChannelElementReader(delegate_, content_length)); | 70 new WrappedChannelElementReader(delegate_, content_length)); |
| 70 upload_data_stream_ = | 71 upload_data_stream_ = |
| 71 net::ElementsUploadDataStream::CreateWithReader(reader.Pass(), 0); | 72 net::ElementsUploadDataStream::CreateWithReader(reader.Pass(), 0); |
| 72 } | 73 } |
| 73 | 74 |
| 74 void URLRequestAdapter::DisableRedirects() { | 75 void URLRequestAdapter::DisableRedirects() { |
| 75 disable_redirect_ = true; | 76 disable_redirect_ = true; |
| 76 } | 77 } |
| 77 | 78 |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 unsigned char* URLRequestAdapter::Data() const { | 320 unsigned char* URLRequestAdapter::Data() const { |
| 320 DCHECK(OnNetworkThread()); | 321 DCHECK(OnNetworkThread()); |
| 321 return reinterpret_cast<unsigned char*>(read_buffer_->data()); | 322 return reinterpret_cast<unsigned char*>(read_buffer_->data()); |
| 322 } | 323 } |
| 323 | 324 |
| 324 bool URLRequestAdapter::OnNetworkThread() const { | 325 bool URLRequestAdapter::OnNetworkThread() const { |
| 325 return context_->GetNetworkTaskRunner()->BelongsToCurrentThread(); | 326 return context_->GetNetworkTaskRunner()->BelongsToCurrentThread(); |
| 326 } | 327 } |
| 327 | 328 |
| 328 } // namespace cronet | 329 } // namespace cronet |
| OLD | NEW |