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_WIN_H_
6#define NET_BASE_NETWORK_CHANGE_NOTIFIER_WIN_H_
7#pragma once
8
9#include <windows.h>
10
11#include "base/basictypes.h"
12#include "base/timer.h"
13#include "base/win/object_watcher.h"
14#include "net/base/network_change_notifier.h"
15
16namespace net {
17
18class NetworkChangeNotifierWin : public NetworkChangeNotifier,
19                                 public base::win::ObjectWatcher::Delegate {
20 public:
21  NetworkChangeNotifierWin();
22
23 private:
24  virtual ~NetworkChangeNotifierWin();
25
26  // NetworkChangeNotifier methods:
27  virtual bool IsCurrentlyOffline() const;
28
29  // ObjectWatcher::Delegate methods:
30  virtual void OnObjectSignaled(HANDLE object);
31
32  // Begins listening for a single subsequent address change.
33  void WatchForAddressChange();
34
35  // Forwards online state notifications to parent class.
36  void NotifyParentOfOnlineStateChange();
37
38  base::win::ObjectWatcher addr_watcher_;
39  OVERLAPPED addr_overlapped_;
40
41  base::OneShotTimer<NetworkChangeNotifierWin> timer_;
42
43  DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierWin);
44};
45
46}  // namespace net
47
48#endif  // NET_BASE_NETWORK_CHANGE_NOTIFIER_WIN_H_
49