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

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

Issue 536023003: Fix crash in Cronet CreateUrlRequestAdapter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « no previous file | components/cronet/android/cronet_jni.cc » ('j') | components/cronet/android/cronet_jni.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/cronet/android/chromium_url_request.cc
diff --git a/components/cronet/android/chromium_url_request.cc b/components/cronet/android/chromium_url_request.cc
index 48db19721e75c04bd5e2181a096214ed2b5394d1..e8bee882ba99886423f128e72827ce3fd97242df 100644
--- a/components/cronet/android/chromium_url_request.cc
+++ b/components/cronet/android/chromium_url_request.cc
@@ -45,10 +45,8 @@ void SetPostContentType(JNIEnv* env,
request->SetMethod(method_post);
std::string content_type_header("Content-Type");
-
- const char* content_type_utf8 = env->GetStringUTFChars(content_type, NULL);
- std::string content_type_string(content_type_utf8);
- env->ReleaseStringUTFChars(content_type, content_type_utf8);
+ std::string content_type_string(
+ base::android::ConvertJavaStringToUTF8(env, content_type));
request->AddHeader(content_type_header, content_type_string);
}
@@ -114,19 +112,18 @@ bool ChromiumUrlRequestRegisterJni(JNIEnv* env) {
static jlong CreateRequestAdapter(JNIEnv* env,
jobject object,
jlong urlRequestContextAdapter,
- jstring url_string,
+ jstring url_jstring,
jint priority) {
URLRequestContextAdapter* context =
reinterpret_cast<URLRequestContextAdapter*>(urlRequestContextAdapter);
DCHECK(context != NULL);
- const char* url_utf8 = env->GetStringUTFChars(url_string, NULL);
-
- VLOG(1) << "New chromium network request. URL:" << url_utf8;
+ std::string url_string(
+ base::android::ConvertJavaStringToUTF8(env, url_jstring));
mmenke 2014/09/03 18:43:06 optional: Think it's cleaner to just do: GURL url
mef 2014/09/03 18:56:04 Done. I haven't really used VLOGs either so far.
- GURL url(url_utf8);
+ VLOG(1) << "New chromium network request. URL:" << url_string;
- env->ReleaseStringUTFChars(url_string, url_utf8);
+ GURL url(url_string);
URLRequestAdapter* adapter =
new URLRequestAdapter(context,
« no previous file with comments | « no previous file | components/cronet/android/cronet_jni.cc » ('j') | components/cronet/android/cronet_jni.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698