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

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

Issue 2812963002: [Cronet] Move initialization to a new thread rather than the UI thread. (Closed)
Patch Set: update tests to account for mRegistered change Created 3 years, 7 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 | « components/cronet/android/java/src/org/chromium/net/impl/CronetLibraryLoader.java ('k') | net/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/cronet/android/java/src/org/chromium/net/impl/CronetUrlRequestContext.java
diff --git a/components/cronet/android/java/src/org/chromium/net/impl/CronetUrlRequestContext.java b/components/cronet/android/java/src/org/chromium/net/impl/CronetUrlRequestContext.java
index 4de86f01c81ea0b1749715adf95780b16ea793d5..b9488c41e7099230c9eb2bcc18c004f895e5fbd9 100644
--- a/components/cronet/android/java/src/org/chromium/net/impl/CronetUrlRequestContext.java
+++ b/components/cronet/android/java/src/org/chromium/net/impl/CronetUrlRequestContext.java
@@ -5,8 +5,6 @@
package org.chromium.net.impl;
import android.os.ConditionVariable;
-import android.os.Handler;
-import android.os.Looper;
import android.os.Process;
import org.chromium.base.Log;
@@ -161,25 +159,19 @@ public class CronetUrlRequestContext extends CronetEngineBase {
mNetworkQualityEstimatorEnabled = builder.networkQualityEstimatorEnabled();
}
- // Init native Chromium URLRequestContext on main UI thread.
- Runnable task = new Runnable() {
+ // Init native Chromium URLRequestContext on init thread.
+ CronetLibraryLoader.postToInitThread(new Runnable() {
@Override
public void run() {
- CronetLibraryLoader.ensureInitializedOnMainThread(builder.getContext());
+ CronetLibraryLoader.ensureInitializedOnInitThread(builder.getContext());
synchronized (mLock) {
// mUrlRequestContextAdapter is guaranteed to exist until
- // initialization on main and network threads completes and
+ // initialization on init and network threads completes and
// initNetworkThread is called back on network thread.
- nativeInitRequestContextOnMainThread(mUrlRequestContextAdapter);
+ nativeInitRequestContextOnInitThread(mUrlRequestContextAdapter);
}
}
- };
- // Run task immediately or post it to the UI thread.
- if (Looper.getMainLooper() == Looper.myLooper()) {
- task.run();
- } else {
- new Handler(Looper.getMainLooper()).post(task);
- }
+ });
}
@VisibleForTesting
@@ -251,7 +243,7 @@ public class CronetUrlRequestContext extends CronetEngineBase {
throw new IllegalThreadStateException("Cannot shutdown from network thread.");
}
}
- // Wait for init to complete on main and network thread (without lock,
+ // Wait for init to complete on init and network thread (without lock,
// so other thread could access it).
mInitCompleted.block();
@@ -711,7 +703,7 @@ public class CronetUrlRequestContext extends CronetEngineBase {
private native void nativeGetCertVerifierData(long nativePtr);
@NativeClassQualifiedName("CronetURLRequestContextAdapter")
- private native void nativeInitRequestContextOnMainThread(long nativePtr);
+ private native void nativeInitRequestContextOnInitThread(long nativePtr);
@NativeClassQualifiedName("CronetURLRequestContextAdapter")
private native void nativeConfigureNetworkQualityEstimatorForTesting(long nativePtr,
« no previous file with comments | « components/cronet/android/java/src/org/chromium/net/impl/CronetLibraryLoader.java ('k') | net/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698