| 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.util.Log; | 7 import android.util.Log; |
| 8 | 8 |
| 9 import org.chromium.base.VisibleForTesting; | 9 import org.chromium.base.VisibleForTesting; |
| 10 import org.chromium.base.annotations.CalledByNative; | 10 import org.chromium.base.annotations.CalledByNative; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 } | 166 } |
| 167 | 167 |
| 168 @Override | 168 @Override |
| 169 public void start() { | 169 public void start() { |
| 170 synchronized (mUrlRequestAdapterLock) { | 170 synchronized (mUrlRequestAdapterLock) { |
| 171 checkNotStarted(); | 171 checkNotStarted(); |
| 172 | 172 |
| 173 try { | 173 try { |
| 174 mUrlRequestAdapter = nativeCreateRequestAdapter( | 174 mUrlRequestAdapter = nativeCreateRequestAdapter( |
| 175 mRequestContext.getUrlRequestContextAdapter(), mInitialU
rl, mPriority); | 175 mRequestContext.getUrlRequestContextAdapter(), mInitialU
rl, mPriority); |
| 176 mRequestContext.onRequestStarted(this); | 176 mRequestContext.onRequestStarted(); |
| 177 if (mInitialMethod != null) { | 177 if (mInitialMethod != null) { |
| 178 if (!nativeSetHttpMethod(mUrlRequestAdapter, mInitialMethod)
) { | 178 if (!nativeSetHttpMethod(mUrlRequestAdapter, mInitialMethod)
) { |
| 179 throw new IllegalArgumentException("Invalid http method
" + mInitialMethod); | 179 throw new IllegalArgumentException("Invalid http method
" + mInitialMethod); |
| 180 } | 180 } |
| 181 } | 181 } |
| 182 | 182 |
| 183 boolean hasContentType = false; | 183 boolean hasContentType = false; |
| 184 for (Map.Entry<String, String> header : mRequestHeaders) { | 184 for (Map.Entry<String, String> header : mRequestHeaders) { |
| 185 if (header.getKey().equalsIgnoreCase("Content-Type") | 185 if (header.getKey().equalsIgnoreCase("Content-Type") |
| 186 && !header.getValue().isEmpty()) { | 186 && !header.getValue().isEmpty()) { |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 } | 405 } |
| 406 } | 406 } |
| 407 } | 407 } |
| 408 | 408 |
| 409 private void destroyRequestAdapter(boolean sendOnCanceled) { | 409 private void destroyRequestAdapter(boolean sendOnCanceled) { |
| 410 synchronized (mUrlRequestAdapterLock) { | 410 synchronized (mUrlRequestAdapterLock) { |
| 411 if (mUrlRequestAdapter == 0) { | 411 if (mUrlRequestAdapter == 0) { |
| 412 return; | 412 return; |
| 413 } | 413 } |
| 414 nativeDestroy(mUrlRequestAdapter, sendOnCanceled); | 414 nativeDestroy(mUrlRequestAdapter, sendOnCanceled); |
| 415 mRequestContext.onRequestDestroyed(this); | 415 mRequestContext.onRequestDestroyed(); |
| 416 mUrlRequestAdapter = 0; | 416 mUrlRequestAdapter = 0; |
| 417 if (mOnDestroyedCallbackForTests != null) { | 417 if (mOnDestroyedCallbackForTests != null) { |
| 418 mOnDestroyedCallbackForTests.run(); | 418 mOnDestroyedCallbackForTests.run(); |
| 419 } | 419 } |
| 420 } | 420 } |
| 421 } | 421 } |
| 422 | 422 |
| 423 /** | 423 /** |
| 424 * If listener method throws an exception, request gets canceled | 424 * If listener method throws an exception, request gets canceled |
| 425 * and exception is reported via onFailed listener callback. | 425 * and exception is reported via onFailed listener callback. |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 | 710 |
| 711 @NativeClassQualifiedName("CronetURLRequestAdapter") | 711 @NativeClassQualifiedName("CronetURLRequestAdapter") |
| 712 private native String nativeGetProxyServer(long nativePtr); | 712 private native String nativeGetProxyServer(long nativePtr); |
| 713 | 713 |
| 714 @NativeClassQualifiedName("CronetURLRequestAdapter") | 714 @NativeClassQualifiedName("CronetURLRequestAdapter") |
| 715 private native void nativeGetStatus(long nativePtr, UrlRequest.StatusListene
r listener); | 715 private native void nativeGetStatus(long nativePtr, UrlRequest.StatusListene
r listener); |
| 716 | 716 |
| 717 @NativeClassQualifiedName("CronetURLRequestAdapter") | 717 @NativeClassQualifiedName("CronetURLRequestAdapter") |
| 718 private native boolean nativeGetWasCached(long nativePtr); | 718 private native boolean nativeGetWasCached(long nativePtr); |
| 719 } | 719 } |
| OLD | NEW |