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

Unified Diff: components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestContextTest.java

Issue 1926683003: [Cronet] Avoid crashing when CronetEngines are created on multiple threads (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address mef comments Created 4 years, 8 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/CronetUrlRequestContext.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestContextTest.java
diff --git a/components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestContextTest.java b/components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestContextTest.java
index 5353b8a9cf40674832f1c17e5c0e1a26adf5d481..5fbfcbf4a43c4c234ea68988fec508afe9557723 100644
--- a/components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestContextTest.java
+++ b/components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestContextTest.java
@@ -1125,4 +1125,30 @@ public class CronetUrlRequestContextTest extends CronetTestBase {
assertTrue(loader.wasCalled());
}
}
+
+ // Creates a CronetEngine on another thread and then one on the main thread. This shouldn't
+ // crash.
+ @SmallTest
+ @Feature({"Cronet"})
+ public void testThreadedStartup() throws Exception {
+ final ConditionVariable otherThreadDone = new ConditionVariable();
+ final ConditionVariable uiThreadDone = new ConditionVariable();
+ new Handler(Looper.getMainLooper()).post(new Runnable() {
+ public void run() {
+ final CronetEngine.Builder builder =
+ new CronetEngine.Builder(getContext()).setLibraryName("cronet_tests");
+ new Thread() {
+ public void run() {
+ CronetEngine cronetEngine = builder.build();
mef 2016/04/27 18:48:15 Can we create and start a new request here, before
pauljensen 2016/04/27 19:04:24 We could do lots of things here. I think our othe
mef 2016/04/27 19:50:00 Acknowledged.
+ otherThreadDone.open();
+ cronetEngine.shutdown();
+ }
+ }.start();
+ otherThreadDone.block();
mef 2016/04/27 18:48:15 OTOH I can see Paul's point that this will deadloc
+ builder.build().shutdown();
+ uiThreadDone.open();
+ }
+ });
+ assertTrue(uiThreadDone.block(1000));
+ }
}
« no previous file with comments | « components/cronet/android/java/src/org/chromium/net/CronetUrlRequestContext.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698