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

Unified Diff: net/android/network_change_notifier_android.h

Issue 10905264: Fix race condition in NetworkChangeNotifier on Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Marcus' comment Created 8 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 side-by-side diff with in-line comments
Download patch
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..dacf84b3f22a4bdd7eb3837de73f2be881280a5e 100644
--- a/net/android/network_change_notifier_android.h
+++ b/net/android/network_change_notifier_android.h
@@ -6,6 +6,7 @@
#define NET_ANDROID_NETWORK_CHANGE_NOTIFIER_ANDROID_H_
#include "base/android/scoped_java_ref.h"
+#include "base/atomicops.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "net/base/network_change_notifier.h"
@@ -15,14 +16,19 @@ 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);
// NetworkChangeNotifier:
@@ -30,6 +36,8 @@ class NetworkChangeNotifier : public net::NetworkChangeNotifier {
GetCurrentConnectionType() const OVERRIDE;
base::android::ScopedJavaGlobalRef<jobject> java_network_change_notifier_;
+ // Wrote from the UI thread, read from any thread.
+ base::subtle::AtomicWord connection_type_;
szym 2012/09/14 18:25:23 In an offline conversation with pauljensen@ we pon
Philippe 2012/09/19 17:35:14 I used a Lock with a TODO instead after Ryan and P
DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifier);
};

Powered by Google App Engine
This is Rietveld 408576698