blob: 052e3ef87bc914fcd7897da82ba14951e2442465 (
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
45
|
// 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.
#include "net/base/network_change_notifier_helper.h"
#include <algorithm>
#include "base/logging.h"
namespace net {
namespace internal {
NetworkChangeNotifierHelper::NetworkChangeNotifierHelper()
: is_notifying_observers_(false) {}
NetworkChangeNotifierHelper::~NetworkChangeNotifierHelper() {
// TODO(willchan): Re-enable this DCHECK after fixing http://crbug.com/34391
// since we're leaking URLRequestContextGetters that cause this DCHECK to
// fire.
// DCHECK(observers_.empty());
}
void NetworkChangeNotifierHelper::AddObserver(Observer* observer) {
DCHECK(!is_notifying_observers_);
observers_.push_back(observer);
}
void NetworkChangeNotifierHelper::RemoveObserver(Observer* observer) {
DCHECK(!is_notifying_observers_);
observers_.erase(std::remove(observers_.begin(), observers_.end(), observer));
}
void NetworkChangeNotifierHelper::OnIPAddressChanged() {
DCHECK(!is_notifying_observers_);
is_notifying_observers_ = true;
for (std::vector<Observer*>::iterator it = observers_.begin();
it != observers_.end(); ++it) {
(*it)->OnIPAddressChanged();
}
is_notifying_observers_ = false;
}
} // namespace internal
} // namespace net
|