Chromium Code Reviews| 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 ddfa1bac77a3320c05bb9d34d0b5bc5849c429c7..4b666183644a406a60e5687da1b6fcb9dc6109a7 100644 |
| --- a/components/cronet/android/cronet_url_request_context_adapter.h |
| +++ b/components/cronet/android/cronet_url_request_context_adapter.h |
| @@ -17,15 +17,19 @@ |
| #include "base/memory/scoped_ptr.h" |
| #include "base/prefs/json_pref_store.h" |
| #include "base/threading/thread.h" |
| +#include "base/time/time.h" |
|
mef
2015/08/28 20:53:16
unused?
bengr
2015/08/28 23:51:36
Done.
|
| +#include "net/base/network_quality_estimator.h" |
| class PrefService; |
| namespace base { |
| class SingleThreadTaskRunner; |
| +class Time; |
|
mef
2015/08/28 20:53:16
unused?
bengr
2015/08/28 23:51:36
Done.
|
| } // namespace base |
| namespace net { |
| class HttpServerPropertiesManager; |
| +class NetworkQualityEstimator; |
|
mef
2015/08/28 20:53:15
do you need this if you have include?
bengr
2015/08/28 23:51:36
Done.
|
| class ProxyConfigService; |
| class SdchOwner; |
| class URLRequestContext; |
| @@ -43,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); |
| @@ -77,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, |
| @@ -98,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, |
|
mef
2015/08/28 20:53:16
class TimeTicks on top?
bengr
2015/08/28 23:51:36
Done.
|
| + 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_; |
| @@ -129,6 +171,11 @@ class CronetURLRequestContextAdapter { |
| bool is_context_initialized_; |
| int default_load_flags_; |
| + // A network quality estimator. |
| + scoped_ptr<net::NetworkQualityEstimator> network_quality_estimator_; |
| + |
| + base::android::ScopedJavaGlobalRef<jobject> jcronet_url_request_context_; |
|
mef
2015/08/28 20:53:16
add comment that this is java-side owner?
bengr
2015/08/28 23:51:36
Done.
|
| + |
| #if defined(DATA_REDUCTION_PROXY_SUPPORT) |
| scoped_ptr<CronetDataReductionProxy> data_reduction_proxy_; |
| #endif |