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

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: Created 5 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 side-by-side diff with in-line comments
Download patch
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..b982c1f7a48c6290933e691f25dd107a0c5c9cd5 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"
+#include "net/base/network_quality_estimator.h"
class PrefService;
namespace base {
class SingleThreadTaskRunner;
+class Time;
} // namespace base
namespace net {
class HttpServerPropertiesManager;
+class NetworkQualityEstimator;
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::BandwidthObserver {
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,16 @@ class CronetURLRequestContextAdapter {
// Called on main Java thread to initialize URLRequestContext.
void InitRequestContextOnMainThread();
+
+ void ConfigureNetworkQualityEstimator(JNIEnv* env, jobject jcaller,
mef 2015/08/11 17:16:26 need comment, don't need nl above.
bengr 2015/08/25 23:43:34 Done.
+ jboolean use_local_host_requests,
+ jboolean use_smaller_responses);
+
+ // Request that RTT and/or bandwidth observations should or should not be
+ // provided by the network quality estimator.
+ void ProvideRTTObservations(JNIEnv* env, jobject jcaller, bool should);
mef 2015/08/11 17:16:26 Would it make sens to combine these 3 methods into
bengr 2015/08/25 23:43:34 Not really. These two are optimizations so that NQ
mef 2015/08/26 16:58:59 Acknowledged.
+ void ProvideBandwidthObservations(JNIEnv* env, jobject jcaller, bool should);
+
private:
// Initializes |context_| on the Network thread.
void InitializeOnNetworkThread(scoped_ptr<URLRequestContextConfig> config,
@@ -98,6 +114,16 @@ class CronetURLRequestContextAdapter {
// Gets the file thread. Create one if there is none.
base::Thread* GetFileThread();
+ // net::NetworkQualityEstimator::RTTObserver implementation.
+ void OnRTTObservation(
+ int32_t value, const base::TimeTicks& timestamp,
+ net::NetworkQualityEstimator::ObservationSource source) override;
+
+ // net::NetworkQualityEstimator::BandwidthObserver implementation.
+ void OnBandwidthObservation(
+ int32_t value, 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 +155,11 @@ class CronetURLRequestContextAdapter {
bool is_context_initialized_;
int default_load_flags_;
+ // A network quality estimator.
+ scoped_ptr<net::NetworkQualityEstimator> network_quality_estimator_;
mef 2015/08/11 17:16:26 does it need special shutdown handling?
bengr 2015/08/25 23:43:34 Nope.
+
+ base::android::ScopedJavaGlobalRef<jobject> jcronet_url_request_context_;
+
#if defined(DATA_REDUCTION_PROXY_SUPPORT)
scoped_ptr<CronetDataReductionProxy> data_reduction_proxy_;
#endif

Powered by Google App Engine
This is Rietveld 408576698