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/java/src/org/chromium/net/ChromiumUrlRequestContext.java

Issue 624443003: Setup ProxyConfigServiceAndroid in Cronet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Initialize boolean to false Created 6 years, 2 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/ChromiumUrlRequestContext.java
diff --git a/components/cronet/android/java/src/org/chromium/net/ChromiumUrlRequestContext.java b/components/cronet/android/java/src/org/chromium/net/ChromiumUrlRequestContext.java
index 9f99814cff68ec491fd59c5f5305c1333f34b3ef..4ceb715c151c4e52edd43f773b024ce60b1d4558 100644
--- a/components/cronet/android/java/src/org/chromium/net/ChromiumUrlRequestContext.java
+++ b/components/cronet/android/java/src/org/chromium/net/ChromiumUrlRequestContext.java
@@ -5,6 +5,8 @@
package org.chromium.net;
import android.content.Context;
+import android.os.Handler;
+import android.os.Looper;
import android.os.Process;
import android.util.Log;
@@ -28,7 +30,6 @@ public class ChromiumUrlRequestContext {
/**
* Constructor.
- *
*/
protected ChromiumUrlRequestContext(Context context, String userAgent,
String config) {
@@ -37,6 +38,17 @@ public class ChromiumUrlRequestContext {
if (mChromiumUrlRequestContextAdapter == 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(
+ mChromiumUrlRequestContextAdapter);
+ }
+ };
+ new Handler(Looper.getMainLooper()).post(task);
}
/**
@@ -129,4 +141,7 @@ public class ChromiumUrlRequestContext {
long chromiumUrlRequestContextAdapter, String fileName);
private native void nativeStopNetLog(long chromiumUrlRequestContextAdapter);
+
+ private native void nativeInitRequestContextOnMainThread(
+ long chromiumUrlRequestContextAdapter);
}

Powered by Google App Engine
This is Rietveld 408576698