| Index: components/cronet/android/cronet_url_request_context_adapter.h
|
| diff --git a/components/cronet/android/cronet_url_request_context_adapter.h b/components/cronet/android/cronet_url_request_context_adapter.h
|
| index 3d83f013480659658857edb21599608cc6500648..dd60b66897400930665ce1b65808a106c9963181 100644
|
| --- a/components/cronet/android/cronet_url_request_context_adapter.h
|
| +++ b/components/cronet/android/cronet_url_request_context_adapter.h
|
| @@ -17,16 +17,19 @@
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/prefs/json_pref_store.h"
|
| #include "base/threading/thread.h"
|
| +#include "net/base/network_quality_estimator.h"
|
|
|
| class PrefService;
|
|
|
| namespace base {
|
| class SingleThreadTaskRunner;
|
| +class TimeTicks;
|
| } // namespace base
|
|
|
| namespace net {
|
| class HttpServerPropertiesManager;
|
| class NetLog;
|
| +class NetworkQualityEstimator;
|
| class ProxyConfigService;
|
| class SdchOwner;
|
| class URLRequestContext;
|
| @@ -44,12 +47,14 @@ struct URLRequestContextConfig;
|
| bool CronetUrlRequestContextAdapterRegisterJni(JNIEnv* env);
|
|
|
| // Adapter between Java CronetUrlRequestContext and net::URLRequestContext.
|
| -class CronetURLRequestContextAdapter {
|
| +class CronetURLRequestContextAdapter
|
| + : public net::NetworkQualityEstimator::RTTObserver,
|
| + public net::NetworkQualityEstimator::ThroughputObserver {
|
| public:
|
| explicit CronetURLRequestContextAdapter(
|
| scoped_ptr<URLRequestContextConfig> context_config);
|
|
|
| - ~CronetURLRequestContextAdapter();
|
| + ~CronetURLRequestContextAdapter() override;
|
|
|
| // Called on main Java thread to initialize URLRequestContext.
|
| void InitRequestContextOnMainThread(JNIEnv* env, jobject jcaller);
|
| @@ -78,6 +83,19 @@ class CronetURLRequestContextAdapter {
|
| // Called on main Java thread to initialize URLRequestContext.
|
| void InitRequestContextOnMainThread();
|
|
|
| + // Enables the network quality estimator and optionally configures it to
|
| + // observe localhost requests, and to consider smaller responses when
|
| + // observing throughput. It is recommended that both options be set to false.
|
| + void EnableNetworkQualityEstimator(JNIEnv* env,
|
| + jobject jcaller,
|
| + jboolean use_local_host_requests,
|
| + jboolean use_smaller_responses);
|
| +
|
| + // Request that RTT and/or throughput observations should or should not be
|
| + // provided by the network quality estimator.
|
| + void ProvideRTTObservations(JNIEnv* env, jobject jcaller, bool should);
|
| + void ProvideThroughputObservations(JNIEnv* env, jobject jcaller, bool should);
|
| +
|
| private:
|
| // Initializes |context_| on the Network thread.
|
| void InitializeOnNetworkThread(scoped_ptr<URLRequestContextConfig> config,
|
| @@ -99,6 +117,29 @@ class CronetURLRequestContextAdapter {
|
| // Gets the file thread. Create one if there is none.
|
| base::Thread* GetFileThread();
|
|
|
| + // Instantiate and configure the network quality estimator. For default
|
| + // behavior, parameters should be set to false; otherwise the estimator
|
| + // can be configured to observe requests to localhost, as well as to use
|
| + // observe smaller responses when estimating throughput.
|
| + void EnableNetworkQualityEstimatorOnNetworkThread(
|
| + bool use_local_host_requests,
|
| + bool use_smaller_responses);
|
| +
|
| + void ProvideRTTObservationsOnNetworkThread(bool should);
|
| + void ProvideThroughputObservationsOnNetworkThread(bool should);
|
| +
|
| + // net::NetworkQualityEstimator::RTTObserver implementation.
|
| + void OnRTTObservation(
|
| + int32_t rtt_ms,
|
| + const base::TimeTicks& timestamp,
|
| + net::NetworkQualityEstimator::ObservationSource source) override;
|
| +
|
| + // net::NetworkQualityEstimator::ThroughputObserver implementation.
|
| + void OnThroughputObservation(
|
| + int32_t throughput_kbps,
|
| + const base::TimeTicks& timestamp,
|
| + net::NetworkQualityEstimator::ObservationSource source) override;
|
| +
|
| // Network thread is owned by |this|, but is destroyed from java thread.
|
| base::Thread* network_thread_;
|
|
|
| @@ -131,6 +172,12 @@ class CronetURLRequestContextAdapter {
|
| bool is_context_initialized_;
|
| int default_load_flags_;
|
|
|
| + // A network quality estimator.
|
| + scoped_ptr<net::NetworkQualityEstimator> network_quality_estimator_;
|
| +
|
| + // Java object that owns this CronetURLRequestContextAdapter.
|
| + base::android::ScopedJavaGlobalRef<jobject> jcronet_url_request_context_;
|
| +
|
| #if defined(DATA_REDUCTION_PROXY_SUPPORT)
|
| scoped_ptr<CronetDataReductionProxy> data_reduction_proxy_;
|
| #endif
|
|
|