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

Side by Side Diff: net/android/network_change_notifier_delegate_android.h

Issue 1306653003: Add connection type to NCN::MaxBandwidthChanged (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove extra space in comment 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 NET_ANDROID_NETWORK_CHANGE_NOTIFIER_DELEGATE_ANDROID_H_ 5 #ifndef NET_ANDROID_NETWORK_CHANGE_NOTIFIER_DELEGATE_ANDROID_H_
6 #define NET_ANDROID_NETWORK_CHANGE_NOTIFIER_DELEGATE_ANDROID_H_ 6 #define NET_ANDROID_NETWORK_CHANGE_NOTIFIER_DELEGATE_ANDROID_H_
7 7
8 #include "base/android/jni_android.h" 8 #include "base/android/jni_android.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 17 matching lines...) Expand all
28 // subscribes to network change notifications fired by the delegate (and 28 // subscribes to network change notifications fired by the delegate (and
29 // initiated by the Java side). 29 // initiated by the Java side).
30 class Observer { 30 class Observer {
31 public: 31 public:
32 virtual ~Observer() {} 32 virtual ~Observer() {}
33 33
34 // Updates the current connection type. 34 // Updates the current connection type.
35 virtual void OnConnectionTypeChanged() = 0; 35 virtual void OnConnectionTypeChanged() = 0;
36 36
37 // Updates the current max bandwidth. 37 // Updates the current max bandwidth.
38 virtual void OnMaxBandwidthChanged(double max_bandwidth_mbps) = 0; 38 virtual void OnMaxBandwidthChanged(double max_bandwidth_mbps,
39 ConnectionType connection_type) = 0;
39 }; 40 };
40 41
41 NetworkChangeNotifierDelegateAndroid(); 42 NetworkChangeNotifierDelegateAndroid();
42 ~NetworkChangeNotifierDelegateAndroid(); 43 ~NetworkChangeNotifierDelegateAndroid();
43 44
44 // Called from NetworkChangeNotifierAndroid.java on the JNI thread whenever 45 // Called from NetworkChangeNotifierAndroid.java on the JNI thread whenever
45 // the connection type changes. This updates the current connection type seen 46 // the connection type changes. This updates the current connection type seen
46 // by this class and forwards the notification to the observers that 47 // by this class and forwards the notification to the observers that
47 // subscribed through AddObserver(). 48 // subscribed through AddObserver().
48 void NotifyConnectionTypeChanged(JNIEnv* env, 49 void NotifyConnectionTypeChanged(JNIEnv* env,
(...skipping 11 matching lines...) Expand all
60 61
61 // These methods can be called on any thread. Note that the provided observer 62 // These methods can be called on any thread. Note that the provided observer
62 // will be notified on the thread AddObserver() is called on. 63 // will be notified on the thread AddObserver() is called on.
63 void AddObserver(Observer* observer); 64 void AddObserver(Observer* observer);
64 void RemoveObserver(Observer* observer); 65 void RemoveObserver(Observer* observer);
65 66
66 // Can be called from any thread. 67 // Can be called from any thread.
67 ConnectionType GetCurrentConnectionType() const; 68 ConnectionType GetCurrentConnectionType() const;
68 69
69 // Can be called from any thread. 70 // Can be called from any thread.
70 double GetCurrentMaxBandwidth() const; 71 void GetCurrentMaxBandwidthAndConnectionType(
72 double* max_bandwidth_mbps,
73 ConnectionType* connection_type) const;
71 74
72 // Initializes JNI bindings. 75 // Initializes JNI bindings.
73 static bool Register(JNIEnv* env); 76 static bool Register(JNIEnv* env);
74 77
75 private: 78 private:
76 friend class BaseNetworkChangeNotifierAndroidTest; 79 friend class BaseNetworkChangeNotifierAndroidTest;
77 80
78 void SetCurrentConnectionType(ConnectionType connection_type); 81 void SetCurrentConnectionType(ConnectionType connection_type);
79 void SetCurrentMaxBandwidth(double max_bandwidth); 82 void SetCurrentMaxBandwidth(double max_bandwidth);
80 83
81 // Methods calling the Java side exposed for testing. 84 // Methods calling the Java side exposed for testing.
82 void SetOnline(); 85 void SetOnline();
83 void SetOffline(); 86 void SetOffline();
84 87
85 base::ThreadChecker thread_checker_; 88 base::ThreadChecker thread_checker_;
86 scoped_refptr<base::ObserverListThreadSafe<Observer>> observers_; 89 scoped_refptr<base::ObserverListThreadSafe<Observer>> observers_;
87 scoped_refptr<base::SingleThreadTaskRunner> jni_task_runner_; 90 scoped_refptr<base::SingleThreadTaskRunner> jni_task_runner_;
88 base::android::ScopedJavaGlobalRef<jobject> java_network_change_notifier_; 91 base::android::ScopedJavaGlobalRef<jobject> java_network_change_notifier_;
89 mutable base::Lock connection_lock_; // Protects the state below. 92 mutable base::Lock connection_lock_; // Protects the state below.
90 ConnectionType connection_type_; 93 ConnectionType connection_type_;
91 double connection_max_bandwidth_; 94 double connection_max_bandwidth_;
92 95
93 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierDelegateAndroid); 96 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierDelegateAndroid);
94 }; 97 };
95 98
96 } // namespace net 99 } // namespace net
97 100
98 #endif // NET_ANDROID_NETWORK_CHANGE_NOTIFIER_DELEGATE_H_ 101 #endif // NET_ANDROID_NETWORK_CHANGE_NOTIFIER_DELEGATE_H_
OLDNEW
« no previous file with comments | « net/android/network_change_notifier_android_unittest.cc ('k') | net/android/network_change_notifier_delegate_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698