Index: tools/android/common/net.cc |
diff --git a/tools/android/common/net.cc b/tools/android/common/net.cc |
index e50a18a9a45ad55414ba4deefde9fbf9c2d9a3f1..12bca8e787aabdecdc2d81547bf4ca7c465f1d4c 100644 |
--- a/tools/android/common/net.cc |
+++ b/tools/android/common/net.cc |
@@ -9,6 +9,8 @@ |
#include <sys/socket.h> |
#include <sys/types.h> |
+#include "base/stringprintf.h" |
+ |
namespace tools { |
int DisableNagle(int socket) { |
@@ -21,5 +23,18 @@ int DeferAccept(int socket) { |
return setsockopt(socket, IPPROTO_TCP, TCP_DEFER_ACCEPT, &on, sizeof(on)); |
} |
+std::string DumpBinary(const char* buffer, size_t length) { |
+ std::string result = "["; |
+ for (int i = 0; i < length; ++i) { |
+ base::StringAppendF(&result, "%02x,", |
+ static_cast<unsigned char>(buffer[i])); |
+ } |
+ |
+ if (length) |
+ result.erase(result.length() - 1); |
+ |
+ return result + "]"; |
+} |
+ |
} // namespace tools |