| 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.Build; | 7 import android.os.Build; |
| 8 import android.os.ConditionVariable; | 8 import android.os.ConditionVariable; |
| 9 import android.os.Handler; | 9 import android.os.Handler; |
| 10 import android.os.Looper; | 10 import android.os.Looper; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 checkHaveAdapter(); | 134 checkHaveAdapter(); |
| 135 return new CronetUrlRequest( | 135 return new CronetUrlRequest( |
| 136 this, mUrlRequestContextAdapter, url, priority, callback, ex
ecutor); | 136 this, mUrlRequestContextAdapter, url, priority, callback, ex
ecutor); |
| 137 } | 137 } |
| 138 } | 138 } |
| 139 | 139 |
| 140 @Override | 140 @Override |
| 141 BidirectionalStream createBidirectionalStream(String url, BidirectionalStrea
m.Callback callback, | 141 BidirectionalStream createBidirectionalStream(String url, BidirectionalStrea
m.Callback callback, |
| 142 Executor executor, String httpMethod, List<Map.Entry<String, String>
> requestHeaders, | 142 Executor executor, String httpMethod, List<Map.Entry<String, String>
> requestHeaders, |
| 143 @BidirectionalStream.Builder.StreamPriority int priority) { | 143 @BidirectionalStream.Builder.StreamPriority int priority) { |
| 144 throw new UnsupportedOperationException(); | 144 synchronized (mLock) { |
| 145 checkHaveAdapter(); |
| 146 return new CronetBidirectionalStream(this, mUrlRequestContextAdapter
, url, callback, |
| 147 executor, httpMethod, requestHeaders); |
| 148 } |
| 145 } | 149 } |
| 146 | 150 |
| 147 @Override | 151 @Override |
| 148 public boolean isEnabled() { | 152 public boolean isEnabled() { |
| 149 return Build.VERSION.SDK_INT >= 14; | 153 return Build.VERSION.SDK_INT >= 14; |
| 150 } | 154 } |
| 151 | 155 |
| 152 @Override | 156 @Override |
| 153 public String getVersionString() { | 157 public String getVersionString() { |
| 154 return "Cronet/" + Version.getVersion(); | 158 return "Cronet/" + Version.getVersion(); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 | 318 |
| 315 @Override | 319 @Override |
| 316 public URLStreamHandlerFactory createURLStreamHandlerFactory() { | 320 public URLStreamHandlerFactory createURLStreamHandlerFactory() { |
| 317 return new CronetURLStreamHandlerFactory(this); | 321 return new CronetURLStreamHandlerFactory(this); |
| 318 } | 322 } |
| 319 | 323 |
| 320 /** | 324 /** |
| 321 * Mark request as started to prevent shutdown when there are active | 325 * Mark request as started to prevent shutdown when there are active |
| 322 * requests. | 326 * requests. |
| 323 */ | 327 */ |
| 324 void onRequestStarted(UrlRequest urlRequest) { | 328 void onRequestStarted() { |
| 325 mActiveRequestCount.incrementAndGet(); | 329 mActiveRequestCount.incrementAndGet(); |
| 326 } | 330 } |
| 327 | 331 |
| 328 /** | 332 /** |
| 329 * Mark request as completed to allow shutdown when there are no active | 333 * Mark request as completed to allow shutdown when there are no active |
| 330 * requests. | 334 * requests. |
| 331 */ | 335 */ |
| 332 void onRequestDestroyed(UrlRequest urlRequest) { | 336 void onRequestDestroyed() { |
| 333 mActiveRequestCount.decrementAndGet(); | 337 mActiveRequestCount.decrementAndGet(); |
| 334 } | 338 } |
| 335 | 339 |
| 336 @VisibleForTesting | 340 @VisibleForTesting |
| 337 long getUrlRequestContextAdapter() { | 341 long getUrlRequestContextAdapter() { |
| 338 synchronized (mLock) { | 342 synchronized (mLock) { |
| 339 checkHaveAdapter(); | 343 checkHaveAdapter(); |
| 340 return mUrlRequestContextAdapter; | 344 return mUrlRequestContextAdapter; |
| 341 } | 345 } |
| 342 } | 346 } |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 @NativeClassQualifiedName("CronetURLRequestContextAdapter") | 460 @NativeClassQualifiedName("CronetURLRequestContextAdapter") |
| 457 private native void nativeEnableNetworkQualityEstimator( | 461 private native void nativeEnableNetworkQualityEstimator( |
| 458 long nativePtr, boolean useLocalHostRequests, boolean useSmallerResp
onses); | 462 long nativePtr, boolean useLocalHostRequests, boolean useSmallerResp
onses); |
| 459 | 463 |
| 460 @NativeClassQualifiedName("CronetURLRequestContextAdapter") | 464 @NativeClassQualifiedName("CronetURLRequestContextAdapter") |
| 461 private native void nativeProvideRTTObservations(long nativePtr, boolean sho
uld); | 465 private native void nativeProvideRTTObservations(long nativePtr, boolean sho
uld); |
| 462 | 466 |
| 463 @NativeClassQualifiedName("CronetURLRequestContextAdapter") | 467 @NativeClassQualifiedName("CronetURLRequestContextAdapter") |
| 464 private native void nativeProvideThroughputObservations(long nativePtr, bool
ean should); | 468 private native void nativeProvideThroughputObservations(long nativePtr, bool
ean should); |
| 465 } | 469 } |
| OLD | NEW |