Chromium Code Reviews| 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 |
| index 3f690a29d0d2e85635af9eb90d9a5633edeb8c93..a40f1966f54670dfd5e8ae31cc5f791bf464902f 100644 |
| --- a/net/base/logging_network_change_observer.cc |
| +++ b/net/base/logging_network_change_observer.cc |
| @@ -11,10 +11,27 @@ |
| #include "base/values.h" |
| #include "net/log/net_log.h" |
| +#if defined(OS_ANDROID) |
| +#include "base/android/build_info.h" |
| +#endif |
| + |
| namespace net { |
| namespace { |
| +// Returns a human readable integer from a NetworkHandle. |
| +int HumanReadableNetworkHandle(NetworkChangeNotifier::NetworkHandle network) { |
| +#if defined(OS_ANDROID) |
| + // On Marshmallow, demunge the NetID to undo munging done in java |
|
xunjieli
2016/08/18 17:15:17
Could you add a comment here that the NetID's lowe
pauljensen
2016/08/19 11:57:47
Done.
|
| + // Network.getNetworkHandle(). |
| + if (base::android::BuildInfo::GetInstance()->sdk_int() >= |
| + base::android::SDK_VERSION_MARSHMALLOW) { |
| + return network >> 32; |
| + } |
| +#endif |
| + return network; |
| +} |
| + |
| // Return a dictionary of values that provide information about a |
| // network-specific change. This also includes relevant current state |
| // like the default network, and the types of active networks. |
| @@ -22,18 +39,21 @@ std::unique_ptr<base::Value> NetworkSpecificNetLogCallback( |
| NetworkChangeNotifier::NetworkHandle network, |
| NetLogCaptureMode capture_mode) { |
| std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| - dict->SetInteger("changed_network_handle", network); |
| + dict->SetInteger("changed_network_handle", |
| + HumanReadableNetworkHandle(network)); |
| dict->SetString( |
| "changed_network_type", |
| NetworkChangeNotifier::ConnectionTypeToString( |
| NetworkChangeNotifier::GetNetworkConnectionType(network))); |
| - dict->SetInteger("default_active_network_handle", |
| - NetworkChangeNotifier::GetDefaultNetwork()); |
| + dict->SetInteger( |
| + "default_active_network_handle", |
| + HumanReadableNetworkHandle(NetworkChangeNotifier::GetDefaultNetwork())); |
| NetworkChangeNotifier::NetworkList networks; |
| NetworkChangeNotifier::GetConnectedNetworks(&networks); |
| for (NetworkChangeNotifier::NetworkHandle active_network : networks) { |
| dict->SetString( |
| - "current_active_networks." + base::IntToString(active_network), |
| + "current_active_networks." + |
| + base::IntToString(HumanReadableNetworkHandle(active_network)), |
|
xunjieli
2016/08/18 16:13:16
Why does ">>32" make network handle human readable
pauljensen
2016/08/18 16:16:49
">> 32" makes it readable because it undoes the mu
xunjieli
2016/08/18 17:15:16
Makes sense. I forgot about the 0xfacade part.
|
| NetworkChangeNotifier::ConnectionTypeToString( |
| NetworkChangeNotifier::GetNetworkConnectionType(active_network))); |
| } |