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 3c71dc5995bb31fdfacf88b46fc8e37ce2cb8106..ee829b3eb908498ec60155c098597a7a342a9a1c 100644 |
--- a/net/android/network_change_notifier_android.h |
+++ b/net/android/network_change_notifier_android.h |
@@ -8,6 +8,7 @@ |
#include "base/android/scoped_java_ref.h" |
#include "base/basictypes.h" |
#include "base/compiler_specific.h" |
+#include "base/synchronization/lock.h" |
#include "net/base/network_change_notifier.h" |
namespace net { |
@@ -15,21 +16,34 @@ namespace android { |
class NetworkChangeNotifier : public net::NetworkChangeNotifier { |
public: |
- NetworkChangeNotifier(); |
virtual ~NetworkChangeNotifier(); |
- void NotifyObservers(JNIEnv* env, jobject obj); |
+ // Called from Java on the UI thread. |
+ void NotifyObservers(JNIEnv* env, jobject obj, int new_connection_type); |
+ jint GetConnectionType(JNIEnv* env, jobject obj); |
static bool Register(JNIEnv* env); |
private: |
+ friend class NetworkChangeNotifierFactory; |
+ |
+ NetworkChangeNotifier(); |
+ |
void CreateJavaObject(JNIEnv* env); |
+ void SetConnectionType(int connection_type); |
+ |
// NetworkChangeNotifier: |
virtual net::NetworkChangeNotifier::ConnectionType |
GetCurrentConnectionType() const OVERRIDE; |
base::android::ScopedJavaGlobalRef<jobject> java_network_change_notifier_; |
+ // TODO(pliard): 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. |
+ // Wrote from the UI thread, read from any thread. |
+ int connection_type_; |
DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifier); |
}; |