Chromium Code Reviews| 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; | 
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 224 assertEquals("Exception received from UrlRequest.Callback", error.ge tMessage()); | 224 assertEquals("Exception received from UrlRequest.Callback", error.ge tMessage()); | 
| 225 assertNotNull(error.getCause()); | 225 assertNotNull(error.getCause()); | 
| 226 assertTrue(error.getCause() instanceof IllegalStateException); | 226 assertTrue(error.getCause() instanceof IllegalStateException); | 
| 227 assertEquals("Listener Exception.", error.getCause().getMessage()); | 227 assertEquals("Listener Exception.", error.getCause().getMessage()); | 
| 228 assertFalse(error.immediatelyRetryable()); | 228 assertFalse(error.immediatelyRetryable()); | 
| 229 } | 229 } | 
| 230 | 230 | 
| 231 mOnErrorCalled = true; | 231 mOnErrorCalled = true; | 
| 232 mError = error; | 232 mError = error; | 
| 233 openDone(); | 233 openDone(); | 
| 234 maybeThrowCancelOrPause(request); | |
| 
 
kapishnikov
2016/08/30 16:15:57
Why don't we update mResponseStep to ON_FAILED her
 
xunjieli
2016/08/30 17:05:43
There is no enum ON_FAILED. We can certainly add o
 
 | |
| 235 } | 234 } | 
| 236 | 235 | 
| 237 @Override | 236 @Override | 
| 238 public void onCanceled(UrlRequest request, UrlResponseInfo info) { | 237 public void onCanceled(UrlRequest request, UrlResponseInfo info) { | 
| 239 assertEquals(mExecutorThread, Thread.currentThread()); | 238 assertEquals(mExecutorThread, Thread.currentThread()); | 
| 240 assertTrue(request.isDone()); | 239 assertTrue(request.isDone()); | 
| 241 // Should happen at most once for a single request. | 240 // Should happen at most once for a single request. | 
| 242 assertFalse(mOnCanceledCalled); | 241 assertFalse(mOnCanceledCalled); | 
| 243 assertFalse(mOnErrorCalled); | 242 assertFalse(mOnErrorCalled); | 
| 244 assertNull(mError); | 243 assertNull(mError); | 
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 291 }; | 290 }; | 
| 292 if (mFailureType == FailureType.CANCEL_ASYNC | 291 if (mFailureType == FailureType.CANCEL_ASYNC | 
| 293 || mFailureType == FailureType.CANCEL_ASYNC_WITHOUT_PAUSE) { | 292 || mFailureType == FailureType.CANCEL_ASYNC_WITHOUT_PAUSE) { | 
| 294 getExecutor().execute(task); | 293 getExecutor().execute(task); | 
| 295 } else { | 294 } else { | 
| 296 task.run(); | 295 task.run(); | 
| 297 } | 296 } | 
| 298 return mFailureType != FailureType.CANCEL_ASYNC_WITHOUT_PAUSE; | 297 return mFailureType != FailureType.CANCEL_ASYNC_WITHOUT_PAUSE; | 
| 299 } | 298 } | 
| 300 } | 299 } | 
| OLD | NEW |