Chromium Code Reviews| Index: components/cronet/android/java/src/org/chromium/net/CronetUrlRequestContext.java |
| diff --git a/components/cronet/android/java/src/org/chromium/net/CronetUrlRequestContext.java b/components/cronet/android/java/src/org/chromium/net/CronetUrlRequestContext.java |
| index 7cdabde2cbeedb1146889c530901f0ca1fa571b8..ee63223cad66d172a03f14b356e50edb8f77757c 100644 |
| --- a/components/cronet/android/java/src/org/chromium/net/CronetUrlRequestContext.java |
| +++ b/components/cronet/android/java/src/org/chromium/net/CronetUrlRequestContext.java |
| @@ -35,6 +35,9 @@ class CronetUrlRequestContext extends CronetEngine { |
| private static final int LOG_VERBOSE = -2; // LOG(FATAL...INFO), VLOG(2) |
| static final String LOG_TAG = "ChromiumNetwork"; |
| + // For Testing. |
| + private static long sNativeMockCertVerifier = 0; |
| + |
| /** |
| * Synchronize access to mUrlRequestContextAdapter and shutdown routine. |
| */ |
| @@ -70,6 +73,10 @@ class CronetUrlRequestContext extends CronetEngine { |
| throw new NullPointerException("Context Adapter creation failed."); |
| } |
| + if (sNativeMockCertVerifier != 0) { |
| + nativeSetMockCertVerifierForTesting(mUrlRequestContextAdapter, sNativeMockCertVerifier); |
|
mef
2015/10/12 18:27:13
Would it make sense to have a 'SetMockCertVerifier
xunjieli
2015/10/13 01:58:02
Great idea! Didn't realize we can serialize a nati
|
| + } |
| + |
| // Init native Chromium URLRequestContext on main UI thread. |
| Runnable task = new Runnable() { |
| @Override |
| @@ -357,12 +364,24 @@ class CronetUrlRequestContext extends CronetEngine { |
| } |
| } |
| + /** |
| + * Sets a mock cert verifier for testing. |
| + * @param nativeMockCertVerifier a pointer to the native net::MockCertVerifier. |
| + */ |
| + static void setMockCertVerifierForTesting(long nativeMockCertVerifier) { |
| + sNativeMockCertVerifier = nativeMockCertVerifier; |
| + } |
| + |
| // Native methods are implemented in cronet_url_request_context.cc. |
| private static native long nativeCreateRequestContextAdapter(String config); |
| private static native int nativeSetMinLogLevel(int loggingLevel); |
| @NativeClassQualifiedName("CronetURLRequestContextAdapter") |
| + private static native void nativeSetMockCertVerifierForTesting( |
| + long nativePtr, long mockCertVerifier); |
| + |
| + @NativeClassQualifiedName("CronetURLRequestContextAdapter") |
| private native void nativeDestroy(long nativePtr); |
| @NativeClassQualifiedName("CronetURLRequestContextAdapter") |