summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorfrankf@chromium.org <frankf@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-14 23:27:05 +0000
committerfrankf@chromium.org <frankf@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-14 23:27:05 +0000
commit29c1e8fa0c9915078f674a9c868c65b6ee1772a7 (patch)
tree5b0663fdb1db6fe907acde32990f21dfea0fb77a /tools
parent628e18aa9bbfc46b14afb70d2c2194aa5dee9914 (diff)
downloadchromium_src-29c1e8fa0c9915078f674a9c868c65b6ee1772a7.zip
chromium_src-29c1e8fa0c9915078f674a9c868c65b6ee1772a7.tar.gz
chromium_src-29c1e8fa0c9915078f674a9c868c65b6ee1772a7.tar.bz2
[Android] Clean up build/android and tools/android
- Remove the place holder modules - Remove unused device_status_monitor - Remove unused fake_dns R=bulach@chromium.org, craigdh@chromium.org Review URL: https://codereview.chromium.org/26402002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@228558 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools')
-rw-r--r--tools/android/android_tools.gyp1
-rw-r--r--tools/android/device_stats_monitor/device_stats_monitor.cc108
-rw-r--r--tools/android/device_stats_monitor/device_stats_monitor.gyp41
-rw-r--r--tools/android/fake_dns/DEPS3
-rw-r--r--tools/android/fake_dns/fake_dns.cc238
-rw-r--r--tools/android/fake_dns/fake_dns.gyp44
6 files changed, 0 insertions, 435 deletions
diff --git a/tools/android/android_tools.gyp b/tools/android/android_tools.gyp
index 0e566d9..6bad985 100644
--- a/tools/android/android_tools.gyp
+++ b/tools/android/android_tools.gyp
@@ -10,7 +10,6 @@
'target_name': 'android_tools',
'type': 'none',
'dependencies': [
- 'fake_dns/fake_dns.gyp:fake_dns',
'forwarder2/forwarder.gyp:forwarder2',
'md5sum/md5sum.gyp:md5sum',
'adb_reboot/adb_reboot.gyp:adb_reboot',
diff --git a/tools/android/device_stats_monitor/device_stats_monitor.cc b/tools/android/device_stats_monitor/device_stats_monitor.cc
deleted file mode 100644
index ef2fee9..0000000
--- a/tools/android/device_stats_monitor/device_stats_monitor.cc
+++ /dev/null
@@ -1,108 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Dumps CPU and IO stats to a file at a regular interval.
-//
-// Output may be post processed by host to get top/iotop style information.
-
-#include <signal.h>
-#include <unistd.h>
-
-#include <fstream>
-#include <string>
-#include <vector>
-
-#include "base/command_line.h"
-#include "base/file_util.h"
-#include "base/strings/string_split.h"
-
-namespace {
-
-const char kIOStatsPath[] = "/proc/diskstats";
-const char kCPUStatsPath[] = "/proc/stat";
-
-class DeviceStatsMonitor {
- public:
- explicit DeviceStatsMonitor(const std::string& out_path)
- : out_path_(out_path),
- record_(true) {
- CHECK(!out_path_.empty());
- samples_.reserve(1024 * 1024);
- }
-
- // Records stats continuously at |hz| cycles per second util
- // StopRecordingAndDumpStats() is called.
- //
- // Yes, this buffers everything in memory, so it cannot be used for extended
- // durations without OOM. But that beats writing during the trace which
- // would affect the results.
- void Start(int hz) {
- const int sample_interval = 1000000 / hz;
- const base::FilePath io_stats_path(kIOStatsPath);
- const base::FilePath cpu_stats_path(kCPUStatsPath);
- std::string out;
- while (record_) {
- out.clear();
- CHECK(base::ReadFileToString(io_stats_path, &out));
- CHECK(base::ReadFileToString(cpu_stats_path, &out));
- samples_.push_back(out);
- usleep(sample_interval);
- }
- }
-
- // Stops recording and saves samples to file.
- void StopAndDumpStats() {
- record_ = false;
- usleep(250 * 1000);
- std::ofstream out_stream;
- out_stream.open(out_path_.value().c_str(), std::ios::out);
- for (std::vector<std::string>::const_iterator i = samples_.begin();
- i != samples_.end(); ++i) {
- out_stream << i->c_str() << std::endl;
- }
- out_stream.close();
- }
-
- private:
- const base::FilePath out_path_;
- std::vector<std::string> samples_;
- bool record_;
-
- DISALLOW_COPY_AND_ASSIGN(DeviceStatsMonitor);
-};
-
-DeviceStatsMonitor* g_device_stats_monitor = NULL;
-
-void SigTermHandler(int unused) {
- printf("Stopping device stats monitor\n");
- g_device_stats_monitor->StopAndDumpStats();
-}
-
-} // namespace
-
-int main(int argc, char** argv) {
- const int kDefaultHz = 20;
-
- CommandLine command_line(argc, argv);
- CommandLine::StringVector args = command_line.GetArgs();
- if (command_line.HasSwitch("h") || command_line.HasSwitch("help") ||
- args.size() != 1) {
- printf("Usage: %s OUTPUT_FILE\n"
- " --hz=HZ Number of samples/second. default=%d\n",
- argv[0], kDefaultHz);
- return 1;
- }
-
- int hz = command_line.HasSwitch("hz") ?
- atoi(command_line.GetSwitchValueNative("hz").c_str()) :
- kDefaultHz;
-
- printf("Starting device stats monitor\n");
- g_device_stats_monitor = new DeviceStatsMonitor(args[0]);
- signal(SIGTERM, SigTermHandler);
- g_device_stats_monitor->Start(hz);
- delete g_device_stats_monitor;
-
- return 0;
-}
diff --git a/tools/android/device_stats_monitor/device_stats_monitor.gyp b/tools/android/device_stats_monitor/device_stats_monitor.gyp
deleted file mode 100644
index f9bd9e8..0000000
--- a/tools/android/device_stats_monitor/device_stats_monitor.gyp
+++ /dev/null
@@ -1,41 +0,0 @@
-# Copyright (c) 2012 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-{
- 'targets': [
- {
- 'target_name': 'device_stats_monitor',
- 'type': 'none',
- 'dependencies': [
- 'device_stats_monitor_symbols',
- ],
- 'actions': [
- {
- 'action_name': 'strip_device_stats_monitor',
- 'inputs': ['<(PRODUCT_DIR)/device_stats_monitor_symbols'],
- 'outputs': ['<(PRODUCT_DIR)/device_stats_monitor'],
- 'action': [
- '<(android_strip)',
- '--strip-unneeded',
- '<@(_inputs)',
- '-o',
- '<@(_outputs)',
- ],
- },
- ],
- }, {
- 'target_name': 'device_stats_monitor_symbols',
- 'type': 'executable',
- 'dependencies': [
- '../../../base/base.gyp:base',
- ],
- 'include_dirs': [
- '../../..',
- ],
- 'sources': [
- 'device_stats_monitor.cc',
- ],
- },
- ],
-}
diff --git a/tools/android/fake_dns/DEPS b/tools/android/fake_dns/DEPS
deleted file mode 100644
index 8fa9d48..0000000
--- a/tools/android/fake_dns/DEPS
+++ /dev/null
@@ -1,3 +0,0 @@
-include_rules = [
- "+net",
-]
diff --git a/tools/android/fake_dns/fake_dns.cc b/tools/android/fake_dns/fake_dns.cc
deleted file mode 100644
index 9a055bf..0000000
--- a/tools/android/fake_dns/fake_dns.cc
+++ /dev/null
@@ -1,238 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <arpa/inet.h>
-#include <errno.h>
-#include <netinet/in.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include <string>
-
-#include "base/basictypes.h"
-#include "base/command_line.h"
-#include "base/logging.h"
-#include "base/posix/eintr_wrapper.h"
-#include "base/safe_strerror_posix.h"
-#include "net/base/big_endian.h"
-#include "net/base/net_util.h"
-#include "net/dns/dns_protocol.h"
-#include "tools/android/common/daemon.h"
-#include "tools/android/common/net.h"
-
-namespace {
-
-// Mininum request size: 1 question containing 1 QNAME, 1 TYPE and 1 CLASS.
-const size_t kMinRequestSize = sizeof(net::dns_protocol::Header) + 6;
-
-// The name reference in the answer pointing to the name in the query.
-// Its format is: highest two bits set to 1, then the offset of the name
-// which just follows the header.
-const uint16 kPointerToQueryName =
- static_cast<uint16>(0xc000 | sizeof(net::dns_protocol::Header));
-
-const uint32 kTTL = 86400; // One day.
-
-void PError(const char* msg) {
- int current_errno = errno;
- LOG(ERROR) << "ERROR: " << msg << ": " << safe_strerror(current_errno);
-}
-
-void SendTo(int sockfd, const void* buf, size_t len, int flags,
- const sockaddr* dest_addr, socklen_t addrlen) {
- if (HANDLE_EINTR(sendto(sockfd, buf, len, flags, dest_addr, addrlen)) == -1)
- PError("sendto()");
-}
-
-void CloseFileDescriptor(int fd) {
- int old_errno = errno;
- (void) HANDLE_EINTR(close(fd));
- errno = old_errno;
-}
-
-void SendRefusedResponse(int sock, const sockaddr_in& client_addr, uint16 id) {
- net::dns_protocol::Header response;
- response.id = htons(id);
- response.flags = htons(net::dns_protocol::kFlagResponse |
- net::dns_protocol::kFlagAA |
- net::dns_protocol::kFlagRD |
- net::dns_protocol::kFlagRA |
- net::dns_protocol::kRcodeREFUSED);
- response.qdcount = 0;
- response.ancount = 0;
- response.nscount = 0;
- response.arcount = 0;
- SendTo(sock, &response, sizeof(response), 0,
- reinterpret_cast<const sockaddr*>(&client_addr), sizeof(client_addr));
-}
-
-void SendResponse(int sock, const sockaddr_in& client_addr, uint16 id,
- uint16 qtype, const char* question, size_t question_length) {
- net::dns_protocol::Header header;
- header.id = htons(id);
- header.flags = htons(net::dns_protocol::kFlagResponse |
- net::dns_protocol::kFlagAA |
- net::dns_protocol::kFlagRD |
- net::dns_protocol::kFlagRA |
- net::dns_protocol::kRcodeNOERROR);
- header.qdcount = htons(1);
- header.ancount = htons(1);
- header.nscount = 0;
- header.arcount = 0;
-
- // Size of RDATA which is a IPv4 or IPv6 address.
- size_t rdata_size = qtype == net::dns_protocol::kTypeA ?
- net::kIPv4AddressSize : net::kIPv6AddressSize;
-
- // Size of the whole response which contains the header, the question and
- // the answer. 12 is the sum of sizes of the compressed name reference, TYPE,
- // CLASS, TTL and RDLENGTH.
- size_t response_size = sizeof(header) + question_length + 12 + rdata_size;
-
- if (response_size > net::dns_protocol::kMaxUDPSize) {
- LOG(ERROR) << "Response is too large: " << response_size;
- SendRefusedResponse(sock, client_addr, id);
- return;
- }
-
- char response[net::dns_protocol::kMaxUDPSize];
- net::BigEndianWriter writer(response, arraysize(response));
- writer.WriteBytes(&header, sizeof(header));
-
- // Repeat the question in the response. Some clients (e.g. ping) needs this.
- writer.WriteBytes(question, question_length);
-
- // Construct the answer.
- writer.WriteU16(kPointerToQueryName);
- writer.WriteU16(qtype);
- writer.WriteU16(net::dns_protocol::kClassIN);
- writer.WriteU32(kTTL);
- writer.WriteU16(rdata_size);
- if (qtype == net::dns_protocol::kTypeA)
- writer.WriteU32(INADDR_LOOPBACK);
- else
- writer.WriteBytes(&in6addr_loopback, sizeof(in6_addr));
- DCHECK(writer.ptr() - response == response_size);
-
- SendTo(sock, response, response_size, 0,
- reinterpret_cast<const sockaddr*>(&client_addr), sizeof(client_addr));
-}
-
-void HandleRequest(int sock, const char* request, size_t size,
- const sockaddr_in& client_addr) {
- if (size < kMinRequestSize) {
- LOG(ERROR) << "Request is too small " << size
- << "\n" << tools::DumpBinary(request, size);
- return;
- }
-
- net::BigEndianReader reader(request, size);
- net::dns_protocol::Header header;
- reader.ReadBytes(&header, sizeof(header));
- uint16 id = ntohs(header.id);
- uint16 flags = ntohs(header.flags);
- uint16 qdcount = ntohs(header.qdcount);
- uint16 ancount = ntohs(header.ancount);
- uint16 nscount = ntohs(header.nscount);
- uint16 arcount = ntohs(header.arcount);
-
- const uint16 kAllowedFlags = 0x07ff;
- if ((flags & ~kAllowedFlags) ||
- qdcount != 1 || ancount || nscount || arcount) {
- LOG(ERROR) << "Unsupported request: FLAGS=" << flags
- << " QDCOUNT=" << qdcount
- << " ANCOUNT=" << ancount
- << " NSCOUNT=" << nscount
- << " ARCOUNT=" << arcount
- << "\n" << tools::DumpBinary(request, size);
- SendRefusedResponse(sock, client_addr, id);
- return;
- }
-
- // request[size - 5] should be the end of the QNAME (a zero byte).
- // We don't care about the validity of QNAME because we don't parse it.
- const char* qname_end = &request[size - 5];
- if (*qname_end) {
- LOG(ERROR) << "Error parsing QNAME\n" << tools::DumpBinary(request, size);
- SendRefusedResponse(sock, client_addr, id);
- return;
- }
-
- reader.Skip(qname_end - reader.ptr() + 1);
-
- uint16 qtype;
- uint16 qclass;
- reader.ReadU16(&qtype);
- reader.ReadU16(&qclass);
- if ((qtype != net::dns_protocol::kTypeA &&
- qtype != net::dns_protocol::kTypeAAAA) ||
- qclass != net::dns_protocol::kClassIN) {
- LOG(ERROR) << "Unsupported query: QTYPE=" << qtype << " QCLASS=" << qclass
- << "\n" << tools::DumpBinary(request, size);
- SendRefusedResponse(sock, client_addr, id);
- return;
- }
-
- SendResponse(sock, client_addr, id, qtype,
- request + sizeof(header), size - sizeof(header));
-}
-
-} // namespace
-
-int main(int argc, char** argv) {
- printf("Fake DNS server\n");
-
- CommandLine command_line(argc, argv);
- if (tools::HasHelpSwitch(command_line) || command_line.GetArgs().size()) {
- tools::ShowHelp(argv[0], "", "");
- return 0;
- }
-
- int sock = socket(AF_INET, SOCK_DGRAM, 0);
- if (sock < 0) {
- PError("create socket");
- return 1;
- }
-
- sockaddr_in addr;
- memset(&addr, 0, sizeof(addr));
- addr.sin_family = AF_INET;
- addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
- addr.sin_port = htons(53);
- int reuse_addr = 1;
- if (HANDLE_EINTR(bind(sock, reinterpret_cast<sockaddr*>(&addr),
- sizeof(addr))) < 0) {
- PError("server bind");
- CloseFileDescriptor(sock);
- return 1;
- }
-
- if (!tools::HasNoSpawnDaemonSwitch(command_line))
- tools::SpawnDaemon(0);
-
- while (true) {
- sockaddr_in client_addr;
- socklen_t client_addr_len = sizeof(client_addr);
- char request[net::dns_protocol::kMaxUDPSize];
- int size = HANDLE_EINTR(recvfrom(sock, request, sizeof(request),
- MSG_WAITALL,
- reinterpret_cast<sockaddr*>(&client_addr),
- &client_addr_len));
- if (size < 0) {
- // Unrecoverable error, can only exit.
- LOG(ERROR) << "Failed to receive a request: " << strerror(errno);
- CloseFileDescriptor(sock);
- return 1;
- }
-
- if (size > 0)
- HandleRequest(sock, request, size, client_addr);
- }
-}
-
diff --git a/tools/android/fake_dns/fake_dns.gyp b/tools/android/fake_dns/fake_dns.gyp
deleted file mode 100644
index 0edacfa..0000000
--- a/tools/android/fake_dns/fake_dns.gyp
+++ /dev/null
@@ -1,44 +0,0 @@
-# Copyright (c) 2012 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-{
- 'targets': [
- {
- 'target_name': 'fake_dns',
- 'type': 'none',
- 'dependencies': [
- 'fake_dns_symbols',
- ],
- 'actions': [
- {
- 'action_name': 'strip_fake_dns',
- 'inputs': ['<(PRODUCT_DIR)/fake_dns_symbols'],
- 'outputs': ['<(PRODUCT_DIR)/fake_dns'],
- 'action': [
- '<(android_strip)',
- '--strip-unneeded',
- '<@(_inputs)',
- '-o',
- '<@(_outputs)',
- ],
- },
- ],
- }, {
- 'target_name': 'fake_dns_symbols',
- 'type': 'executable',
- 'dependencies': [
- '../../../base/base.gyp:base',
- '../../../net/net.gyp:net',
- '../common/common.gyp:android_tools_common',
- ],
- 'include_dirs': [
- '../../..',
- ],
- 'sources': [
- 'fake_dns.cc',
- ],
- },
- ],
-}
-