| Index: net/android/network_change_notifier_android.h
|
| diff --git a/net/android/network_change_notifier_android.h b/net/android/network_change_notifier_android.h
|
| index f5311ac9bc60abfd2f011c72797b83a9f111d0a3..2f413e4958df1fe4063b61f4def4610f31dbdffc 100644
|
| --- a/net/android/network_change_notifier_android.h
|
| +++ b/net/android/network_change_notifier_android.h
|
| @@ -11,41 +11,54 @@
|
| #include "base/synchronization/lock.h"
|
| #include "net/base/network_change_notifier.h"
|
|
|
| +namespace base {
|
| +
|
| +class TaskRunner;
|
| +
|
| +} // namespace base
|
| +
|
| namespace net {
|
|
|
| class NetworkChangeNotifierAndroidTest;
|
|
|
| class NetworkChangeNotifierAndroid : public NetworkChangeNotifier {
|
| public:
|
| - virtual ~NetworkChangeNotifierAndroid();
|
| + class Delegate {
|
| + public:
|
| + // Called from Java on the UI thread.
|
| + virtual void NotifyObserversOfConnectionTypeChange(
|
| + JNIEnv* env, jobject obj, jint new_connection_type) = 0;
|
|
|
| - // Called from Java on the UI thread.
|
| - void NotifyObserversOfConnectionTypeChange(
|
| - JNIEnv* env, jobject obj, jint new_connection_type);
|
| - jint GetConnectionType(JNIEnv* env, jobject obj);
|
| + virtual jint GetConnectionType(JNIEnv* env, jobject obj) const = 0;
|
| +
|
| + protected:
|
| + virtual ~Delegate() {}
|
| + };
|
| +
|
| + virtual ~NetworkChangeNotifierAndroid();
|
|
|
| static bool Register(JNIEnv* env);
|
|
|
| private:
|
| + class DelegateImpl;
|
| +
|
| + friend class DelegateImpl;
|
| friend class NetworkChangeNotifierAndroidTest;
|
| friend class NetworkChangeNotifierFactoryAndroid;
|
|
|
| - NetworkChangeNotifierAndroid();
|
| + NetworkChangeNotifierAndroid(base::TaskRunner* ui_task_runner);
|
|
|
| - void SetConnectionType(int connection_type);
|
| + // Wrapper used to let |Delegate| call the protected
|
| + // NetworkChangeNotifier::NotifyObserversOfConnectionTypeChange() method.
|
| + static void NotifyObservers();
|
|
|
| void ForceConnectivityState(bool state);
|
|
|
| // NetworkChangeNotifier:
|
| virtual ConnectionType GetCurrentConnectionType() const OVERRIDE;
|
|
|
| - base::android::ScopedJavaGlobalRef<jobject> java_network_change_notifier_;
|
| - // TODO(pliard): http://crbug.com/150867. Use an atomic integer for the
|
| - // connection type without the lock once a non-subtle atomic integer is
|
| - // available under base/. That might never happen though.
|
| - mutable base::Lock lock_; // Protects the state below.
|
| - // Written from the UI thread, read from any thread.
|
| - int connection_type_;
|
| + // The delegate deletes itself.
|
| + DelegateImpl* const delegate_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierAndroid);
|
| };
|
|
|