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

Side by Side Diff: components/cronet/android/test/src/org/chromium/net/QuicTestServer.java

Issue 1911353003: [Cronet] Do not call into BidirectionalStream::SendData if stream failed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address 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 unified diff | Download patch
« no previous file with comments | « components/cronet/android/test/javatests/src/org/chromium/net/BidirectionalStreamQuicTest.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 android.content.Context; 7 import android.content.Context;
8 import android.os.ConditionVariable; 8 import android.os.ConditionVariable;
9 9
10 import org.chromium.base.Log; 10 import org.chromium.base.Log;
11 import org.chromium.base.annotations.CalledByNative; 11 import org.chromium.base.annotations.CalledByNative;
12 import org.chromium.base.annotations.JNINamespace; 12 import org.chromium.base.annotations.JNINamespace;
13 13
14 /** 14 /**
15 * Wrapper class to start a Quic test server. 15 * Wrapper class to start a Quic test server.
16 */ 16 */
17 @JNINamespace("cronet") 17 @JNINamespace("cronet")
18 public final class QuicTestServer { 18 public final class QuicTestServer {
19 private static final ConditionVariable sBlock = new ConditionVariable(); 19 private static final ConditionVariable sBlock = new ConditionVariable();
20 private static final String TAG = "cr.QuicTestServer"; 20 private static final String TAG = "cr.QuicTestServer";
21 21
22 private static final String CERT_USED = "quic_test.example.com.crt"; 22 private static final String CERT_USED = "quic_test.example.com.crt";
23 private static final String KEY_USED = "quic_test.example.com.key"; 23 private static final String KEY_USED = "quic_test.example.com.key";
24 private static final String[] CERTS_USED = {CERT_USED}; 24 private static final String[] CERTS_USED = {CERT_USED};
25 25
26 private static boolean sServerRunning = false;
27
28 /*
29 * Starts the server.
30 */
26 public static void startQuicTestServer(Context context) { 31 public static void startQuicTestServer(Context context) {
32 if (sServerRunning) {
33 throw new IllegalStateException("Quic server is already running");
34 }
27 TestFilesInstaller.installIfNeeded(context); 35 TestFilesInstaller.installIfNeeded(context);
28 nativeStartQuicTestServer(TestFilesInstaller.getInstalledPath(context)); 36 nativeStartQuicTestServer(TestFilesInstaller.getInstalledPath(context));
29 sBlock.block(); 37 sBlock.block();
38 sBlock.close();
39 sServerRunning = true;
30 } 40 }
31 41
42 /**
43 * Shuts down the server. No-op if the server is already shut down.
44 */
32 public static void shutdownQuicTestServer() { 45 public static void shutdownQuicTestServer() {
46 if (!sServerRunning) {
47 return;
48 }
33 nativeShutdownQuicTestServer(); 49 nativeShutdownQuicTestServer();
34 sBlock.close(); 50 sServerRunning = false;
35 } 51 }
36 52
37 public static String getServerURL() { 53 public static String getServerURL() {
38 return "https://" + getServerHost() + ":" + getServerPort(); 54 return "https://" + getServerHost() + ":" + getServerPort();
39 } 55 }
40 56
41 public static String getServerHost() { 57 public static String getServerHost() {
42 return nativeGetServerHost(); 58 return nativeGetServerHost();
43 } 59 }
44 60
(...skipping 17 matching lines...) Expand all
62 private static void onServerStarted() { 78 private static void onServerStarted() {
63 Log.i(TAG, "Quic server started."); 79 Log.i(TAG, "Quic server started.");
64 sBlock.open(); 80 sBlock.open();
65 } 81 }
66 82
67 private static native void nativeStartQuicTestServer(String filePath); 83 private static native void nativeStartQuicTestServer(String filePath);
68 private static native void nativeShutdownQuicTestServer(); 84 private static native void nativeShutdownQuicTestServer();
69 private static native String nativeGetServerHost(); 85 private static native String nativeGetServerHost();
70 private static native int nativeGetServerPort(); 86 private static native int nativeGetServerPort();
71 } 87 }
OLDNEW
« no previous file with comments | « components/cronet/android/test/javatests/src/org/chromium/net/BidirectionalStreamQuicTest.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698