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.SystemClock; | 7 import android.os.SystemClock; |
8 import android.support.annotation.Nullable; | 8 import android.support.annotation.Nullable; |
9 import android.util.Log; | 9 import android.util.Log; |
10 | 10 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 } | 183 } |
184 | 184 |
185 @Override | 185 @Override |
186 public void start() { | 186 public void start() { |
187 synchronized (mUrlRequestAdapterLock) { | 187 synchronized (mUrlRequestAdapterLock) { |
188 checkNotStarted(); | 188 checkNotStarted(); |
189 | 189 |
190 try { | 190 try { |
191 mUrlRequestAdapter = nativeCreateRequestAdapter( | 191 mUrlRequestAdapter = nativeCreateRequestAdapter( |
192 mRequestContext.getUrlRequestContextAdapter(), mInitialU
rl, mPriority); | 192 mRequestContext.getUrlRequestContextAdapter(), mInitialU
rl, mPriority); |
193 mRequestContext.onRequestStarted(this); | 193 mRequestContext.onRequestStarted(); |
194 if (mInitialMethod != null) { | 194 if (mInitialMethod != null) { |
195 if (!nativeSetHttpMethod(mUrlRequestAdapter, mInitialMethod)
) { | 195 if (!nativeSetHttpMethod(mUrlRequestAdapter, mInitialMethod)
) { |
196 throw new IllegalArgumentException("Invalid http method
" + mInitialMethod); | 196 throw new IllegalArgumentException("Invalid http method
" + mInitialMethod); |
197 } | 197 } |
198 } | 198 } |
199 | 199 |
200 boolean hasContentType = false; | 200 boolean hasContentType = false; |
201 for (Map.Entry<String, String> header : mRequestHeaders) { | 201 for (Map.Entry<String, String> header : mRequestHeaders) { |
202 if (header.getKey().equalsIgnoreCase("Content-Type") | 202 if (header.getKey().equalsIgnoreCase("Content-Type") |
203 && !header.getValue().isEmpty()) { | 203 && !header.getValue().isEmpty()) { |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 private void destroyRequestAdapter(boolean sendOnCanceled) { | 428 private void destroyRequestAdapter(boolean sendOnCanceled) { |
429 synchronized (mUrlRequestAdapterLock) { | 429 synchronized (mUrlRequestAdapterLock) { |
430 if (mUrlRequestAdapter == 0) { | 430 if (mUrlRequestAdapter == 0) { |
431 return; | 431 return; |
432 } | 432 } |
433 if (mRequestMetricsAccumulator != null) { | 433 if (mRequestMetricsAccumulator != null) { |
434 mRequestMetricsAccumulator.onRequestFinished(); | 434 mRequestMetricsAccumulator.onRequestFinished(); |
435 } | 435 } |
436 nativeDestroy(mUrlRequestAdapter, sendOnCanceled); | 436 nativeDestroy(mUrlRequestAdapter, sendOnCanceled); |
437 mRequestContext.reportFinished(this); | 437 mRequestContext.reportFinished(this); |
438 mRequestContext.onRequestDestroyed(this); | 438 mRequestContext.onRequestDestroyed(); |
439 mUrlRequestAdapter = 0; | 439 mUrlRequestAdapter = 0; |
440 if (mOnDestroyedCallbackForTesting != null) { | 440 if (mOnDestroyedCallbackForTesting != null) { |
441 mOnDestroyedCallbackForTesting.run(); | 441 mOnDestroyedCallbackForTesting.run(); |
442 } | 442 } |
443 } | 443 } |
444 } | 444 } |
445 | 445 |
446 /** | 446 /** |
447 * If listener method throws an exception, request gets canceled | 447 * If listener method throws an exception, request gets canceled |
448 * and exception is reported via onFailed listener callback. | 448 * and exception is reported via onFailed listener callback. |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 | 779 |
780 @NativeClassQualifiedName("CronetURLRequestAdapter") | 780 @NativeClassQualifiedName("CronetURLRequestAdapter") |
781 private native String nativeGetProxyServer(long nativePtr); | 781 private native String nativeGetProxyServer(long nativePtr); |
782 | 782 |
783 @NativeClassQualifiedName("CronetURLRequestAdapter") | 783 @NativeClassQualifiedName("CronetURLRequestAdapter") |
784 private native void nativeGetStatus(long nativePtr, UrlRequest.StatusListene
r listener); | 784 private native void nativeGetStatus(long nativePtr, UrlRequest.StatusListene
r listener); |
785 | 785 |
786 @NativeClassQualifiedName("CronetURLRequestAdapter") | 786 @NativeClassQualifiedName("CronetURLRequestAdapter") |
787 private native boolean nativeGetWasCached(long nativePtr); | 787 private native boolean nativeGetWasCached(long nativePtr); |
788 } | 788 } |
OLD | NEW |