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

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

Issue 2010003002: Reduce the number of calls to external estimate provider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 6 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
« no previous file with comments | « no previous file | chrome/browser/android/net/external_estimate_provider_android.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 #include "base/android/scoped_java_ref.h" 11 #include "base/android/scoped_java_ref.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/threading/thread_checker.h" 15 #include "base/threading/thread_checker.h"
16 #include "base/threading/thread_task_runner_handle.h" 16 #include "base/threading/thread_task_runner_handle.h"
17 #include "base/time/time.h" 17 #include "base/time/time.h"
18 #include "net/base/network_change_notifier.h"
19 #include "net/nqe/external_estimate_provider.h" 18 #include "net/nqe/external_estimate_provider.h"
20 19
21 namespace chrome { 20 namespace chrome {
22 namespace android { 21 namespace android {
23 22
24 // Native class that calls Java code exposed by 23 // Native class that calls Java code exposed by
25 // ExternalEstimateProviderAndroidHelper.java. Provides network quality 24 // ExternalEstimateProviderAndroidHelper.java. Provides network quality
26 // estimates as provided by Android. Estimates are automatically updated on a 25 // estimates as provided by Android. Estimates are automatically updated on a
27 // network change event. 26 // network change event.
28 class ExternalEstimateProviderAndroid 27 class ExternalEstimateProviderAndroid : public net::ExternalEstimateProvider {
29 : public net::NetworkChangeNotifier::ConnectionTypeObserver,
30 public net::ExternalEstimateProvider {
31 public: 28 public:
32 // Constructs and initializes the underlying provider. 29 // Constructs and initializes the underlying provider.
33 ExternalEstimateProviderAndroid(); 30 ExternalEstimateProviderAndroid();
34 31
35 ~ExternalEstimateProviderAndroid() override; 32 ~ExternalEstimateProviderAndroid() override;
36 33
37 // net::ExternalEstimateProvider implementation: 34 // net::ExternalEstimateProvider implementation:
38 bool GetRTT(base::TimeDelta* rtt) const override; 35 bool GetRTT(base::TimeDelta* rtt) const override;
39 bool GetDownstreamThroughputKbps( 36 bool GetDownstreamThroughputKbps(
40 int32_t* downstream_throughput_kbps) const override; 37 int32_t* downstream_throughput_kbps) const override;
41 bool GetUpstreamThroughputKbps( 38 bool GetUpstreamThroughputKbps(
42 int32_t* upstream_throughput_kbps) const override; 39 int32_t* upstream_throughput_kbps) const override;
43 bool GetTimeSinceLastUpdate( 40 bool GetTimeSinceLastUpdate(
44 base::TimeDelta* time_since_last_update) const override; 41 base::TimeDelta* time_since_last_update) const override;
45 void SetUpdatedEstimateDelegate( 42 void SetUpdatedEstimateDelegate(
46 net::ExternalEstimateProvider::UpdatedEstimateDelegate* delegate) 43 net::ExternalEstimateProvider::UpdatedEstimateDelegate* delegate)
47 override; 44 override;
48 void Update() const override; 45 void Update() const override;
49 46
50 // NetworkChangeNotifier::ConnectionTypeObserver implementation.
51 void OnConnectionTypeChanged(
52 net::NetworkChangeNotifier::ConnectionType type) override;
53
54 // Called by Java when the external estimate provider has an updated value. 47 // Called by Java when the external estimate provider has an updated value.
55 // This may be called on a thread different from |task_runner_|. 48 // This may be called on a thread different from |task_runner_|.
56 void NotifyExternalEstimateProviderAndroidUpdate( 49 void NotifyExternalEstimateProviderAndroidUpdate(
57 JNIEnv* env, 50 JNIEnv* env,
58 const base::android::JavaParamRef<jobject>& obj); 51 const base::android::JavaParamRef<jobject>& obj);
59 52
60 protected: 53 protected:
61 // Notifies the delegate that a new update to external estimate is available. 54 // Notifies the delegate that a new update to external estimate is available.
62 // Protected for testing. 55 // Protected for testing.
63 void NotifyUpdatedEstimateAvailable() const; 56 void NotifyUpdatedEstimateAvailable() const;
(...skipping 17 matching lines...) Expand all
81 74
82 DISALLOW_COPY_AND_ASSIGN(ExternalEstimateProviderAndroid); 75 DISALLOW_COPY_AND_ASSIGN(ExternalEstimateProviderAndroid);
83 }; 76 };
84 77
85 bool RegisterExternalEstimateProviderAndroid(JNIEnv* env); 78 bool RegisterExternalEstimateProviderAndroid(JNIEnv* env);
86 79
87 } // namespace android 80 } // namespace android
88 } // namespace chrome 81 } // namespace chrome
89 82
90 #endif // CHROME_BROWSER_ANDROID_NET_EXTERNAL_ESTIMATE_PROVIDER_ANDROID_H_ 83 #endif // CHROME_BROWSER_ANDROID_NET_EXTERNAL_ESTIMATE_PROVIDER_ANDROID_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/android/net/external_estimate_provider_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698