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

Unified Diff: components/cronet/android/cronet_url_request_context_adapter.h

Issue 1273173002: Added Network Quality Estimator Real-time interface to Cronet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/cronet.gypi ('k') | components/cronet/android/cronet_url_request_context_adapter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..cbc3e2c9db9f16667e787406f910779ffce58613 100644
--- a/components/cronet/android/cronet_url_request_context_adapter.h
+++ b/components/cronet/android/cronet_url_request_context_adapter.h
@@ -17,11 +17,13 @@
#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 {
@@ -44,12 +46,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 +82,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 +116,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 +171,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
« no previous file with comments | « components/cronet.gypi ('k') | components/cronet/android/cronet_url_request_context_adapter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698