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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
142 | 142 |
143 @Override | 143 @Override |
144 public UrlRequest createRequest(String url, UrlRequest.Callback callback, Ex ecutor executor, | 144 public UrlRequest createRequest(String url, UrlRequest.Callback callback, Ex ecutor executor, |
145 int priority, Collection<Object> requestAnnotations) { | 145 int priority, Collection<Object> requestAnnotations) { |
146 synchronized (mLock) { | 146 synchronized (mLock) { |
147 checkHaveAdapter(); | 147 checkHaveAdapter(); |
148 boolean metricsCollectionEnabled = mNetworkQualityEstimatorEnabled; | 148 boolean metricsCollectionEnabled = mNetworkQualityEstimatorEnabled; |
149 if (metricsCollectionEnabled) { // Collect metrics only if someone i s listening. | 149 if (metricsCollectionEnabled) { // Collect metrics only if someone i s listening. |
150 synchronized (mNetworkQualityLock) { | 150 synchronized (mNetworkQualityLock) { |
151 metricsCollectionEnabled = !mFinishedListenerList.isEmpty(); | 151 metricsCollectionEnabled = !mFinishedListenerList.isEmpty(); |
152 } | 152 } |
pauljensen
2016/01/04 19:56:00
I imagine there will be demand for metrics collect
mef
2016/01/04 22:27:08
Yes, but not in this CL.
| |
153 } | 153 } |
154 return new CronetUrlRequest(this, mUrlRequestContextAdapter, url, pr iority, callback, | 154 return new CronetUrlRequest(this, mUrlRequestContextAdapter, url, pr iority, callback, |
155 executor, requestAnnotations, metricsCollectionEnabled); | 155 executor, requestAnnotations, metricsCollectionEnabled); |
156 } | 156 } |
157 } | 157 } |
158 | 158 |
159 @Override | 159 @Override |
160 BidirectionalStream createBidirectionalStream(String url, BidirectionalStrea m.Callback callback, | 160 BidirectionalStream createBidirectionalStream(String url, BidirectionalStrea m.Callback callback, |
161 Executor executor, String httpMethod, List<Map.Entry<String, String> > requestHeaders, | 161 Executor executor, String httpMethod, List<Map.Entry<String, String> > requestHeaders, |
162 @BidirectionalStream.Builder.StreamPriority int priority) { | 162 @BidirectionalStream.Builder.StreamPriority int priority) { |
163 throw new UnsupportedOperationException(); | 163 synchronized (mLock) { |
164 checkHaveAdapter(); | |
165 return new CronetBidirectionalStream(this, mUrlRequestContextAdapter , url, priority, | |
166 callback, executor, httpMethod, requestHeaders); | |
167 } | |
164 } | 168 } |
165 | 169 |
166 @Override | 170 @Override |
167 public boolean isEnabled() { | 171 public boolean isEnabled() { |
168 return Build.VERSION.SDK_INT >= 14; | 172 return Build.VERSION.SDK_INT >= 14; |
169 } | 173 } |
170 | 174 |
171 @Override | 175 @Override |
172 public String getVersionString() { | 176 public String getVersionString() { |
173 return "Cronet/" + Version.getVersion(); | 177 return "Cronet/" + Version.getVersion(); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
353 | 357 |
354 @Override | 358 @Override |
355 public URLStreamHandlerFactory createURLStreamHandlerFactory() { | 359 public URLStreamHandlerFactory createURLStreamHandlerFactory() { |
356 return new CronetURLStreamHandlerFactory(this); | 360 return new CronetURLStreamHandlerFactory(this); |
357 } | 361 } |
358 | 362 |
359 /** | 363 /** |
360 * Mark request as started to prevent shutdown when there are active | 364 * Mark request as started to prevent shutdown when there are active |
361 * requests. | 365 * requests. |
362 */ | 366 */ |
363 void onRequestStarted(UrlRequest urlRequest) { | 367 void onRequestStarted() { |
364 mActiveRequestCount.incrementAndGet(); | 368 mActiveRequestCount.incrementAndGet(); |
365 } | 369 } |
366 | 370 |
367 /** | 371 /** |
368 * Mark request as finished to allow shutdown when there are no active | 372 * Mark request as finished to allow shutdown when there are no active |
369 * requests. | 373 * requests. |
370 */ | 374 */ |
371 void onRequestDestroyed(UrlRequest urlRequest) { | 375 void onRequestDestroyed() { |
372 mActiveRequestCount.decrementAndGet(); | 376 mActiveRequestCount.decrementAndGet(); |
373 } | 377 } |
374 | 378 |
375 @VisibleForTesting | 379 @VisibleForTesting |
376 long getUrlRequestContextAdapter() { | 380 long getUrlRequestContextAdapter() { |
377 synchronized (mLock) { | 381 synchronized (mLock) { |
378 checkHaveAdapter(); | 382 checkHaveAdapter(); |
379 return mUrlRequestContextAdapter; | 383 return mUrlRequestContextAdapter; |
380 } | 384 } |
381 } | 385 } |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
512 @NativeClassQualifiedName("CronetURLRequestContextAdapter") | 516 @NativeClassQualifiedName("CronetURLRequestContextAdapter") |
513 private native void nativeEnableNetworkQualityEstimator( | 517 private native void nativeEnableNetworkQualityEstimator( |
514 long nativePtr, boolean useLocalHostRequests, boolean useSmallerResp onses); | 518 long nativePtr, boolean useLocalHostRequests, boolean useSmallerResp onses); |
515 | 519 |
516 @NativeClassQualifiedName("CronetURLRequestContextAdapter") | 520 @NativeClassQualifiedName("CronetURLRequestContextAdapter") |
517 private native void nativeProvideRTTObservations(long nativePtr, boolean sho uld); | 521 private native void nativeProvideRTTObservations(long nativePtr, boolean sho uld); |
518 | 522 |
519 @NativeClassQualifiedName("CronetURLRequestContextAdapter") | 523 @NativeClassQualifiedName("CronetURLRequestContextAdapter") |
520 private native void nativeProvideThroughputObservations(long nativePtr, bool ean should); | 524 private native void nativeProvideThroughputObservations(long nativePtr, bool ean should); |
521 } | 525 } |
OLD | NEW |