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

Unified Diff: net/base/logging_network_change_observer.cc

Issue 2251413003: Make NetworkChangeNotifier NetworkHandles readable in NetLog on Android M (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comment Created 4 years, 4 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 | « no previous file | no next file » | 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
index 3f690a29d0d2e85635af9eb90d9a5633edeb8c93..bd1f61afbb1522a1c016d4b3d7306053796b0301 100644
--- a/net/base/logging_network_change_observer.cc
+++ b/net/base/logging_network_change_observer.cc
@@ -11,10 +11,28 @@
#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
+ // Network.getNetworkHandle() by shifting away 0xfacade from
+ // http://androidxref.com/6.0.1_r10/xref/frameworks/base/core/java/android/net/Network.java#385
+ 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 +40,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)),
NetworkChangeNotifier::ConnectionTypeToString(
NetworkChangeNotifier::GetNetworkConnectionType(active_network)));
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698