| Index: net/android/network_change_notifier_delegate_android.h
|
| diff --git a/net/android/network_change_notifier_delegate_android.h b/net/android/network_change_notifier_delegate_android.h
|
| index 9f5caa44167656ac279c519a50a69e46f4d0263f..d35ef137d35cf79cd9047a0b708411fde9d3d227 100644
|
| --- a/net/android/network_change_notifier_delegate_android.h
|
| +++ b/net/android/network_change_notifier_delegate_android.h
|
| @@ -9,6 +9,7 @@
|
| #include "base/basictypes.h"
|
| #include "base/memory/ref_counted.h"
|
| #include "base/observer_list_threadsafe.h"
|
| +#include "base/synchronization/lock.h"
|
| #include "base/threading/thread_checker.h"
|
| #include "net/base/network_change_notifier.h"
|
|
|
| @@ -21,10 +22,7 @@ namespace net {
|
| // unless otherwise stated (e.g. AddObserver()/RemoveObserver()).
|
| class NET_EXPORT_PRIVATE NetworkChangeNotifierDelegateAndroid {
|
| public:
|
| - enum ConnectivityState {
|
| - OFFLINE,
|
| - ONLINE,
|
| - };
|
| + typedef NetworkChangeNotifier::ConnectionType ConnectionType;
|
|
|
| // Observer interface implemented by NetworkChangeNotifierAndroid which
|
| // subscribes to network change notifications fired by the delegate (and
|
| @@ -41,6 +39,9 @@ class NET_EXPORT_PRIVATE NetworkChangeNotifierDelegateAndroid {
|
| NetworkChangeNotifierDelegateAndroid();
|
| ~NetworkChangeNotifierDelegateAndroid();
|
|
|
| + // Can be called from any thread.
|
| + ConnectionType GetCurrentConnectionType() const;
|
| +
|
| // Called from NetworkChangeNotifierAndroid.java on the JNI thread whenever
|
| // the connection type changes. This updates the current connection type seen
|
| // by this class and forwards the notification to the observers that
|
| @@ -55,21 +56,28 @@ class NET_EXPORT_PRIVATE NetworkChangeNotifierDelegateAndroid {
|
| void AddObserver(Observer* observer);
|
| void RemoveObserver(Observer* observer);
|
|
|
| - // Exposed for testing.
|
| - void ForceConnectivityState(ConnectivityState state);
|
| -
|
| // Initializes JNI bindings.
|
| static bool Register(JNIEnv* env);
|
|
|
| private:
|
| - friend class NetworkChangeNotifierDelegateAndroidTest;
|
| + friend class BaseNetworkChangeNotifierAndroidTest;
|
|
|
| - typedef NetworkChangeNotifier::ConnectionType ConnectionType;
|
| + enum ConnectivityState {
|
| + OFFLINE,
|
| + ONLINE,
|
| + };
|
| +
|
| + void SetCurrentConnectionType(ConnectionType connection_type);
|
| +
|
| + // Exposed for testing.
|
| + void ForceJavaSideConnectivityState(ConnectivityState state);
|
| + ConnectivityState GetJavaSideConnectivityState();
|
|
|
| base::ThreadChecker thread_checker_;
|
| scoped_refptr<ObserverListThreadSafe<Observer> > observers_;
|
| scoped_refptr<base::SingleThreadTaskRunner> jni_task_runner_;
|
| base::android::ScopedJavaGlobalRef<jobject> java_network_change_notifier_;
|
| + mutable base::Lock connection_type_lock_; // Protects the state below.
|
| ConnectionType connection_type_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierDelegateAndroid);
|
|
|