Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2016 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 #include "net/base/logging_network_change_observer.h" | |
| 6 | |
| 7 #include "net/log/net_log.h" | |
| 8 | |
| 9 namespace net { | |
| 10 | |
| 11 LoggingNetworkChangeObserver::LoggingNetworkChangeObserver(net::NetLog* net_log) | |
| 12 : net_log_(net_log) { | |
| 13 net::NetworkChangeNotifier::AddIPAddressObserver(this); | |
| 14 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); | |
| 15 net::NetworkChangeNotifier::AddNetworkChangeObserver(this); | |
| 16 } | |
| 17 | |
| 18 LoggingNetworkChangeObserver::~LoggingNetworkChangeObserver() { | |
| 19 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); | |
| 20 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this); | |
| 21 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this); | |
| 22 } | |
| 23 | |
| 24 void LoggingNetworkChangeObserver::OnIPAddressChanged() { | |
| 25 VLOG(1) << "Observed a change to the network IP addresses"; | |
|
mmenke
2016/05/12 16:47:58
need base/logging.h.
pauljensen
2016/05/12 16:52:56
Done.
| |
| 26 | |
| 27 net_log_->AddGlobalEntry(net::NetLog::TYPE_NETWORK_IP_ADDRESSES_CHANGED); | |
| 28 } | |
| 29 | |
| 30 void LoggingNetworkChangeObserver::OnConnectionTypeChanged( | |
| 31 net::NetworkChangeNotifier::ConnectionType type) { | |
| 32 std::string type_as_string = | |
|
mmenke
2016/05/12 16:47:58
include <string>
pauljensen
2016/05/12 16:52:56
Done.
| |
| 33 net::NetworkChangeNotifier::ConnectionTypeToString(type); | |
| 34 | |
| 35 VLOG(1) << "Observed a change to network connectivity state " | |
| 36 << type_as_string; | |
| 37 | |
| 38 net_log_->AddGlobalEntry( | |
| 39 net::NetLog::TYPE_NETWORK_CONNECTIVITY_CHANGED, | |
| 40 net::NetLog::StringCallback("new_connection_type", &type_as_string)); | |
| 41 } | |
| 42 | |
| 43 void LoggingNetworkChangeObserver::OnNetworkChanged( | |
| 44 net::NetworkChangeNotifier::ConnectionType type) { | |
| 45 std::string type_as_string = | |
| 46 net::NetworkChangeNotifier::ConnectionTypeToString(type); | |
| 47 | |
| 48 VLOG(1) << "Observed a network change to state " << type_as_string; | |
| 49 | |
| 50 net_log_->AddGlobalEntry( | |
| 51 net::NetLog::TYPE_NETWORK_CHANGED, | |
| 52 net::NetLog::StringCallback("new_connection_type", &type_as_string)); | |
| 53 } | |
| 54 | |
| 55 } // namespace net | |
| OLD | NEW |