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

Side by Side 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, 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.net; 5 package org.chromium.net;
6 6
7 import static org.chromium.base.CollectionUtil.newHashSet; 7 import static org.chromium.base.CollectionUtil.newHashSet;
8 8
9 import android.content.Context; 9 import android.content.Context;
10 import android.content.ContextWrapper; 10 import android.content.ContextWrapper;
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1118 builder.setLibraryLoader(loader).setLibraryName("cronet_tests"); 1118 builder.setLibraryLoader(loader).setLibraryName("cronet_tests");
1119 try { 1119 try {
1120 // ensureInitialized() calls native code to check the version right after library load 1120 // ensureInitialized() calls native code to check the version right after library load
1121 // and will error with the message below if library loading was skip ped 1121 // and will error with the message below if library loading was skip ped
1122 CronetLibraryLoader.ensureInitialized(getContext(), builder); 1122 CronetLibraryLoader.ensureInitialized(getContext(), builder);
1123 fail("Native library should not be loaded"); 1123 fail("Native library should not be loaded");
1124 } catch (UnsatisfiedLinkError e) { 1124 } catch (UnsatisfiedLinkError e) {
1125 assertTrue(loader.wasCalled()); 1125 assertTrue(loader.wasCalled());
1126 } 1126 }
1127 } 1127 }
1128
1129 // Creates a CronetEngine on another thread and then one on the main thread. This shouldn't
1130 // crash.
1131 @SmallTest
1132 @Feature({"Cronet"})
1133 public void testThreadedStartup() throws Exception {
1134 final ConditionVariable otherThreadDone = new ConditionVariable();
1135 final ConditionVariable uiThreadDone = new ConditionVariable();
1136 new Handler(Looper.getMainLooper()).post(new Runnable() {
1137 public void run() {
1138 final CronetEngine.Builder builder =
1139 new CronetEngine.Builder(getContext()).setLibraryName("c ronet_tests");
1140 new Thread() {
1141 public void run() {
1142 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.
1143 otherThreadDone.open();
1144 cronetEngine.shutdown();
1145 }
1146 }.start();
1147 otherThreadDone.block();
mef 2016/04/27 18:48:15 OTOH I can see Paul's point that this will deadloc
1148 builder.build().shutdown();
1149 uiThreadDone.open();
1150 }
1151 });
1152 assertTrue(uiThreadDone.block(1000));
1153 }
1128 } 1154 }
OLDNEW
« 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