| 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 if (Looper.getMainLooper() == Looper.myLooper()) { | 100 if (Looper.getMainLooper() == Looper.myLooper()) { |
| 101 task.run(); | 101 task.run(); |
| 102 } else { | 102 } else { |
| 103 new Handler(Looper.getMainLooper()).post(task); | 103 new Handler(Looper.getMainLooper()).post(task); |
| 104 } | 104 } |
| 105 } | 105 } |
| 106 | 106 |
| 107 static long createNativeUrlRequestContextConfig(CronetEngine.Builder builder
) { | 107 static long createNativeUrlRequestContextConfig(CronetEngine.Builder builder
) { |
| 108 final long urlRequestContextConfig = nativeCreateRequestContextConfig( | 108 final long urlRequestContextConfig = nativeCreateRequestContextConfig( |
| 109 builder.getUserAgent(), builder.storagePath(), builder.quicEnabl
ed(), | 109 builder.getUserAgent(), builder.storagePath(), builder.quicEnabl
ed(), |
| 110 builder.http2Enabled(), builder.sdchEnabled(), builder.dataReduc
tionProxyKey(), | 110 builder.getDefaultQuicUserAgentId(), builder.http2Enabled(), bui
lder.sdchEnabled(), |
| 111 builder.dataReductionProxyPrimaryProxy(), builder.dataReductionP
roxyFallbackProxy(), | 111 builder.dataReductionProxyKey(), builder.dataReductionProxyPrima
ryProxy(), |
| 112 builder.dataReductionProxyFallbackProxy(), |
| 112 builder.dataReductionProxySecureProxyCheckUrl(), builder.cacheDi
sabled(), | 113 builder.dataReductionProxySecureProxyCheckUrl(), builder.cacheDi
sabled(), |
| 113 builder.httpCacheMode(), builder.httpCacheMaxSize(), builder.exp
erimentalOptions(), | 114 builder.httpCacheMode(), builder.httpCacheMaxSize(), builder.exp
erimentalOptions(), |
| 114 builder.mockCertVerifier()); | 115 builder.mockCertVerifier()); |
| 115 for (Builder.QuicHint quicHint : builder.quicHints()) { | 116 for (Builder.QuicHint quicHint : builder.quicHints()) { |
| 116 nativeAddQuicHint(urlRequestContextConfig, quicHint.mHost, quicHint.
mPort, | 117 nativeAddQuicHint(urlRequestContextConfig, quicHint.mHost, quicHint.
mPort, |
| 117 quicHint.mAlternatePort); | 118 quicHint.mAlternatePort); |
| 118 } | 119 } |
| 119 for (Builder.Pkp pkp : builder.publicKeyPins()) { | 120 for (Builder.Pkp pkp : builder.publicKeyPins()) { |
| 120 nativeAddPkp(urlRequestContextConfig, pkp.mHost, pkp.mHashes, pkp.mI
ncludeSubdomains, | 121 nativeAddPkp(urlRequestContextConfig, pkp.mHost, pkp.mHashes, pkp.mI
ncludeSubdomains, |
| 121 pkp.mExpirationDate.getTime()); | 122 pkp.mExpirationDate.getTime()); |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 try { | 459 try { |
| 459 mNetworkQualityExecutor.execute(task); | 460 mNetworkQualityExecutor.execute(task); |
| 460 } catch (RejectedExecutionException failException) { | 461 } catch (RejectedExecutionException failException) { |
| 461 Log.e(CronetUrlRequestContext.LOG_TAG, "Exception posting task to ex
ecutor", | 462 Log.e(CronetUrlRequestContext.LOG_TAG, "Exception posting task to ex
ecutor", |
| 462 failException); | 463 failException); |
| 463 } | 464 } |
| 464 } | 465 } |
| 465 | 466 |
| 466 // Native methods are implemented in cronet_url_request_context_adapter.cc. | 467 // Native methods are implemented in cronet_url_request_context_adapter.cc. |
| 467 private static native long nativeCreateRequestContextConfig(String userAgent
, | 468 private static native long nativeCreateRequestContextConfig(String userAgent
, |
| 468 String storagePath, boolean quicEnabled, boolean http2Enabled, boole
an sdchEnabled, | 469 String storagePath, boolean quicEnabled, String quicUserAgentId, boo
lean http2Enabled, |
| 469 String dataReductionProxyKey, String dataReductionProxyPrimaryProxy, | 470 boolean sdchEnabled, String dataReductionProxyKey, |
| 470 String dataReductionProxyFallbackProxy, String dataReductionProxySec
ureProxyCheckUrl, | 471 String dataReductionProxyPrimaryProxy, String dataReductionProxyFall
backProxy, |
| 471 boolean disableCache, int httpCacheMode, long httpCacheMaxSize, | 472 String dataReductionProxySecureProxyCheckUrl, boolean disableCache,
int httpCacheMode, |
| 472 String experimentalOptions, long mockCertVerifier); | 473 long httpCacheMaxSize, String experimentalOptions, long mockCertVeri
fier); |
| 473 | 474 |
| 474 private static native void nativeAddQuicHint( | 475 private static native void nativeAddQuicHint( |
| 475 long urlRequestContextConfig, String host, int port, int alternatePo
rt); | 476 long urlRequestContextConfig, String host, int port, int alternatePo
rt); |
| 476 | 477 |
| 477 private static native void nativeAddPkp(long urlRequestContextConfig, String
host, | 478 private static native void nativeAddPkp(long urlRequestContextConfig, String
host, |
| 478 byte[][] hashes, boolean includeSubdomains, long expirationTime); | 479 byte[][] hashes, boolean includeSubdomains, long expirationTime); |
| 479 | 480 |
| 480 private static native long nativeCreateRequestContextAdapter(long urlRequest
ContextConfig); | 481 private static native long nativeCreateRequestContextAdapter(long urlRequest
ContextConfig); |
| 481 | 482 |
| 482 private static native int nativeSetMinLogLevel(int loggingLevel); | 483 private static native int nativeSetMinLogLevel(int loggingLevel); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 499 @NativeClassQualifiedName("CronetURLRequestContextAdapter") | 500 @NativeClassQualifiedName("CronetURLRequestContextAdapter") |
| 500 private native void nativeEnableNetworkQualityEstimator( | 501 private native void nativeEnableNetworkQualityEstimator( |
| 501 long nativePtr, boolean useLocalHostRequests, boolean useSmallerResp
onses); | 502 long nativePtr, boolean useLocalHostRequests, boolean useSmallerResp
onses); |
| 502 | 503 |
| 503 @NativeClassQualifiedName("CronetURLRequestContextAdapter") | 504 @NativeClassQualifiedName("CronetURLRequestContextAdapter") |
| 504 private native void nativeProvideRTTObservations(long nativePtr, boolean sho
uld); | 505 private native void nativeProvideRTTObservations(long nativePtr, boolean sho
uld); |
| 505 | 506 |
| 506 @NativeClassQualifiedName("CronetURLRequestContextAdapter") | 507 @NativeClassQualifiedName("CronetURLRequestContextAdapter") |
| 507 private native void nativeProvideThroughputObservations(long nativePtr, bool
ean should); | 508 private native void nativeProvideThroughputObservations(long nativePtr, bool
ean should); |
| 508 } | 509 } |
| OLD | NEW |