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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 } | 136 } |
137 return new CronetUrlRequest(this, mUrlRequestContextAdapter, url, pr
iority, callback, | 137 return new CronetUrlRequest(this, mUrlRequestContextAdapter, url, pr
iority, callback, |
138 executor, requestAnnotations, metricsCollectionEnabled); | 138 executor, requestAnnotations, metricsCollectionEnabled); |
139 } | 139 } |
140 } | 140 } |
141 | 141 |
142 @Override | 142 @Override |
143 BidirectionalStream createBidirectionalStream(String url, BidirectionalStrea
m.Callback callback, | 143 BidirectionalStream createBidirectionalStream(String url, BidirectionalStrea
m.Callback callback, |
144 Executor executor, String httpMethod, List<Map.Entry<String, String>
> requestHeaders, | 144 Executor executor, String httpMethod, List<Map.Entry<String, String>
> requestHeaders, |
145 @BidirectionalStream.Builder.StreamPriority int priority) { | 145 @BidirectionalStream.Builder.StreamPriority int priority) { |
146 throw new UnsupportedOperationException(); | 146 synchronized (mLock) { |
| 147 checkHaveAdapter(); |
| 148 return new CronetBidirectionalStream( |
| 149 this, url, priority, callback, executor, httpMethod, request
Headers); |
| 150 } |
147 } | 151 } |
148 | 152 |
149 @Override | 153 @Override |
150 public boolean isEnabled() { | 154 public boolean isEnabled() { |
151 return Build.VERSION.SDK_INT >= 14; | 155 return Build.VERSION.SDK_INT >= 14; |
152 } | 156 } |
153 | 157 |
154 @Override | 158 @Override |
155 public String getVersionString() { | 159 public String getVersionString() { |
156 return "Cronet/" + Version.getVersion(); | 160 return "Cronet/" + Version.getVersion(); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 | 340 |
337 @Override | 341 @Override |
338 public URLStreamHandlerFactory createURLStreamHandlerFactory() { | 342 public URLStreamHandlerFactory createURLStreamHandlerFactory() { |
339 return new CronetURLStreamHandlerFactory(this); | 343 return new CronetURLStreamHandlerFactory(this); |
340 } | 344 } |
341 | 345 |
342 /** | 346 /** |
343 * Mark request as started to prevent shutdown when there are active | 347 * Mark request as started to prevent shutdown when there are active |
344 * requests. | 348 * requests. |
345 */ | 349 */ |
346 void onRequestStarted(UrlRequest urlRequest) { | 350 void onRequestStarted() { |
347 mActiveRequestCount.incrementAndGet(); | 351 mActiveRequestCount.incrementAndGet(); |
348 } | 352 } |
349 | 353 |
350 /** | 354 /** |
351 * Mark request as finished to allow shutdown when there are no active | 355 * Mark request as finished to allow shutdown when there are no active |
352 * requests. | 356 * requests. |
353 */ | 357 */ |
354 void onRequestDestroyed(UrlRequest urlRequest) { | 358 void onRequestDestroyed() { |
355 mActiveRequestCount.decrementAndGet(); | 359 mActiveRequestCount.decrementAndGet(); |
356 } | 360 } |
357 | 361 |
358 @VisibleForTesting | 362 @VisibleForTesting |
359 long getUrlRequestContextAdapter() { | 363 long getUrlRequestContextAdapter() { |
360 synchronized (mLock) { | 364 synchronized (mLock) { |
361 checkHaveAdapter(); | 365 checkHaveAdapter(); |
362 return mUrlRequestContextAdapter; | 366 return mUrlRequestContextAdapter; |
363 } | 367 } |
364 } | 368 } |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 @NativeClassQualifiedName("CronetURLRequestContextAdapter") | 499 @NativeClassQualifiedName("CronetURLRequestContextAdapter") |
496 private native void nativeEnableNetworkQualityEstimator( | 500 private native void nativeEnableNetworkQualityEstimator( |
497 long nativePtr, boolean useLocalHostRequests, boolean useSmallerResp
onses); | 501 long nativePtr, boolean useLocalHostRequests, boolean useSmallerResp
onses); |
498 | 502 |
499 @NativeClassQualifiedName("CronetURLRequestContextAdapter") | 503 @NativeClassQualifiedName("CronetURLRequestContextAdapter") |
500 private native void nativeProvideRTTObservations(long nativePtr, boolean sho
uld); | 504 private native void nativeProvideRTTObservations(long nativePtr, boolean sho
uld); |
501 | 505 |
502 @NativeClassQualifiedName("CronetURLRequestContextAdapter") | 506 @NativeClassQualifiedName("CronetURLRequestContextAdapter") |
503 private native void nativeProvideThroughputObservations(long nativePtr, bool
ean should); | 507 private native void nativeProvideThroughputObservations(long nativePtr, bool
ean should); |
504 } | 508 } |
OLD | NEW |