[Android WebViewShell] Add inclusion test for webview exposed stable interfaces.
[chromium-blink-merge.git] / tools / android / common / net.cc
bloba535656d62d075c439209faae21cf92ab95712db
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "tools/android/common/net.h"
7 #include <netinet/in.h>
8 #include <netinet/tcp.h>
9 #include <sys/socket.h>
10 #include <sys/types.h>
12 #include "base/strings/stringprintf.h"
14 namespace tools {
16 int DisableNagle(int socket) {
17 int on = 1;
18 return setsockopt(socket, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on));
21 int DeferAccept(int socket) {
22 int on = 1;
23 return setsockopt(socket, IPPROTO_TCP, TCP_DEFER_ACCEPT, &on, sizeof(on));
26 std::string DumpBinary(const char* buffer, size_t length) {
27 std::string result = "[";
28 for (size_t i = 0; i < length; ++i) {
29 base::StringAppendF(&result, "%02x,",
30 static_cast<unsigned char>(buffer[i]));
33 if (length)
34 result.erase(result.length() - 1);
36 return result + "]";
39 } // namespace tools