| OLD | NEW |
| 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/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 jint GetConnectionType(JNIEnv* env, jobject obj) const; | 48 jint GetConnectionType(JNIEnv* env, jobject obj) const; |
| 49 | 49 |
| 50 // These methods can be called on any thread. Note that the provided observer | 50 // These methods can be called on any thread. Note that the provided observer |
| 51 // will be notified on the thread AddObserver() is called on. | 51 // will be notified on the thread AddObserver() is called on. |
| 52 void AddObserver(Observer* observer); | 52 void AddObserver(Observer* observer); |
| 53 void RemoveObserver(Observer* observer); | 53 void RemoveObserver(Observer* observer); |
| 54 | 54 |
| 55 // Can be called from any thread. | 55 // Can be called from any thread. |
| 56 ConnectionType GetCurrentConnectionType() const; | 56 ConnectionType GetCurrentConnectionType() const; |
| 57 | 57 |
| 58 // Can be called from any thread. |
| 59 double GetCurrentMaxBandwidth() const; |
| 60 |
| 58 // Initializes JNI bindings. | 61 // Initializes JNI bindings. |
| 59 static bool Register(JNIEnv* env); | 62 static bool Register(JNIEnv* env); |
| 60 | 63 |
| 61 private: | 64 private: |
| 62 friend class BaseNetworkChangeNotifierAndroidTest; | 65 friend class BaseNetworkChangeNotifierAndroidTest; |
| 63 | 66 |
| 64 void SetCurrentConnectionType(ConnectionType connection_type); | 67 void SetCurrentConnectionType(ConnectionType connection_type); |
| 68 void SetCurrentMaxBandwidth(double max_bandwidth); |
| 65 | 69 |
| 66 // Methods calling the Java side exposed for testing. | 70 // Methods calling the Java side exposed for testing. |
| 67 void SetOnline(); | 71 void SetOnline(); |
| 68 void SetOffline(); | 72 void SetOffline(); |
| 69 | 73 |
| 70 base::ThreadChecker thread_checker_; | 74 base::ThreadChecker thread_checker_; |
| 71 scoped_refptr<ObserverListThreadSafe<Observer> > observers_; | 75 scoped_refptr<ObserverListThreadSafe<Observer> > observers_; |
| 72 scoped_refptr<base::SingleThreadTaskRunner> jni_task_runner_; | 76 scoped_refptr<base::SingleThreadTaskRunner> jni_task_runner_; |
| 73 base::android::ScopedJavaGlobalRef<jobject> java_network_change_notifier_; | 77 base::android::ScopedJavaGlobalRef<jobject> java_network_change_notifier_; |
| 74 mutable base::Lock connection_type_lock_; // Protects the state below. | 78 mutable base::Lock connection_lock_; // Protects the state below. |
| 75 ConnectionType connection_type_; | 79 ConnectionType connection_type_; |
| 80 double connection_max_bandwidth_; |
| 76 | 81 |
| 77 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierDelegateAndroid); | 82 DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierDelegateAndroid); |
| 78 }; | 83 }; |
| 79 | 84 |
| 80 } // namespace net | 85 } // namespace net |
| 81 | 86 |
| 82 #endif // NET_ANDROID_NETWORK_CHANGE_NOTIFIER_DELEGATE_H_ | 87 #endif // NET_ANDROID_NETWORK_CHANGE_NOTIFIER_DELEGATE_H_ |
| OLD | NEW |