summaryrefslogtreecommitdiffstats
path: root/net/base/network_change_notifier_helper.h
blob: f860c452b8807a698b2951e8b78522a616c54112 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// NetworkChangeNotifierHelper is a helper class that assists in implementing
// base functionality for a NetworkChangeNotifier implementation.  In
// particular, it manages adding/removing observers and sending them
// notifications of event changes.

#ifndef NET_BASE_NETWORK_CHANGE_NOTIFIER_HELPER_H_
#define NET_BASE_NETWORK_CHANGE_NOTIFIER_HELPER_H_

#include <vector>
#include "base/basictypes.h"
#include "net/base/network_change_notifier.h"

namespace net {

namespace internal {

class NetworkChangeNotifierHelper {
 public:
  typedef NetworkChangeNotifier::Observer Observer;

  NetworkChangeNotifierHelper();
  ~NetworkChangeNotifierHelper();

  void AddObserver(Observer* observer);
  void RemoveObserver(Observer* observer);

  void OnIPAddressChanged();

 private:
  bool is_notifying_observers_;
  std::vector<Observer*> observers_;

  DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierHelper);
};

}  // namespace internal

}  // namespace net

#endif  // NET_BASE_NETWORK_CHANGE_NOTIFIER_HELPER_H_