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

Side by Side Diff: chrome/browser/android/net/external_estimate_provider_android.h

Issue 1316863006: Populate EEP estimate in NQE (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed asvitkine comments Created 5 years, 3 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 2015 The Chromium Authors. All rights reserved. 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 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 CHROME_BROWSER_ANDROID_NET_EXTERNAL_ESTIMATE_PROVIDER_ANDROID_H_ 5 #ifndef CHROME_BROWSER_ANDROID_NET_EXTERNAL_ESTIMATE_PROVIDER_ANDROID_H_
6 #define CHROME_BROWSER_ANDROID_NET_EXTERNAL_ESTIMATE_PROVIDER_ANDROID_H_ 6 #define CHROME_BROWSER_ANDROID_NET_EXTERNAL_ESTIMATE_PROVIDER_ANDROID_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 16 matching lines...) Expand all
27 // network change event. 27 // network change event.
28 class ExternalEstimateProviderAndroid 28 class ExternalEstimateProviderAndroid
29 : public net::NetworkChangeNotifier::ConnectionTypeObserver, 29 : public net::NetworkChangeNotifier::ConnectionTypeObserver,
30 public net::ExternalEstimateProvider { 30 public net::ExternalEstimateProvider {
31 public: 31 public:
32 // Constructs and initializes the underlying provider. 32 // Constructs and initializes the underlying provider.
33 ExternalEstimateProviderAndroid(); 33 ExternalEstimateProviderAndroid();
34 34
35 ~ExternalEstimateProviderAndroid() override; 35 ~ExternalEstimateProviderAndroid() override;
36 36
37 // net::ExternalEstimateProvider implementation. 37 // net::ExternalEstimateProvider implementation:
38 bool GetRTT(base::TimeDelta* rtt) const override; 38 bool GetRTT(base::TimeDelta* rtt) const override;
39
40 // net::ExternalEstimateProvider implementation.
41 bool GetDownstreamThroughputKbps( 39 bool GetDownstreamThroughputKbps(
42 int32_t* downstream_throughput_kbps) const override; 40 int32_t* downstream_throughput_kbps) const override;
43
44 // net::ExternalEstimateProvider implementation.
45 bool GetUpstreamThroughputKbps( 41 bool GetUpstreamThroughputKbps(
46 int32_t* upstream_throughput_kbps) const override; 42 int32_t* upstream_throughput_kbps) const override;
47
48 // net::ExternalEstimateProvider implementation.
49 bool GetTimeSinceLastUpdate( 43 bool GetTimeSinceLastUpdate(
50 base::TimeDelta* time_since_last_update) const override; 44 base::TimeDelta* time_since_last_update) const override;
45 void SetUpdatedEstimateDelegate(
46 net::ExternalEstimateProvider::UpdatedEstimateDelegate* delegate)
47 override;
48 void RequestUpdate() const override;
mmenke 2015/09/11 14:28:08 I don't see implementations of these in this CL.
tbansal1 2015/09/11 21:24:30 These have just been rearranged to keep all overri
51 49
52 // NetworkChangeNotifier::ConnectionTypeObserver implementation. 50 // NetworkChangeNotifier::ConnectionTypeObserver implementation.
53 void OnConnectionTypeChanged( 51 void OnConnectionTypeChanged(
54 net::NetworkChangeNotifier::ConnectionType type) override; 52 net::NetworkChangeNotifier::ConnectionType type) override;
55 53
56 // net::ExternalEstimateProvider implementation.
57 void SetUpdatedEstimateDelegate(
58 net::ExternalEstimateProvider::UpdatedEstimateDelegate* delegate)
59 override;
60
61 // Called by Java when the external estimate provider has an updated value. 54 // Called by Java when the external estimate provider has an updated value.
62 // This may be called on a thread different from |task_runner_|. 55 // This may be called on a thread different from |task_runner_|.
63 void NotifyExternalEstimateProviderAndroidUpdate(JNIEnv* env, jobject obj); 56 void NotifyExternalEstimateProviderAndroidUpdate(JNIEnv* env, jobject obj);
64 57
65 protected: 58 protected:
66 // Notifies the delegate that a new update to external estimate is available. 59 // Notifies the delegate that a new update to external estimate is available.
67 // Protected for testing. 60 // Protected for testing.
68 void NotifyUpdatedEstimateAvailable() const; 61 void NotifyUpdatedEstimateAvailable() const;
69 62
70 private: 63 private:
71 // Places a requests to the provider to update the network quality. Returns
72 // true if the request was placed successfully.
73 void RequestUpdate() const;
74
75 // Value returned if valid value is unavailable. 64 // Value returned if valid value is unavailable.
76 int32_t no_value_ = -1; 65 int32_t no_value_ = -1;
77 66
78 base::android::ScopedJavaGlobalRef<jobject> j_external_estimate_provider_; 67 base::android::ScopedJavaGlobalRef<jobject> j_external_estimate_provider_;
79 68
80 // Task runner that accesses ExternalEstimateProviderAndroid members. 69 // Task runner that accesses ExternalEstimateProviderAndroid members.
81 scoped_refptr<base::TaskRunner> task_runner_; 70 scoped_refptr<base::TaskRunner> task_runner_;
82 71
83 // Notified every time there is an update available from the network quality 72 // Notified every time there is an update available from the network quality
84 // provider. 73 // provider.
85 // TODO(tbansal): Add the function that is called by Java side when an update 74 // TODO(tbansal): Add the function that is called by Java side when an update
86 // is available. 75 // is available.
87 net::ExternalEstimateProvider::UpdatedEstimateDelegate* delegate_; 76 net::ExternalEstimateProvider::UpdatedEstimateDelegate* delegate_;
88 77
89 base::ThreadChecker thread_checker_; 78 base::ThreadChecker thread_checker_;
90 79
91 // Used for posting tasks. 80 // Used for posting tasks.
92 base::WeakPtrFactory<ExternalEstimateProviderAndroid> weak_factory_; 81 base::WeakPtrFactory<ExternalEstimateProviderAndroid> weak_factory_;
93 82
94 DISALLOW_COPY_AND_ASSIGN(ExternalEstimateProviderAndroid); 83 DISALLOW_COPY_AND_ASSIGN(ExternalEstimateProviderAndroid);
95 }; 84 };
96 85
97 bool RegisterExternalEstimateProviderAndroid(JNIEnv* env); 86 bool RegisterExternalEstimateProviderAndroid(JNIEnv* env);
98 87
99 } // namespace android 88 } // namespace android
100 } // namespace chrome 89 } // namespace chrome
101 90
102 #endif // CHROME_BROWSER_ANDROID_NET_EXTERNAL_ESTIMATE_PROVIDER_ANDROID_H_ 91 #endif // CHROME_BROWSER_ANDROID_NET_EXTERNAL_ESTIMATE_PROVIDER_ANDROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698