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

Side by Side Diff: tools/android/forwarder2/host_forwarder_main.cc

Issue 684133002: [Android] Fix gn build for instrumentation tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Follow review Created 6 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « tools/android/forwarder2/forwarders_manager.cc ('k') | tools/android/forwarder2/socket.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <errno.h> 5 #include <errno.h>
6 #include <signal.h> 6 #include <signal.h>
7 #include <sys/types.h> 7 #include <sys/types.h>
8 #include <sys/wait.h> 8 #include <sys/wait.h>
9 #include <unistd.h> 9 #include <unistd.h>
10 10
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "tools/android/forwarder2/pipe_notifier.h" 42 #include "tools/android/forwarder2/pipe_notifier.h"
43 #include "tools/android/forwarder2/socket.h" 43 #include "tools/android/forwarder2/socket.h"
44 #include "tools/android/forwarder2/util.h" 44 #include "tools/android/forwarder2/util.h"
45 45
46 namespace forwarder2 { 46 namespace forwarder2 {
47 namespace { 47 namespace {
48 48
49 const char kLogFilePath[] = "/tmp/host_forwarder_log"; 49 const char kLogFilePath[] = "/tmp/host_forwarder_log";
50 const char kDaemonIdentifier[] = "chrome_host_forwarder_daemon"; 50 const char kDaemonIdentifier[] = "chrome_host_forwarder_daemon";
51 51
52 const char kKillServerCommand[] = "kill-server";
53 const char kForwardCommand[] = "forward";
54
55 const int kBufSize = 256; 52 const int kBufSize = 256;
56 53
57 // Needs to be global to be able to be accessed from the signal handler. 54 // Needs to be global to be able to be accessed from the signal handler.
58 PipeNotifier* g_notifier = NULL; 55 PipeNotifier* g_notifier = NULL;
59 56
60 // Lets the daemon fetch the exit notifier file descriptor. 57 // Lets the daemon fetch the exit notifier file descriptor.
61 int GetExitNotifierFD() { 58 int GetExitNotifierFD() {
62 DCHECK(g_notifier); 59 DCHECK(g_notifier);
63 return g_notifier->receiver_fd(); 60 return g_notifier->receiver_fd();
64 } 61 }
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 ClientDelegate(const Pickle& command_pickle) 354 ClientDelegate(const Pickle& command_pickle)
358 : command_pickle_(command_pickle), 355 : command_pickle_(command_pickle),
359 has_failed_(false) { 356 has_failed_(false) {
360 } 357 }
361 358
362 bool has_failed() const { return has_failed_; } 359 bool has_failed() const { return has_failed_; }
363 360
364 // Daemon::ClientDelegate: 361 // Daemon::ClientDelegate:
365 virtual void OnDaemonReady(Socket* daemon_socket) override { 362 virtual void OnDaemonReady(Socket* daemon_socket) override {
366 // Send the forward command to the daemon. 363 // Send the forward command to the daemon.
367 CHECK_EQ(command_pickle_.size(), 364 CHECK_EQ(static_cast<long>(command_pickle_.size()),
368 daemon_socket->WriteNumBytes(command_pickle_.data(), 365 daemon_socket->WriteNumBytes(command_pickle_.data(),
369 command_pickle_.size())); 366 command_pickle_.size()));
370 char buf[kBufSize]; 367 char buf[kBufSize];
371 const int bytes_read = daemon_socket->Read( 368 const int bytes_read = daemon_socket->Read(
372 buf, sizeof(buf) - 1 /* leave space for null terminator */); 369 buf, sizeof(buf) - 1 /* leave space for null terminator */);
373 CHECK_GT(bytes_read, 0); 370 CHECK_GT(bytes_read, 0);
374 DCHECK(bytes_read < sizeof(buf)); 371 DCHECK(static_cast<size_t>(bytes_read) < sizeof(buf));
375 buf[bytes_read] = 0; 372 buf[bytes_read] = 0;
376 base::StringPiece msg(buf, bytes_read); 373 base::StringPiece msg(buf, bytes_read);
377 if (msg.starts_with("ERROR")) { 374 if (msg.starts_with("ERROR")) {
378 LOG(ERROR) << msg; 375 LOG(ERROR) << msg;
379 has_failed_ = true; 376 has_failed_ = true;
380 return; 377 return;
381 } 378 }
382 printf("%s\n", buf); 379 printf("%s\n", buf);
383 } 380 }
384 381
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 448
452 return client_delegate.has_failed() || daemon_delegate.has_failed(); 449 return client_delegate.has_failed() || daemon_delegate.has_failed();
453 } 450 }
454 451
455 } // namespace 452 } // namespace
456 } // namespace forwarder2 453 } // namespace forwarder2
457 454
458 int main(int argc, char** argv) { 455 int main(int argc, char** argv) {
459 return forwarder2::RunHostForwarder(argc, argv); 456 return forwarder2::RunHostForwarder(argc, argv);
460 } 457 }
OLDNEW
« no previous file with comments | « tools/android/forwarder2/forwarders_manager.cc ('k') | tools/android/forwarder2/socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698