blob: f138c7389b05623ebdbdda15aeb0f464e8feb394 [file] [log] [blame]
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "net/quic/network_connection.h"
#include "base/logging.h"
#include "net/base/network_interfaces.h"
namespace net {
NetworkConnection::NetworkConnection() {
NetworkChangeNotifier::AddIPAddressObserver(this);
NetworkChangeNotifier::AddConnectionTypeObserver(this);
OnIPAddressChanged(NetworkChangeNotifier::IP_ADDRESS_CHANGE_NORMAL);
}
NetworkConnection::~NetworkConnection() {
NetworkChangeNotifier::RemoveConnectionTypeObserver(this);
NetworkChangeNotifier::RemoveIPAddressObserver(this);
}
void NetworkConnection::OnIPAddressChanged(
NetworkChangeNotifier::IPAddressChangeType change_type) {
OnConnectionTypeChanged(NetworkChangeNotifier::GetConnectionType());
}
void NetworkConnection::OnConnectionTypeChanged(
NetworkChangeNotifier::ConnectionType type) {
DVLOG(1) << "Updating NetworkConnection's Cached Data";
connection_type_ = type;
connection_description_ =
NetworkChangeNotifier::ConnectionTypeToString(type).c_str();
}
} // namespace net