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

Unified Diff: net/android/network_change_notifier_delegate_android.h

Issue 11628008: Provide NetworkChangeNotifierAndroid with the actual initial connection type. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make NCNA fetch the connection type through NCNDA Created 8 years 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_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..fa01c05fb6c6c654a1c8bcd642bc7bea10187ba9 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,6 +22,8 @@ namespace net {
// unless otherwise stated (e.g. AddObserver()/RemoveObserver()).
class NET_EXPORT_PRIVATE NetworkChangeNotifierDelegateAndroid {
public:
+ typedef NetworkChangeNotifier::ConnectionType ConnectionType;
+
enum ConnectivityState {
OFFLINE,
ONLINE,
@@ -50,6 +53,10 @@ class NET_EXPORT_PRIVATE NetworkChangeNotifierDelegateAndroid {
jint new_connection_type);
jint GetConnectionType(JNIEnv* env, jobject obj) const;
+ // Same as above but meant to be called by NetworkChangeNotifierAndroid from
+ // any thread.
Ryan Sleevi 2012/12/19 18:07:57 This comment is confusing and would need to be re-
+ ConnectionType GetCurrentConnectionType() const;
+
// These methods can be called on any thread. Note that the provided observer
// will be notified on the thread AddObserver() is called on.
void AddObserver(Observer* observer);
@@ -64,12 +71,13 @@ class NET_EXPORT_PRIVATE NetworkChangeNotifierDelegateAndroid {
private:
friend class NetworkChangeNotifierDelegateAndroidTest;
- typedef NetworkChangeNotifier::ConnectionType ConnectionType;
+ void SetConnectionType(ConnectionType new_connection_type);
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);
« no previous file with comments | « net/android/network_change_notifier_android.cc ('k') | net/android/network_change_notifier_delegate_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698