| Index: components/cronet/android/test/src/org/chromium/net/MockUrlRequestJobFactory.java
|
| diff --git a/components/cronet/android/test/src/org/chromium/net/MockUrlRequestJobFactory.java b/components/cronet/android/test/src/org/chromium/net/MockUrlRequestJobFactory.java
|
| index 96750028ea374fcdf297bbdc0fd113dffd9af363..1e540e2dc93ac7d0a7fce902b2a2bb1fbae210e8 100644
|
| --- a/components/cronet/android/test/src/org/chromium/net/MockUrlRequestJobFactory.java
|
| +++ b/components/cronet/android/test/src/org/chromium/net/MockUrlRequestJobFactory.java
|
| @@ -7,6 +7,7 @@ package org.chromium.net;
|
| import static junit.framework.Assert.assertTrue;
|
|
|
| import org.chromium.base.annotations.JNINamespace;
|
| +import org.chromium.net.impl.CronetUrlRequestContext;
|
| import org.chromium.net.test.FailurePhase;
|
|
|
| /**
|
| @@ -14,11 +15,26 @@ import org.chromium.net.test.FailurePhase;
|
| */
|
| @JNINamespace("cronet")
|
| public final class MockUrlRequestJobFactory {
|
| + private final long mInterceptorHandle;
|
| + private final CronetTestUtil.PrepareNetworkThread mPrepareNetworkThread;
|
| +
|
| /**
|
| * Sets up URL interceptors.
|
| */
|
| - public static void setUp() {
|
| + public MockUrlRequestJobFactory(CronetEngine cronetEngine) {
|
| + mPrepareNetworkThread = new CronetTestUtil.PrepareNetworkThread(cronetEngine);
|
| +
|
| nativeAddUrlInterceptors();
|
| + mInterceptorHandle = nativeAddUrlInterceptorJobFactory(
|
| + ((CronetUrlRequestContext) cronetEngine).getUrlRequestContextAdapter());
|
| + }
|
| +
|
| + /**
|
| + * Remove URL Interceptors.
|
| + */
|
| + public void shutdown() {
|
| + nativeRemoveUrlInterceptorJobFactory(mInterceptorHandle);
|
| + mPrepareNetworkThread.shutdown();
|
| }
|
|
|
| /**
|
| @@ -77,6 +93,10 @@ public final class MockUrlRequestJobFactory {
|
|
|
| private static native void nativeAddUrlInterceptors();
|
|
|
| + private static native long nativeAddUrlInterceptorJobFactory(long requestContextAdapter);
|
| +
|
| + private static native void nativeRemoveUrlInterceptorJobFactory(long interceptorHandle);
|
| +
|
| private static native String nativeGetMockUrlWithFailure(int phase, int netError);
|
|
|
| private static native String nativeGetMockUrlForData(String data,
|
|
|