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

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: Try another approach 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..90d2508d1ce38cc01394817de4e126c49f21ba53 100644
--- a/net/android/network_change_notifier_delegate_android.h
+++ b/net/android/network_change_notifier_delegate_android.h
@@ -8,6 +8,7 @@
#include "base/android/jni_android.h"
#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
#include "base/observer_list_threadsafe.h"
#include "base/threading/thread_checker.h"
#include "net/base/network_change_notifier.h"
@@ -50,8 +51,10 @@ class NET_EXPORT_PRIVATE NetworkChangeNotifierDelegateAndroid {
jint new_connection_type);
jint GetConnectionType(JNIEnv* env, jobject obj) const;
- // These methods can be called on any thread. Note that the provided observer
- // will be notified on the thread AddObserver() is called on.
+ // These methods can be called on any thread. The provided observer will be
+ // notified on the thread AddObserver() is called on. Note that calling this
+ // method schedules an initial notification that lets the observer initialize
+ // its connection type.
void AddObserver(Observer* observer);
Ryan Sleevi 2012/12/19 17:38:16 Can you not just have AddObserver return the initi
Philippe 2012/12/19 17:52:23 I might be missing something but AddObserver() can
Ryan Sleevi 2012/12/19 18:07:57 Yeah, you'd still have to have a lock.
void RemoveObserver(Observer* observer);
@@ -62,13 +65,19 @@ class NET_EXPORT_PRIVATE NetworkChangeNotifierDelegateAndroid {
static bool Register(JNIEnv* env);
private:
- friend class NetworkChangeNotifierDelegateAndroidTest;
+ friend class BaseNetworkChangeNotifierAndroidTest;
typedef NetworkChangeNotifier::ConnectionType ConnectionType;
+ // Provides the newly added observer with an initial connection type.
+ void SendInitialNotification();
+
base::ThreadChecker thread_checker_;
- scoped_refptr<ObserverListThreadSafe<Observer> > observers_;
scoped_refptr<base::SingleThreadTaskRunner> jni_task_runner_;
+ base::WeakPtrFactory<NetworkChangeNotifierDelegateAndroid> weak_ptr_factory_;
+ base::WeakPtr<NetworkChangeNotifierDelegateAndroid> weak_ptr_;
+
+ scoped_refptr<ObserverListThreadSafe<Observer> > observers_;
base::android::ScopedJavaGlobalRef<jobject> java_network_change_notifier_;
ConnectionType connection_type_;
« no previous file with comments | « net/android/network_change_notifier_android_unittest.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