Temporarily make lastchange use only the git hash.
[chromium-blink-merge.git] / net / base / network_config_watcher_mac.h
blob850ad8a1c1057cd8702152ecc6297e1c6cad61e0
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef NET_BASE_NETWORK_CONFIG_WATCHER_MAC_H_
6 #define NET_BASE_NETWORK_CONFIG_WATCHER_MAC_H_
8 #include <SystemConfiguration/SCDynamicStore.h>
10 #include "base/basictypes.h"
11 #include "base/mac/scoped_cftyperef.h"
12 #include "base/memory/scoped_ptr.h"
14 namespace base {
15 class Thread;
18 namespace net {
20 // Helper class for watching the Mac OS system network settings.
21 class NetworkConfigWatcherMac {
22 public:
23 // NOTE: The lifetime of Delegate is expected to exceed the lifetime of
24 // NetworkConfigWatcherMac.
25 class Delegate {
26 public:
27 virtual ~Delegate() {}
29 // Called to let the delegate do any setup work the must be run on the
30 // notifier thread immediately after it starts.
31 virtual void Init() {}
33 // Called to start receiving notifications from the SCNetworkReachability
34 // API.
35 // Will be called on the notifier thread.
36 virtual void StartReachabilityNotifications() = 0;
38 // Called to register the notification keys on |store|.
39 // Implementors are expected to call SCDynamicStoreSetNotificationKeys().
40 // Will be called on the notifier thread.
41 virtual void SetDynamicStoreNotificationKeys(SCDynamicStoreRef store) = 0;
43 // Called when one of the notification keys has changed.
44 // Will be called on the notifier thread.
45 virtual void OnNetworkConfigChange(CFArrayRef changed_keys) = 0;
48 explicit NetworkConfigWatcherMac(Delegate* delegate);
49 ~NetworkConfigWatcherMac();
51 private:
52 // The thread used to listen for notifications. This relays the notification
53 // to the registered observers without posting back to the thread the object
54 // was created on.
55 scoped_ptr<base::Thread> notifier_thread_;
57 DISALLOW_COPY_AND_ASSIGN(NetworkConfigWatcherMac);
60 } // namespace net
62 #endif // NET_BASE_NETWORK_CONFIG_WATCHER_MAC_H_