| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/base/logging_network_change_observer.h" | 5 #include "net/base/logging_network_change_observer.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "net/log/net_log.h" | 12 #include "net/log/net_log.h" |
| 13 #include "net/log/net_log_event_type.h" |
| 13 | 14 |
| 14 #if defined(OS_ANDROID) | 15 #if defined(OS_ANDROID) |
| 15 #include "base/android/build_info.h" | 16 #include "base/android/build_info.h" |
| 16 #endif | 17 #endif |
| 17 | 18 |
| 18 namespace net { | 19 namespace net { |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 // Returns a human readable integer from a NetworkHandle. | 23 // Returns a human readable integer from a NetworkHandle. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 NetworkChangeNotifier::RemoveIPAddressObserver(this); | 77 NetworkChangeNotifier::RemoveIPAddressObserver(this); |
| 77 NetworkChangeNotifier::RemoveConnectionTypeObserver(this); | 78 NetworkChangeNotifier::RemoveConnectionTypeObserver(this); |
| 78 NetworkChangeNotifier::RemoveNetworkChangeObserver(this); | 79 NetworkChangeNotifier::RemoveNetworkChangeObserver(this); |
| 79 if (NetworkChangeNotifier::AreNetworkHandlesSupported()) | 80 if (NetworkChangeNotifier::AreNetworkHandlesSupported()) |
| 80 NetworkChangeNotifier::RemoveNetworkObserver(this); | 81 NetworkChangeNotifier::RemoveNetworkObserver(this); |
| 81 } | 82 } |
| 82 | 83 |
| 83 void LoggingNetworkChangeObserver::OnIPAddressChanged() { | 84 void LoggingNetworkChangeObserver::OnIPAddressChanged() { |
| 84 VLOG(1) << "Observed a change to the network IP addresses"; | 85 VLOG(1) << "Observed a change to the network IP addresses"; |
| 85 | 86 |
| 86 net_log_->AddGlobalEntry(NetLog::TYPE_NETWORK_IP_ADDRESSES_CHANGED); | 87 net_log_->AddGlobalEntry(NetLogEventType::NETWORK_IP_ADDRESSES_CHANGED); |
| 87 } | 88 } |
| 88 | 89 |
| 89 void LoggingNetworkChangeObserver::OnConnectionTypeChanged( | 90 void LoggingNetworkChangeObserver::OnConnectionTypeChanged( |
| 90 NetworkChangeNotifier::ConnectionType type) { | 91 NetworkChangeNotifier::ConnectionType type) { |
| 91 std::string type_as_string = | 92 std::string type_as_string = |
| 92 NetworkChangeNotifier::ConnectionTypeToString(type); | 93 NetworkChangeNotifier::ConnectionTypeToString(type); |
| 93 | 94 |
| 94 VLOG(1) << "Observed a change to network connectivity state " | 95 VLOG(1) << "Observed a change to network connectivity state " |
| 95 << type_as_string; | 96 << type_as_string; |
| 96 | 97 |
| 97 net_log_->AddGlobalEntry( | 98 net_log_->AddGlobalEntry( |
| 98 NetLog::TYPE_NETWORK_CONNECTIVITY_CHANGED, | 99 NetLogEventType::NETWORK_CONNECTIVITY_CHANGED, |
| 99 NetLog::StringCallback("new_connection_type", &type_as_string)); | 100 NetLog::StringCallback("new_connection_type", &type_as_string)); |
| 100 } | 101 } |
| 101 | 102 |
| 102 void LoggingNetworkChangeObserver::OnNetworkChanged( | 103 void LoggingNetworkChangeObserver::OnNetworkChanged( |
| 103 NetworkChangeNotifier::ConnectionType type) { | 104 NetworkChangeNotifier::ConnectionType type) { |
| 104 std::string type_as_string = | 105 std::string type_as_string = |
| 105 NetworkChangeNotifier::ConnectionTypeToString(type); | 106 NetworkChangeNotifier::ConnectionTypeToString(type); |
| 106 | 107 |
| 107 VLOG(1) << "Observed a network change to state " << type_as_string; | 108 VLOG(1) << "Observed a network change to state " << type_as_string; |
| 108 | 109 |
| 109 net_log_->AddGlobalEntry( | 110 net_log_->AddGlobalEntry( |
| 110 NetLog::TYPE_NETWORK_CHANGED, | 111 NetLogEventType::NETWORK_CHANGED, |
| 111 NetLog::StringCallback("new_connection_type", &type_as_string)); | 112 NetLog::StringCallback("new_connection_type", &type_as_string)); |
| 112 } | 113 } |
| 113 | 114 |
| 114 void LoggingNetworkChangeObserver::OnNetworkConnected( | 115 void LoggingNetworkChangeObserver::OnNetworkConnected( |
| 115 NetworkChangeNotifier::NetworkHandle network) { | 116 NetworkChangeNotifier::NetworkHandle network) { |
| 116 VLOG(1) << "Observed network " << network << " connect"; | 117 VLOG(1) << "Observed network " << network << " connect"; |
| 117 | 118 |
| 118 net_log_->AddGlobalEntry(NetLog::TYPE_SPECIFIC_NETWORK_CONNECTED, | 119 net_log_->AddGlobalEntry(NetLogEventType::SPECIFIC_NETWORK_CONNECTED, |
| 119 base::Bind(&NetworkSpecificNetLogCallback, network)); | 120 base::Bind(&NetworkSpecificNetLogCallback, network)); |
| 120 } | 121 } |
| 121 | 122 |
| 122 void LoggingNetworkChangeObserver::OnNetworkDisconnected( | 123 void LoggingNetworkChangeObserver::OnNetworkDisconnected( |
| 123 NetworkChangeNotifier::NetworkHandle network) { | 124 NetworkChangeNotifier::NetworkHandle network) { |
| 124 VLOG(1) << "Observed network " << network << " disconnect"; | 125 VLOG(1) << "Observed network " << network << " disconnect"; |
| 125 | 126 |
| 126 net_log_->AddGlobalEntry(NetLog::TYPE_SPECIFIC_NETWORK_DISCONNECTED, | 127 net_log_->AddGlobalEntry(NetLogEventType::SPECIFIC_NETWORK_DISCONNECTED, |
| 127 base::Bind(&NetworkSpecificNetLogCallback, network)); | 128 base::Bind(&NetworkSpecificNetLogCallback, network)); |
| 128 } | 129 } |
| 129 | 130 |
| 130 void LoggingNetworkChangeObserver::OnNetworkSoonToDisconnect( | 131 void LoggingNetworkChangeObserver::OnNetworkSoonToDisconnect( |
| 131 NetworkChangeNotifier::NetworkHandle network) { | 132 NetworkChangeNotifier::NetworkHandle network) { |
| 132 VLOG(1) << "Observed network " << network << " soon to disconnect"; | 133 VLOG(1) << "Observed network " << network << " soon to disconnect"; |
| 133 | 134 |
| 134 net_log_->AddGlobalEntry(NetLog::TYPE_SPECIFIC_NETWORK_SOON_TO_DISCONNECT, | 135 net_log_->AddGlobalEntry(NetLogEventType::SPECIFIC_NETWORK_SOON_TO_DISCONNECT, |
| 135 base::Bind(&NetworkSpecificNetLogCallback, network)); | 136 base::Bind(&NetworkSpecificNetLogCallback, network)); |
| 136 } | 137 } |
| 137 | 138 |
| 138 void LoggingNetworkChangeObserver::OnNetworkMadeDefault( | 139 void LoggingNetworkChangeObserver::OnNetworkMadeDefault( |
| 139 NetworkChangeNotifier::NetworkHandle network) { | 140 NetworkChangeNotifier::NetworkHandle network) { |
| 140 VLOG(1) << "Observed network " << network << " made the default network"; | 141 VLOG(1) << "Observed network " << network << " made the default network"; |
| 141 | 142 |
| 142 net_log_->AddGlobalEntry(NetLog::TYPE_SPECIFIC_NETWORK_MADE_DEFAULT, | 143 net_log_->AddGlobalEntry(NetLogEventType::SPECIFIC_NETWORK_MADE_DEFAULT, |
| 143 base::Bind(&NetworkSpecificNetLogCallback, network)); | 144 base::Bind(&NetworkSpecificNetLogCallback, network)); |
| 144 } | 145 } |
| 145 | 146 |
| 146 } // namespace net | 147 } // namespace net |
| OLD | NEW |