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

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: Fix compilation error. Created 5 years, 10 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..bae03804261989a7972809698ea250060b9514d3 100644
--- a/components/cronet/android/cronet_url_request_context.cc
+++ b/components/cronet/android/cronet_url_request_context.cc
@@ -33,7 +33,8 @@ bool CronetUrlRequestContextRegisterJni(JNIEnv* env) {
return RegisterNativesImpl(env);
}
-// Sets global user-agent to be used for all subsequent requests.
+// Creates RequestContextAdater if config is valid URLRequestContextConfig,
+// returns 0 otherwise.
static jlong CreateRequestContextAdapter(JNIEnv* env,
jobject jcaller,
jobject japp_context,
@@ -45,19 +46,8 @@ static jlong CreateRequestContextAdapter(JNIEnv* env,
if (!context_config->LoadFromJSON(config_string))
return 0;
- // Set application context.
- base::android::ScopedJavaLocalRef<jobject> scoped_context(env, japp_context);
- 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);
-
+ new CronetURLRequestContextAdapter(context_config.Pass());
return reinterpret_cast<jlong>(context_adapter);
}
@@ -106,4 +96,22 @@ 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) {
+ if (jurl_request_context_adapter == 0)
+ 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(init_java_network_thread);
+}
+
} // namespace cronet

Powered by Google App Engine
This is Rietveld 408576698