1c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Copyright (c) 2010 The Chromium Authors. All rights reserved.
2c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// Use of this source code is governed by a BSD-style license that can be
3c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott// found in the LICENSE file.
4c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
5c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#ifndef NET_BASE_NETWORK_CHANGE_NOTIFIER_MAC_H_
6c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#define NET_BASE_NETWORK_CHANGE_NOTIFIER_MAC_H_
73345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick#pragma once
8c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
9c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include <SystemConfiguration/SCDynamicStore.h>
10c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
11c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#include "base/basictypes.h"
12c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#include "net/base/network_change_notifier.h"
133345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick#include "net/base/network_config_watcher_mac.h"
14c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
15c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scottnamespace net {
16c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
173345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrickclass NetworkChangeNotifierMac: public NetworkChangeNotifier {
18c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott public:
19c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  NetworkChangeNotifierMac();
20c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  virtual ~NetworkChangeNotifierMac();
21c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
22731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick  // NetworkChangeNotifier implementation:
23731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick  virtual bool IsCurrentlyOffline() const;
24731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick
253345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick private:
263345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick  // Forwarder just exists to keep the NetworkConfigWatcherMac API out of
273345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick  // NetworkChangeNotifierMac's public API.
283345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick  class Forwarder : public NetworkConfigWatcherMac::Delegate {
293345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick   public:
303345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick    explicit Forwarder(NetworkChangeNotifierMac* net_config_watcher)
313345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick        : net_config_watcher_(net_config_watcher) {}
323345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick
333345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick    // NetworkConfigWatcherMac::Delegate implementation:
343345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick    virtual void SetDynamicStoreNotificationKeys(SCDynamicStoreRef store) {
353345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick      net_config_watcher_->SetDynamicStoreNotificationKeys(store);
363345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick    }
373345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick    virtual void OnNetworkConfigChange(CFArrayRef changed_keys) {
383345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick      net_config_watcher_->OnNetworkConfigChange(changed_keys);
393345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick    }
403345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick
413345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick   private:
423345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick    NetworkChangeNotifierMac* const net_config_watcher_;
433345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick    DISALLOW_COPY_AND_ASSIGN(Forwarder);
443345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick  };
453345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick
463345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick  // NetworkConfigWatcherMac::Delegate implementation:
473345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick  void SetDynamicStoreNotificationKeys(SCDynamicStoreRef store);
48c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  void OnNetworkConfigChange(CFArrayRef changed_keys);
49c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
503345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick  Forwarder forwarder_;
513345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick  const NetworkConfigWatcherMac config_watcher_;
52c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
53c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott  DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierMac);
54c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott};
55c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
56c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott}  // namespace net
57c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott
58c7f5f8508d98d5952d42ed7648c2a8f30a4da156Patrick Scott#endif  // NET_BASE_NETWORK_CHANGE_NOTIFIER_MAC_H_
59