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

Unified Diff: components/cronet/android/org_chromium_net_UrlRequest.cc

Issue 442803002: Remove explicit JNI references by adding UrlRequest.readFromUploadChannel callback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . 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 side-by-side diff with in-line comments
Download patch
Index: components/cronet/android/org_chromium_net_UrlRequest.cc
diff --git a/components/cronet/android/org_chromium_net_UrlRequest.cc b/components/cronet/android/org_chromium_net_UrlRequest.cc
index 8ec8b7abdac5f64bba367abcd9204a9b1753de37..e94e853a1c48c8cc76c11c63468ec71cd19fbb6b 100644
--- a/components/cronet/android/org_chromium_net_UrlRequest.cc
+++ b/components/cronet/android/org_chromium_net_UrlRequest.cc
@@ -81,6 +81,16 @@ class JniURLRequestPeerDelegate
cronet::Java_UrlRequest_finish(env, owner_);
}
+ virtual int OnReadUploadData(net::IOBuffer* buf, int buf_length) {
mmenke 2014/08/05 19:32:41 OVERRIDE
mef 2014/08/05 20:44:28 Done.
+ JNIEnv* env = base::android::AttachCurrentThread();
+ jobject jbuf = env->NewDirectByteBuffer(
mmenke 2014/08/05 19:32:41 jbuf seems to violate the C++ style guide - I'd su
mef 2014/08/05 20:44:28 Done.
+ reinterpret_cast<void*>(buf->data()), buf_length);
+ jint bytes_read =
+ cronet::Java_UrlRequest_onReadUploadChannel(env, owner_, jbuf);
+ env->DeleteLocalRef(jbuf);
mmenke 2014/08/05 19:32:41 Is this call actually needed? Seems like it's not
mef 2014/08/05 20:44:28 IIUIC this is explicit refcounting, so we have to
mmenke 2014/08/05 21:08:02 Hrm...I missed that ,ost use ScopedJavaLocalRef, w
mef 2014/08/05 21:38:45 Done.
+ return bytes_read;
+ }
+
protected:
virtual ~JniURLRequestPeerDelegate() {
JNIEnv* env = base::android::AttachCurrentThread();
@@ -176,12 +186,11 @@ static void SetUploadChannel(JNIEnv* env,
jobject object,
jlong urlRequestPeer,
jstring content_type,
- jobject content,
jlong content_length) {
URLRequestPeer* request = reinterpret_cast<URLRequestPeer*>(urlRequestPeer);
SetPostContentType(env, request, content_type);
- request->SetUploadChannel(env, content, content_length);
+ request->SetUploadChannel(env, content_length);
}

Powered by Google App Engine
This is Rietveld 408576698