| OLD | NEW |
| 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 android.os.ConditionVariable; | 7 import android.os.ConditionVariable; |
| 8 import android.os.StrictMode; | 8 import android.os.StrictMode; |
| 9 | 9 |
| 10 import static junit.framework.Assert.assertEquals; | 10 import static junit.framework.Assert.assertEquals; |
| 11 import static junit.framework.Assert.assertFalse; | 11 import static junit.framework.Assert.assertFalse; |
| 12 import static junit.framework.Assert.assertNotNull; | 12 import static junit.framework.Assert.assertNotNull; |
| 13 import static junit.framework.Assert.assertNull; | 13 import static junit.framework.Assert.assertNull; |
| 14 import static junit.framework.Assert.assertTrue; | 14 import static junit.framework.Assert.assertTrue; |
| 15 | 15 |
| 16 import static org.chromium.net.CronetTestBase.assertContains; | 16 import static org.chromium.net.CronetTestBase.assertContains; |
| 17 | 17 |
| 18 import java.nio.ByteBuffer; | 18 import java.nio.ByteBuffer; |
| 19 import java.util.ArrayList; | 19 import java.util.ArrayList; |
| 20 import java.util.concurrent.ExecutorService; | 20 import java.util.concurrent.ExecutorService; |
| 21 import java.util.concurrent.Executors; | 21 import java.util.concurrent.Executors; |
| 22 import java.util.concurrent.ThreadFactory; | 22 import java.util.concurrent.ThreadFactory; |
| 23 import java.util.concurrent.TimeUnit; | 23 import java.util.concurrent.TimeUnit; |
| 24 | 24 |
| 25 /** | 25 /** |
| 26 * Callback that tracks information from different callbacks and and has a | 26 * Callback that tracks information from different callbacks and and has a |
| 27 * method to block thread until the request completes on another thread. | 27 * method to block thread until the request completes on another thread. |
| 28 * Allows to cancel, block request or throw an exception from an arbitrary step. | 28 * Allows to cancel, block request or throw an exception from an arbitrary step. |
| 29 */ | 29 */ |
| 30 class TestUrlRequestCallback extends UrlRequest.Callback { | 30 public class TestUrlRequestCallback extends UrlRequest.Callback { |
| 31 public ArrayList<UrlResponseInfo> mRedirectResponseInfoList = new ArrayList<
UrlResponseInfo>(); | 31 public ArrayList<UrlResponseInfo> mRedirectResponseInfoList = new ArrayList<
UrlResponseInfo>(); |
| 32 public ArrayList<String> mRedirectUrlList = new ArrayList<String>(); | 32 public ArrayList<String> mRedirectUrlList = new ArrayList<String>(); |
| 33 public UrlResponseInfo mResponseInfo; | 33 public UrlResponseInfo mResponseInfo; |
| 34 public CronetException mError; | 34 public CronetException mError; |
| 35 | 35 |
| 36 public ResponseStep mResponseStep = ResponseStep.NOTHING; | 36 public ResponseStep mResponseStep = ResponseStep.NOTHING; |
| 37 | 37 |
| 38 public int mRedirectCount = 0; | 38 public int mRedirectCount = 0; |
| 39 public boolean mOnErrorCalled = false; | 39 public boolean mOnErrorCalled = false; |
| 40 public boolean mOnCanceledCalled = false; | 40 public boolean mOnCanceledCalled = false; |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 }; | 333 }; |
| 334 if (mFailureType == FailureType.CANCEL_ASYNC | 334 if (mFailureType == FailureType.CANCEL_ASYNC |
| 335 || mFailureType == FailureType.CANCEL_ASYNC_WITHOUT_PAUSE) { | 335 || mFailureType == FailureType.CANCEL_ASYNC_WITHOUT_PAUSE) { |
| 336 getExecutor().execute(task); | 336 getExecutor().execute(task); |
| 337 } else { | 337 } else { |
| 338 task.run(); | 338 task.run(); |
| 339 } | 339 } |
| 340 return mFailureType != FailureType.CANCEL_ASYNC_WITHOUT_PAUSE; | 340 return mFailureType != FailureType.CANCEL_ASYNC_WITHOUT_PAUSE; |
| 341 } | 341 } |
| 342 } | 342 } |
| OLD | NEW |