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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 synchronized (mLock) { | 113 synchronized (mLock) { |
114 checkHaveAdapter(); | 114 checkHaveAdapter(); |
115 return new CronetUrlRequest( | 115 return new CronetUrlRequest( |
116 this, mUrlRequestContextAdapter, url, priority, callback, ex
ecutor); | 116 this, mUrlRequestContextAdapter, url, priority, callback, ex
ecutor); |
117 } | 117 } |
118 } | 118 } |
119 | 119 |
120 @Override | 120 @Override |
121 BidirectionalStream createBidirectionalStream(String url, BidirectionalStrea
m.Callback callback, | 121 BidirectionalStream createBidirectionalStream(String url, BidirectionalStrea
m.Callback callback, |
122 Executor executor, String httpMethod, List<Map.Entry<String, String>
> requestHeaders) { | 122 Executor executor, String httpMethod, List<Map.Entry<String, String>
> requestHeaders) { |
123 throw new UnsupportedOperationException(); | 123 synchronized (mLock) { |
| 124 checkHaveAdapter(); |
| 125 return new CronetBidirectionalStream(this, mUrlRequestContextAdapter
, url, callback, |
| 126 executor, httpMethod, requestHeaders); |
| 127 } |
124 } | 128 } |
125 | 129 |
126 @Override | 130 @Override |
127 public boolean isEnabled() { | 131 public boolean isEnabled() { |
128 return Build.VERSION.SDK_INT >= 14; | 132 return Build.VERSION.SDK_INT >= 14; |
129 } | 133 } |
130 | 134 |
131 @Override | 135 @Override |
132 public String getVersionString() { | 136 public String getVersionString() { |
133 return "Cronet/" + Version.getVersion(); | 137 return "Cronet/" + Version.getVersion(); |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 | 297 |
294 @Override | 298 @Override |
295 public URLStreamHandlerFactory createURLStreamHandlerFactory() { | 299 public URLStreamHandlerFactory createURLStreamHandlerFactory() { |
296 return new CronetURLStreamHandlerFactory(this); | 300 return new CronetURLStreamHandlerFactory(this); |
297 } | 301 } |
298 | 302 |
299 /** | 303 /** |
300 * Mark request as started to prevent shutdown when there are active | 304 * Mark request as started to prevent shutdown when there are active |
301 * requests. | 305 * requests. |
302 */ | 306 */ |
303 void onRequestStarted(UrlRequest urlRequest) { | 307 void onRequestStarted() { |
304 mActiveRequestCount.incrementAndGet(); | 308 mActiveRequestCount.incrementAndGet(); |
305 } | 309 } |
306 | 310 |
307 /** | 311 /** |
308 * Mark request as completed to allow shutdown when there are no active | 312 * Mark request as completed to allow shutdown when there are no active |
309 * requests. | 313 * requests. |
310 */ | 314 */ |
311 void onRequestDestroyed(UrlRequest urlRequest) { | 315 void onRequestDestroyed() { |
312 mActiveRequestCount.decrementAndGet(); | 316 mActiveRequestCount.decrementAndGet(); |
313 } | 317 } |
314 | 318 |
315 @VisibleForTesting | 319 @VisibleForTesting |
316 long getUrlRequestContextAdapter() { | 320 long getUrlRequestContextAdapter() { |
317 synchronized (mLock) { | 321 synchronized (mLock) { |
318 checkHaveAdapter(); | 322 checkHaveAdapter(); |
319 return mUrlRequestContextAdapter; | 323 return mUrlRequestContextAdapter; |
320 } | 324 } |
321 } | 325 } |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 @NativeClassQualifiedName("CronetURLRequestContextAdapter") | 426 @NativeClassQualifiedName("CronetURLRequestContextAdapter") |
423 private native void nativeEnableNetworkQualityEstimator( | 427 private native void nativeEnableNetworkQualityEstimator( |
424 long nativePtr, boolean useLocalHostRequests, boolean useSmallerResp
onses); | 428 long nativePtr, boolean useLocalHostRequests, boolean useSmallerResp
onses); |
425 | 429 |
426 @NativeClassQualifiedName("CronetURLRequestContextAdapter") | 430 @NativeClassQualifiedName("CronetURLRequestContextAdapter") |
427 private native void nativeProvideRTTObservations(long nativePtr, boolean sho
uld); | 431 private native void nativeProvideRTTObservations(long nativePtr, boolean sho
uld); |
428 | 432 |
429 @NativeClassQualifiedName("CronetURLRequestContextAdapter") | 433 @NativeClassQualifiedName("CronetURLRequestContextAdapter") |
430 private native void nativeProvideThroughputObservations(long nativePtr, bool
ean should); | 434 private native void nativeProvideThroughputObservations(long nativePtr, bool
ean should); |
431 } | 435 } |
OLD | NEW |