Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(540)

Side by Side Diff: components/cronet/android/java/src/org/chromium/net/CronetUrlRequest.java

Issue 1412243012: Initial implementation of CronetBidirectionalStream. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Helen's comments. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 private void destroyRequestAdapter(boolean sendOnCanceled) { 434 private void destroyRequestAdapter(boolean sendOnCanceled) {
435 synchronized (mUrlRequestAdapterLock) { 435 synchronized (mUrlRequestAdapterLock) {
436 if (mUrlRequestAdapter == 0) { 436 if (mUrlRequestAdapter == 0) {
437 return; 437 return;
438 } 438 }
439 if (mRequestMetricsAccumulator != null) { 439 if (mRequestMetricsAccumulator != null) {
440 mRequestMetricsAccumulator.onRequestFinished(); 440 mRequestMetricsAccumulator.onRequestFinished();
441 } 441 }
442 nativeDestroy(mUrlRequestAdapter, sendOnCanceled); 442 nativeDestroy(mUrlRequestAdapter, sendOnCanceled);
443 mRequestContext.reportFinished(this); 443 mRequestContext.reportFinished(this);
444 mRequestContext.onRequestDestroyed(this); 444 mRequestContext.onRequestDestroyed();
445 mUrlRequestAdapter = 0; 445 mUrlRequestAdapter = 0;
446 if (mOnDestroyedCallbackForTesting != null) { 446 if (mOnDestroyedCallbackForTesting != null) {
447 mOnDestroyedCallbackForTesting.run(); 447 mOnDestroyedCallbackForTesting.run();
448 } 448 }
449 } 449 }
450 } 450 }
451 451
452 /** 452 /**
453 * If listener method throws an exception, request gets canceled 453 * If listener method throws an exception, request gets canceled
454 * and exception is reported via onFailed listener callback. 454 * and exception is reported via onFailed listener callback.
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 785
786 @NativeClassQualifiedName("CronetURLRequestAdapter") 786 @NativeClassQualifiedName("CronetURLRequestAdapter")
787 private native String nativeGetProxyServer(long nativePtr); 787 private native String nativeGetProxyServer(long nativePtr);
788 788
789 @NativeClassQualifiedName("CronetURLRequestAdapter") 789 @NativeClassQualifiedName("CronetURLRequestAdapter")
790 private native void nativeGetStatus(long nativePtr, UrlRequest.StatusListene r listener); 790 private native void nativeGetStatus(long nativePtr, UrlRequest.StatusListene r listener);
791 791
792 @NativeClassQualifiedName("CronetURLRequestAdapter") 792 @NativeClassQualifiedName("CronetURLRequestAdapter")
793 private native boolean nativeGetWasCached(long nativePtr); 793 private native boolean nativeGetWasCached(long nativePtr);
794 } 794 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698