Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: components/cronet/android/cronet_url_request_context_adapter.h

Issue 2223773003: Expose effective connection type to Cronet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased, addressed comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
21 #include "net/nqe/network_quality_estimator.h" 22 #include "net/nqe/network_quality_estimator.h"
22 #include "net/nqe/network_quality_observation_source.h" 23 #include "net/nqe/network_quality_observation_source.h"
23 24
24 class PrefService; 25 class PrefService;
25 26
26 namespace base { 27 namespace base {
27 class SingleThreadTaskRunner; 28 class SingleThreadTaskRunner;
28 class TimeTicks; 29 class TimeTicks;
29 } // namespace base 30 } // namespace base
30 31
(...skipping 11 matching lines...) Expand all
42 #if defined(DATA_REDUCTION_PROXY_SUPPORT) 43 #if defined(DATA_REDUCTION_PROXY_SUPPORT)
43 class CronetDataReductionProxy; 44 class CronetDataReductionProxy;
44 #endif 45 #endif
45 46
46 struct URLRequestContextConfig; 47 struct URLRequestContextConfig;
47 48
48 bool CronetUrlRequestContextAdapterRegisterJni(JNIEnv* env); 49 bool CronetUrlRequestContextAdapterRegisterJni(JNIEnv* env);
49 50
50 // Adapter between Java CronetUrlRequestContext and net::URLRequestContext. 51 // Adapter between Java CronetUrlRequestContext and net::URLRequestContext.
51 class CronetURLRequestContextAdapter 52 class CronetURLRequestContextAdapter
52 : public net::NetworkQualityEstimator::RTTObserver, 53 : public net::NetworkQualityEstimator::EffectiveConnectionTypeObserver,
54 public net::NetworkQualityEstimator::RTTObserver,
53 public net::NetworkQualityEstimator::ThroughputObserver { 55 public net::NetworkQualityEstimator::ThroughputObserver {
54 public: 56 public:
55 explicit CronetURLRequestContextAdapter( 57 explicit CronetURLRequestContextAdapter(
56 std::unique_ptr<URLRequestContextConfig> context_config); 58 std::unique_ptr<URLRequestContextConfig> context_config);
57 59
58 ~CronetURLRequestContextAdapter() override; 60 ~CronetURLRequestContextAdapter() override;
59 61
60 // Called on main Java thread to initialize URLRequestContext. 62 // Called on main Java thread to initialize URLRequestContext.
61 void InitRequestContextOnMainThread( 63 void InitRequestContextOnMainThread(
62 JNIEnv* env, 64 JNIEnv* env,
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 // Configures the network quality estimator to observe requests to localhost, 144 // Configures the network quality estimator to observe requests to localhost,
143 // as well as to use smaller responses when estimating throughput. This 145 // as well as to use smaller responses when estimating throughput. This
144 // should only be used for testing. 146 // should only be used for testing.
145 void ConfigureNetworkQualityEstimatorOnNetworkThreadForTesting( 147 void ConfigureNetworkQualityEstimatorOnNetworkThreadForTesting(
146 bool use_local_host_requests, 148 bool use_local_host_requests,
147 bool use_smaller_responses); 149 bool use_smaller_responses);
148 150
149 void ProvideRTTObservationsOnNetworkThread(bool should); 151 void ProvideRTTObservationsOnNetworkThread(bool should);
150 void ProvideThroughputObservationsOnNetworkThread(bool should); 152 void ProvideThroughputObservationsOnNetworkThread(bool should);
151 153
154 // net::NetworkQualityEstimator::EffectiveConnectionTypeObserver
155 // implementation.
156 void OnEffectiveConnectionTypeChanged(
157 net::EffectiveConnectionType effective_connection_type) override;
158
152 // net::NetworkQualityEstimator::RTTObserver implementation. 159 // net::NetworkQualityEstimator::RTTObserver implementation.
153 void OnRTTObservation(int32_t rtt_ms, 160 void OnRTTObservation(int32_t rtt_ms,
154 const base::TimeTicks& timestamp, 161 const base::TimeTicks& timestamp,
155 net::NetworkQualityObservationSource source) override; 162 net::NetworkQualityObservationSource source) override;
156 163
157 // net::NetworkQualityEstimator::ThroughputObserver implementation. 164 // net::NetworkQualityEstimator::ThroughputObserver implementation.
158 void OnThroughputObservation( 165 void OnThroughputObservation(
159 int32_t throughput_kbps, 166 int32_t throughput_kbps,
160 const base::TimeTicks& timestamp, 167 const base::TimeTicks& timestamp,
161 net::NetworkQualityObservationSource source) override; 168 net::NetworkQualityObservationSource source) override;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 #if defined(DATA_REDUCTION_PROXY_SUPPORT) 212 #if defined(DATA_REDUCTION_PROXY_SUPPORT)
206 std::unique_ptr<CronetDataReductionProxy> data_reduction_proxy_; 213 std::unique_ptr<CronetDataReductionProxy> data_reduction_proxy_;
207 #endif 214 #endif
208 215
209 DISALLOW_COPY_AND_ASSIGN(CronetURLRequestContextAdapter); 216 DISALLOW_COPY_AND_ASSIGN(CronetURLRequestContextAdapter);
210 }; 217 };
211 218
212 } // namespace cronet 219 } // namespace cronet
213 220
214 #endif // COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_ 221 #endif // COMPONENTS_CRONET_ANDROID_CRONET_URL_REQUEST_CONTEXT_ADAPTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698