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

Unified Diff: net/base/network_change_notifier_mac.h

Issue 2802015: Massively simplify the NetworkChangeNotifier infrastructure:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 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/base/network_change_notifier_mac.h
===================================================================
--- net/base/network_change_notifier_mac.h (revision 50775)
+++ net/base/network_change_notifier_mac.h (working copy)
@@ -5,53 +5,51 @@
#ifndef NET_BASE_NETWORK_CHANGE_NOTIFIER_MAC_H_
#define NET_BASE_NETWORK_CHANGE_NOTIFIER_MAC_H_
-#include "base/basictypes.h"
-#include "base/non_thread_safe.h"
-#include "base/observer_list.h"
-#include "base/ref_counted.h"
-#include "base/scoped_ptr.h"
-#include "base/task.h"
+#include <SystemConfiguration/SCDynamicStore.h>
+
+#include "base/message_loop.h"
+#include "base/scoped_cftyperef.h"
#include "net/base/network_change_notifier.h"
-class MessageLoop;
namespace base {
class Thread;
-} // namespace base
+}
namespace net {
-class NetworkChangeNotifierMac : public NetworkChangeNotifier,
- public NonThreadSafe {
+class NetworkChangeNotifierMac : public MessageLoop::DestructionObserver,
+ public NetworkChangeNotifier {
public:
NetworkChangeNotifierMac();
- void OnIPAddressChanged();
+ private:
+ virtual ~NetworkChangeNotifierMac();
- // NetworkChangeNotifier methods:
- virtual void AddObserver(Observer* observer);
- virtual void RemoveObserver(Observer* observer);
+ // Called back by OS. Calls OnNetworkConfigChange().
+ static void DynamicStoreCallback(SCDynamicStoreRef /* store */,
+ CFArrayRef changed_keys,
+ void* config);
- private:
- friend class base::RefCounted<NetworkChangeNotifierMac>;
+ // MessageLoop::DestructionObserver:
+ virtual void WillDestroyCurrentMessageLoop();
- virtual ~NetworkChangeNotifierMac();
+ // Called on the notifier thread to initialize the notification
+ // implementation. The SystemConfiguration calls in this function can lead to
+ // contention early on, so we invoke this function later on in startup to keep
+ // it fast.
+ void Init();
- // Initializes the notifier thread. The SystemConfiguration calls in this
- // function can lead to contention early on, so we invoke this function later
- // on in startup to keep it fast.
- // See http://crbug.com/34926 for details.
- void InitializeNotifierThread(MessageLoop* loop);
+ // Called by DynamicStoreCallback() when something about the network config
+ // changes.
+ void OnNetworkConfigChange(CFArrayRef changed_keys);
- // Receives the OS X network change notifications on this thread.
+ // The thread used to listen for notifications. This relays the notification
+ // to the registered observers without posting back to the thread the object
+ // was created on.
scoped_ptr<base::Thread> notifier_thread_;
- // TODO(willchan): Fix the URLRequestContextGetter leaks and flip the false to
- // true so we assert that all observers have been removed.
- ObserverList<Observer, false> observers_;
+ scoped_cftyperef<CFRunLoopSourceRef> run_loop_source_;
- // Used to initialize the notifier thread.
- ScopedRunnableMethodFactory<NetworkChangeNotifierMac> method_factory_;
-
DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierMac);
};

Powered by Google App Engine
This is Rietveld 408576698