Chromium Code Reviews| Index: chrome/browser/android/net/network_quality_provider.h |
| diff --git a/chrome/browser/android/net/network_quality_provider.h b/chrome/browser/android/net/network_quality_provider.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..de7a35131f004dd73473a8e187d6142178307ac7 |
| --- /dev/null |
| +++ b/chrome/browser/android/net/network_quality_provider.h |
| @@ -0,0 +1,58 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_ANDROID_NET_NETWORK_QUALITY_PROVIDER_H_ |
| +#define CHROME_BROWSER_ANDROID_NET_NETWORK_QUALITY_PROVIDER_H_ |
| + |
| +#include <jni.h> |
| +#include <stdint.h> |
| + |
| +#include "base/android/scoped_java_ref.h" |
| +#include "base/macros.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "base/threading/thread_checker.h" |
| +#include "base/time/time.h" |
| + |
| +// Native class that calls Java code exposed by |
| +// NetworkQualityProviderHelper.java. |
| +class NetworkQualityProvider { |
| + public: |
| + // Constructs and initializes the underlying provider. |
| + NetworkQualityProvider(); |
| + |
| + virtual ~NetworkQualityProvider(); |
| + |
| + // Returns true only if network quality estimate is available. |
| + bool IsEstimateAvailable(); |
| + |
| + // Returns true if the estimated RTT duration is available, and sets |rtt| to |
| + // the estimate. |
| + bool GetRTT(base::TimeDelta* rtt); |
| + |
| + // Returns true if the estimated downstream throughput (in Kbps) is available, |
| + // and sets |downstream_throughput_kbps| to the estimate. |
| + bool GetDownstreamThroughputKbps(int32_t* downstream_throughput_kbps); |
| + |
| + // Returns true if the estimated upstream throughput (in Kbps) is available, |
| + // and sets |upstream_throughput_kbps| to the estimate. |
| + bool GetUpstreamThroughputKbps(int32_t* upstream_throughput_kbps); |
| + |
| + // Returns true if the time since network quality was last updated is |
| + // available, and sets |time_since_last_update| to that value. |
| + bool GetTimeSinceLastUpdate(base::TimeDelta* time_since_last_update); |
| + |
| + private: |
| + // Value returned if valid value is unavailable. |
| + int32_t no_value_ = -1; |
|
nyquist
2015/07/22 14:47:00
Should this be initialized here? Seems like you do
tbansal1
2015/07/22 21:11:30
I do it there because I need |env| to initialize i
|
| + |
| + base::android::ScopedJavaGlobalRef<jobject> j_network_quality_provider_; |
| + |
| + base::ThreadChecker thread_checker_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(NetworkQualityProvider); |
| +}; |
| + |
| +bool RegisterNetworkQualityProvider(JNIEnv* env); |
| + |
| +#endif // CHROME_BROWSER_ANDROID_NET_NETWORK_QUALITY_PROVIDER_H_ |