Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1276)

Unified Diff: net/base/logging_network_change_observer.cc

Issue 1971853002: Move IOThread::LoggingNetworkChangeObserver to net/base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/logging_network_change_observer.h ('k') | net/net.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/logging_network_change_observer.cc
diff --git a/net/base/logging_network_change_observer.cc b/net/base/logging_network_change_observer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..871a44abbb4f08836ffd6696e245dffb48e0a70d
--- /dev/null
+++ b/net/base/logging_network_change_observer.cc
@@ -0,0 +1,58 @@
+// Copyright (c) 2016 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/logging_network_change_observer.h"
+
+#include <string>
+
+#include "base/logging.h"
+#include "net/log/net_log.h"
+
+namespace net {
+
+LoggingNetworkChangeObserver::LoggingNetworkChangeObserver(net::NetLog* net_log)
+ : net_log_(net_log) {
+ net::NetworkChangeNotifier::AddIPAddressObserver(this);
+ net::NetworkChangeNotifier::AddConnectionTypeObserver(this);
+ net::NetworkChangeNotifier::AddNetworkChangeObserver(this);
+}
+
+LoggingNetworkChangeObserver::~LoggingNetworkChangeObserver() {
+ net::NetworkChangeNotifier::RemoveIPAddressObserver(this);
+ net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this);
+ net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this);
+}
+
+void LoggingNetworkChangeObserver::OnIPAddressChanged() {
+ VLOG(1) << "Observed a change to the network IP addresses";
+
+ net_log_->AddGlobalEntry(net::NetLog::TYPE_NETWORK_IP_ADDRESSES_CHANGED);
+}
+
+void LoggingNetworkChangeObserver::OnConnectionTypeChanged(
+ net::NetworkChangeNotifier::ConnectionType type) {
+ std::string type_as_string =
+ net::NetworkChangeNotifier::ConnectionTypeToString(type);
+
+ VLOG(1) << "Observed a change to network connectivity state "
+ << type_as_string;
+
+ net_log_->AddGlobalEntry(
+ net::NetLog::TYPE_NETWORK_CONNECTIVITY_CHANGED,
+ net::NetLog::StringCallback("new_connection_type", &type_as_string));
+}
+
+void LoggingNetworkChangeObserver::OnNetworkChanged(
+ net::NetworkChangeNotifier::ConnectionType type) {
+ std::string type_as_string =
+ net::NetworkChangeNotifier::ConnectionTypeToString(type);
+
+ VLOG(1) << "Observed a network change to state " << type_as_string;
+
+ net_log_->AddGlobalEntry(
+ net::NetLog::TYPE_NETWORK_CHANGED,
+ net::NetLog::StringCallback("new_connection_type", &type_as_string));
+}
+
+} // namespace net
« no previous file with comments | « net/base/logging_network_change_observer.h ('k') | net/net.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698