Home | History | Annotate | Download | only in base
      1 // Copyright (c) 2010 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.
      4 
      5 #ifndef NET_BASE_NETWORK_CHANGE_NOTIFIER_MAC_H_
      6 #define NET_BASE_NETWORK_CHANGE_NOTIFIER_MAC_H_
      7 #pragma once
      8 
      9 #include <SystemConfiguration/SCDynamicStore.h>
     10 
     11 #include "base/basictypes.h"
     12 #include "net/base/network_change_notifier.h"
     13 #include "net/base/network_config_watcher_mac.h"
     14 
     15 namespace net {
     16 
     17 class NetworkChangeNotifierMac: public NetworkChangeNotifier {
     18  public:
     19   NetworkChangeNotifierMac();
     20   virtual ~NetworkChangeNotifierMac();
     21 
     22   // NetworkChangeNotifier implementation:
     23   virtual bool IsCurrentlyOffline() const;
     24 
     25  private:
     26   // Forwarder just exists to keep the NetworkConfigWatcherMac API out of
     27   // NetworkChangeNotifierMac's public API.
     28   class Forwarder : public NetworkConfigWatcherMac::Delegate {
     29    public:
     30     explicit Forwarder(NetworkChangeNotifierMac* net_config_watcher)
     31         : net_config_watcher_(net_config_watcher) {}
     32 
     33     // NetworkConfigWatcherMac::Delegate implementation:
     34     virtual void SetDynamicStoreNotificationKeys(SCDynamicStoreRef store) {
     35       net_config_watcher_->SetDynamicStoreNotificationKeys(store);
     36     }
     37     virtual void OnNetworkConfigChange(CFArrayRef changed_keys) {
     38       net_config_watcher_->OnNetworkConfigChange(changed_keys);
     39     }
     40 
     41    private:
     42     NetworkChangeNotifierMac* const net_config_watcher_;
     43     DISALLOW_COPY_AND_ASSIGN(Forwarder);
     44   };
     45 
     46   // NetworkConfigWatcherMac::Delegate implementation:
     47   void SetDynamicStoreNotificationKeys(SCDynamicStoreRef store);
     48   void OnNetworkConfigChange(CFArrayRef changed_keys);
     49 
     50   Forwarder forwarder_;
     51   const NetworkConfigWatcherMac config_watcher_;
     52 
     53   DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierMac);
     54 };
     55 
     56 }  // namespace net
     57 
     58 #endif  // NET_BASE_NETWORK_CHANGE_NOTIFIER_MAC_H_
     59