| 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 #ifndef COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_ | 5 #ifndef COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_ |
| 6 #define COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_ | 6 #define COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <queue> | 12 #include <queue> |
| 13 #include <string> | 13 #include <string> |
| 14 | 14 |
| 15 #include "base/android/scoped_java_ref.h" | 15 #include "base/android/scoped_java_ref.h" |
| 16 #include "base/callback.h" | 16 #include "base/callback.h" |
| 17 #include "base/macros.h" | 17 #include "base/macros.h" |
| 18 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
| 19 #include "base/threading/thread.h" | 19 #include "base/threading/thread.h" |
| 20 #include "components/prefs/json_pref_store.h" | 20 #include "components/prefs/json_pref_store.h" |
| 21 #include "net/nqe/effective_connection_type.h" | |
| 22 #include "net/nqe/network_quality_estimator.h" | 21 #include "net/nqe/network_quality_estimator.h" |
| 23 #include "net/nqe/network_quality_observation_source.h" | 22 #include "net/nqe/network_quality_observation_source.h" |
| 24 | 23 |
| 25 class PrefService; | 24 class PrefService; |
| 26 | 25 |
| 27 namespace base { | 26 namespace base { |
| 28 class SingleThreadTaskRunner; | 27 class SingleThreadTaskRunner; |
| 29 class TimeTicks; | 28 class TimeTicks; |
| 30 } // namespace base | 29 } // namespace base |
| 31 | 30 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 43 #if defined(DATA_REDUCTION_PROXY_SUPPORT) | 42 #if defined(DATA_REDUCTION_PROXY_SUPPORT) |
| 44 class CronetDataReductionProxy; | 43 class CronetDataReductionProxy; |
| 45 #endif | 44 #endif |
| 46 | 45 |
| 47 struct URLRequestContextConfig; | 46 struct URLRequestContextConfig; |
| 48 | 47 |
| 49 bool CronetUrlRequestContextAdapterRegisterJni(JNIEnv* env); | 48 bool CronetUrlRequestContextAdapterRegisterJni(JNIEnv* env); |
| 50 | 49 |
| 51 // Adapter between Java CronetUrlRequestContext and net::URLRequestContext. | 50 // Adapter between Java CronetUrlRequestContext and net::URLRequestContext. |
| 52 class CronetURLRequestContextAdapter | 51 class CronetURLRequestContextAdapter |
| 53 : public net::NetworkQualityEstimator::EffectiveConnectionTypeObserver, | 52 : public net::NetworkQualityEstimator::RTTObserver, |
| 54 public net::NetworkQualityEstimator::RTTObserver, | |
| 55 public net::NetworkQualityEstimator::ThroughputObserver { | 53 public net::NetworkQualityEstimator::ThroughputObserver { |
| 56 public: | 54 public: |
| 57 explicit CronetURLRequestContextAdapter( | 55 explicit CronetURLRequestContextAdapter( |
| 58 std::unique_ptr<URLRequestContextConfig> context_config); | 56 std::unique_ptr<URLRequestContextConfig> context_config); |
| 59 | 57 |
| 60 ~CronetURLRequestContextAdapter() override; | 58 ~CronetURLRequestContextAdapter() override; |
| 61 | 59 |
| 62 // Called on main Java thread to initialize URLRequestContext. | 60 // Called on main Java thread to initialize URLRequestContext. |
| 63 void InitRequestContextOnMainThread( | 61 void InitRequestContextOnMainThread( |
| 64 JNIEnv* env, | 62 JNIEnv* env, |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 // Configures the network quality estimator to observe requests to localhost, | 142 // Configures the network quality estimator to observe requests to localhost, |
| 145 // as well as to use smaller responses when estimating throughput. This | 143 // as well as to use smaller responses when estimating throughput. This |
| 146 // should only be used for testing. | 144 // should only be used for testing. |
| 147 void ConfigureNetworkQualityEstimatorOnNetworkThreadForTesting( | 145 void ConfigureNetworkQualityEstimatorOnNetworkThreadForTesting( |
| 148 bool use_local_host_requests, | 146 bool use_local_host_requests, |
| 149 bool use_smaller_responses); | 147 bool use_smaller_responses); |
| 150 | 148 |
| 151 void ProvideRTTObservationsOnNetworkThread(bool should); | 149 void ProvideRTTObservationsOnNetworkThread(bool should); |
| 152 void ProvideThroughputObservationsOnNetworkThread(bool should); | 150 void ProvideThroughputObservationsOnNetworkThread(bool should); |
| 153 | 151 |
| 154 // net::NetworkQualityEstimator::EffectiveConnectionTypeObserver | |
| 155 // implementation. | |
| 156 void OnEffectiveConnectionTypeChanged( | |
| 157 net::EffectiveConnectionType effective_connection_type) override; | |
| 158 | |
| 159 // net::NetworkQualityEstimator::RTTObserver implementation. | 152 // net::NetworkQualityEstimator::RTTObserver implementation. |
| 160 void OnRTTObservation(int32_t rtt_ms, | 153 void OnRTTObservation(int32_t rtt_ms, |
| 161 const base::TimeTicks& timestamp, | 154 const base::TimeTicks& timestamp, |
| 162 net::NetworkQualityObservationSource source) override; | 155 net::NetworkQualityObservationSource source) override; |
| 163 | 156 |
| 164 // net::NetworkQualityEstimator::ThroughputObserver implementation. | 157 // net::NetworkQualityEstimator::ThroughputObserver implementation. |
| 165 void OnThroughputObservation( | 158 void OnThroughputObservation( |
| 166 int32_t throughput_kbps, | 159 int32_t throughput_kbps, |
| 167 const base::TimeTicks& timestamp, | 160 const base::TimeTicks& timestamp, |
| 168 net::NetworkQualityObservationSource source) override; | 161 net::NetworkQualityObservationSource source) override; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 #if defined(DATA_REDUCTION_PROXY_SUPPORT) | 205 #if defined(DATA_REDUCTION_PROXY_SUPPORT) |
| 213 std::unique_ptr<CronetDataReductionProxy> data_reduction_proxy_; | 206 std::unique_ptr<CronetDataReductionProxy> data_reduction_proxy_; |
| 214 #endif | 207 #endif |
| 215 | 208 |
| 216 DISALLOW_COPY_AND_ASSIGN(CronetURLRequestContextAdapter); | 209 DISALLOW_COPY_AND_ASSIGN(CronetURLRequestContextAdapter); |
| 217 }; | 210 }; |
| 218 | 211 |
| 219 } // namespace cronet | 212 } // namespace cronet |
| 220 | 213 |
| 221 #endif // COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_ | 214 #endif // COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_ |
| OLD | NEW |