summaryrefslogtreecommitdiffstats
path: root/net/base/network_change_notifier_mac.h
diff options
context:
space:
mode:
Diffstat (limited to 'net/base/network_change_notifier_mac.h')
-rw-r--r--net/base/network_change_notifier_mac.h54
1 files changed, 27 insertions, 27 deletions
diff --git a/net/base/network_change_notifier_mac.h b/net/base/network_change_notifier_mac.h
index 2ffaaba..c85f244 100644
--- a/net/base/network_change_notifier_mac.h
+++ b/net/base/network_change_notifier_mac.h
@@ -5,52 +5,52 @@
#ifndef NET_BASE_NETWORK_CHANGE_NOTIFIER_MAC_H_
#define NET_BASE_NETWORK_CHANGE_NOTIFIER_MAC_H_
+#include <SystemConfiguration/SCDynamicStore.h>
+
#include "base/basictypes.h"
-#include "base/non_thread_safe.h"
-#include "base/observer_list.h"
-#include "base/ref_counted.h"
+#include "base/message_loop.h"
+#include "base/scoped_cftyperef.h"
#include "base/scoped_ptr.h"
-#include "base/task.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_;
-
- // Used to initialize the notifier thread.
- ScopedRunnableMethodFactory<NetworkChangeNotifierMac> method_factory_;
+ scoped_cftyperef<CFRunLoopSourceRef> run_loop_source_;
DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierMac);
};