Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: components/cronet/android/url_request_peer.cc

Issue 442803002: Remove explicit JNI references by adding UrlRequest.readFromUploadChannel callback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove spurious space. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_peer.h" 5 #include "url_request_peer.h"
6 6
7 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "components/cronet/android/url_request_context_peer.h" 8 #include "components/cronet/android/url_request_context_peer.h"
9 #include "components/cronet/android/wrapped_channel_upload_element_reader.h" 9 #include "components/cronet/android/wrapped_channel_upload_element_reader.h"
10 #include "net/base/load_flags.h" 10 #include "net/base/load_flags.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 } 44 }
45 45
46 void URLRequestPeer::SetUploadContent(const char* bytes, int bytes_len) { 46 void URLRequestPeer::SetUploadContent(const char* bytes, int bytes_len) {
47 std::vector<char> data(bytes, bytes + bytes_len); 47 std::vector<char> data(bytes, bytes + bytes_len);
48 scoped_ptr<net::UploadElementReader> reader( 48 scoped_ptr<net::UploadElementReader> reader(
49 new net::UploadOwnedBytesElementReader(&data)); 49 new net::UploadOwnedBytesElementReader(&data));
50 upload_data_stream_.reset(net::UploadDataStream::CreateWithReader( 50 upload_data_stream_.reset(net::UploadDataStream::CreateWithReader(
51 reader.Pass(), 0)); 51 reader.Pass(), 0));
52 } 52 }
53 53
54 void URLRequestPeer::SetUploadChannel( 54 void URLRequestPeer::SetUploadChannel(JNIEnv* env, int64 content_length) {
55 JNIEnv* env, jobject channel, int64 content_length) {
56 scoped_ptr<net::UploadElementReader> reader( 55 scoped_ptr<net::UploadElementReader> reader(
57 new WrappedChannelElementReader(env, channel, content_length)); 56 new WrappedChannelElementReader(delegate_, content_length));
58 upload_data_stream_.reset(net::UploadDataStream::CreateWithReader( 57 upload_data_stream_.reset(net::UploadDataStream::CreateWithReader(
59 reader.Pass(), 0)); 58 reader.Pass(), 0));
60 } 59 }
61 60
62 std::string URLRequestPeer::GetHeader(const std::string &name) const { 61 std::string URLRequestPeer::GetHeader(const std::string &name) const {
63 std::string value; 62 std::string value;
64 if (url_request_ != NULL) { 63 if (url_request_ != NULL) {
65 url_request_->GetResponseHeaderByName(name, &value); 64 url_request_->GetResponseHeaderByName(name, &value);
66 } 65 }
67 return value; 66 return value;
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 249
251 delegate_->OnBytesRead(this); 250 delegate_->OnBytesRead(this);
252 delegate_->OnRequestFinished(this); 251 delegate_->OnRequestFinished(this);
253 } 252 }
254 253
255 unsigned char* URLRequestPeer::Data() const { 254 unsigned char* URLRequestPeer::Data() const {
256 return reinterpret_cast<unsigned char*>(read_buffer_->StartOfBuffer()); 255 return reinterpret_cast<unsigned char*>(read_buffer_->StartOfBuffer());
257 } 256 }
258 257
259 } // namespace cronet 258 } // namespace cronet
OLDNEW
« no previous file with comments | « components/cronet/android/url_request_peer.h ('k') | components/cronet/android/wrapped_channel_upload_element_reader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698