OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_ANDROID_NET_NETWORK_QUALITY_PROVIDER_H_ | |
6 #define CHROME_BROWSER_ANDROID_NET_NETWORK_QUALITY_PROVIDER_H_ | |
7 | |
8 #include <jni.h> | |
9 #include <stdint.h> | |
10 | |
11 #include "base/android/scoped_java_ref.h" | |
12 #include "base/macros.h" | |
13 #include "base/memory/weak_ptr.h" | |
14 #include "base/threading/thread_checker.h" | |
15 #include "base/time/time.h" | |
16 | |
17 // Native class that calls Java code exposed by | |
18 // NetworkQualityProviderHelper.java. | |
19 class NetworkQualityProvider { | |
20 public: | |
21 // Constructs and initializes the underlying provider. | |
22 NetworkQualityProvider(); | |
23 | |
24 virtual ~NetworkQualityProvider(); | |
25 | |
26 // Returns true only if network quality estimate is available. | |
27 bool IsEstimateAvailable(); | |
28 | |
29 // Returns true if the estimated RTT duration is available, and sets |rtt| to | |
30 // the estimate. | |
31 bool GetRTT(base::TimeDelta* rtt); | |
32 | |
33 // Returns true if the estimated downstream throughput (in Kbps) is available, | |
34 // and sets |downstream_throughput_kbps| to the estimate. | |
35 bool GetDownstreamThroughputKbps(int32_t* downstream_throughput_kbps); | |
36 | |
37 // Returns true if the estimated upstream throughput (in Kbps) is available, | |
38 // and sets |upstream_throughput_kbps| to the estimate. | |
39 bool GetUpstreamThroughputKbps(int32_t* upstream_throughput_kbps); | |
40 | |
41 // Returns true if the time since network quality was last updated is | |
42 // available, and sets |time_since_last_update| to that value. | |
43 bool GetTimeSinceLastUpdate(base::TimeDelta* time_since_last_update); | |
44 | |
45 private: | |
46 // Value returned if valid value is unavailable. | |
47 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
| |
48 | |
49 base::android::ScopedJavaGlobalRef<jobject> j_network_quality_provider_; | |
50 | |
51 base::ThreadChecker thread_checker_; | |
52 | |
53 DISALLOW_COPY_AND_ASSIGN(NetworkQualityProvider); | |
54 }; | |
55 | |
56 bool RegisterNetworkQualityProvider(JNIEnv* env); | |
57 | |
58 #endif // CHROME_BROWSER_ANDROID_NET_NETWORK_QUALITY_PROVIDER_H_ | |
OLD | NEW |