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

Unified Diff: components/cronet/android/java/src/org/chromium/net/CronetUrlRequestContext.java

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: Self review, cl format Created 5 years, 12 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/java/src/org/chromium/net/CronetUrlRequestContext.java
diff --git a/components/cronet/android/java/src/org/chromium/net/CronetUrlRequestContext.java b/components/cronet/android/java/src/org/chromium/net/CronetUrlRequestContext.java
index 4c7afc6c0f2278fc2be06da86220681d7d2ee5ac..a852415374923e0febdbf70dacfe4433d6dfebde 100644
--- a/components/cronet/android/java/src/org/chromium/net/CronetUrlRequestContext.java
+++ b/components/cronet/android/java/src/org/chromium/net/CronetUrlRequestContext.java
@@ -6,6 +6,8 @@ package org.chromium.net;
import android.content.Context;
import android.os.Build;
+import android.os.Handler;
+import android.os.Looper;
import android.os.Process;
import android.util.Log;
@@ -31,12 +33,24 @@ public class CronetUrlRequestContext extends UrlRequestContext {
public CronetUrlRequestContext(Context context,
UrlRequestContextConfig config) {
+ CronetLibraryLoader.loadAndInitialize(context, config);
xunjieli 2015/01/05 14:48:03 Maybe rename "loadAndInitialize" to sth like "init
mef 2015/01/05 16:59:21 Done. ensureInitialized seems to be commonly used
nativeSetMinLogLevel(getLoggingLevel());
mUrlRequestContextAdapter = nativeCreateRequestContextAdapter(
context, config.toString());
if (mUrlRequestContextAdapter == 0) {
throw new NullPointerException("Context Adapter creation failed");
}
+ // Post a task to UI thread to init native Chromium URLRequestContext.
+ // TODO(xunjieli): This constructor is not supposed to be invoked on
+ // the main thread. Consider making the following code into a blocking
+ // API to handle the case where we are already on main thread.
+ Runnable task = new Runnable() {
+ public void run() {
+ nativeInitRequestContextOnMainThread(
+ mUrlRequestContextAdapter);
+ }
+ };
+ new Handler(Looper.getMainLooper()).post(task);
}
@Override
@@ -146,4 +160,7 @@ public class CronetUrlRequestContext extends UrlRequestContext {
private native void nativeStopNetLog(long urlRequestContextAdapter);
private native int nativeSetMinLogLevel(int loggingLevel);
+
+ private native void nativeInitRequestContextOnMainThread(
+ long urlRequestContextAdapter);
}

Powered by Google App Engine
This is Rietveld 408576698