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

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

Issue 726013002: [Cronet] Hook up library loader, system proxy and network change notifier to async api. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Helen's comments. Created 5 years, 11 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/cronet_url_request_context.cc
diff --git a/components/cronet/android/cronet_url_request_context.cc b/components/cronet/android/cronet_url_request_context.cc
index a9b6014217c7ffd110f42fa9a90a4eea5a3227da..c3de3945bc51e850d8f58bb0cae27433b890182f 100644
--- a/components/cronet/android/cronet_url_request_context.cc
+++ b/components/cronet/android/cronet_url_request_context.cc
@@ -49,15 +49,8 @@ static jlong CreateRequestContextAdapter(JNIEnv* env,
base::android::ScopedJavaLocalRef<jobject> scoped_context(env, japp_context);
xunjieli 2015/01/05 18:22:45 base::android::InitApplicationContext is already d
mef 2015/01/05 19:32:41 Done.
base::android::InitApplicationContext(env, scoped_context);
- base::android::ScopedJavaGlobalRef<jobject> jcaller_ref;
- jcaller_ref.Reset(env, jcaller);
-
CronetURLRequestContextAdapter* context_adapter =
new CronetURLRequestContextAdapter();
- base::Closure init_java_network_thread = base::Bind(&initJavaNetworkThread,
- jcaller_ref);
- context_adapter->Initialize(context_config.Pass(), init_java_network_thread);
-
return reinterpret_cast<jlong>(context_adapter);
}
@@ -106,4 +99,31 @@ static jint SetMinLogLevel(JNIEnv* env, jobject jcaller, jint jlog_level) {
return old_log_level;
}
+// Called on application's main Java thread.
+static void InitRequestContextOnMainThread(JNIEnv* env,
+ jobject jcaller,
+ jlong jurl_request_context_adapter,
+ jstring jconfig) {
+ if (jurl_request_context_adapter == 0)
+ return;
+
+ std::string config_string =
+ base::android::ConvertJavaStringToUTF8(env, jconfig);
+ scoped_ptr<URLRequestContextConfig> context_config(
+ new URLRequestContextConfig());
+ if (!context_config->LoadFromJSON(config_string))
xunjieli 2015/01/05 18:22:45 Hmm.. we probably should avoid doing things on the
mef 2015/01/05 19:32:41 The config used to be a member of CronetURLRequest
+ return;
+
+ CronetURLRequestContextAdapter* context_adapter =
+ reinterpret_cast<CronetURLRequestContextAdapter*>(
+ jurl_request_context_adapter);
+
+ base::android::ScopedJavaGlobalRef<jobject> jcaller_ref;
+ jcaller_ref.Reset(env, jcaller);
+ base::Closure init_java_network_thread = base::Bind(&initJavaNetworkThread,
+ jcaller_ref);
+ context_adapter->InitRequestContextOnMainThread(
+ context_config.Pass(), init_java_network_thread);
+}
+
} // namespace cronet

Powered by Google App Engine
This is Rietveld 408576698