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

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

Issue 10918057: Add forwarder2 (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 3 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 unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 #include <signal.h>
6 #include <stdio.h>
7 #include <stdlib.h>
8
9 #include <string>
10
11 #include "base/command_line.h"
12 #include "base/lazy_instance.h"
13 #include "base/stringprintf.h"
14 #include "tools/android/common/daemon.h"
15 #include "tools/android/forwarder2/device_controller.h"
16 #include "tools/android/forwarder2/pipe_notifier.h"
17
18 namespace {
19
20 // Accessed from the signal handler.
21 base::LazyInstance<forwarder::PipeNotifier>::Leaky g_notifier;
22
23 // Unix domain socket name for Device Controller.
24 const char kDefaultAdbSocket[] = "chrome_device_forwarder";
25
26 void KillHandler(int /* unused */) {
27 if (!g_notifier.Get().Notify())
28 exit(-1);
29 }
30
31 } // namespace
32
33 int main(int argc, char** argv) {
34 printf("Device forwarder to forward connections to the Host machine.\n");
35 printf("Like 'adb forward' but in the reverse direction\n");
36
37 CommandLine command_line(argc, argv);
38 string adb_socket_path = command_line.GetSwitchValueASCII("adb_sock");
39 if (adb_socket_path.empty()) {
40 adb_socket_path = kDefaultAdbSocket;
41 }
42 if (tools::HasHelpSwitch(command_line)) {
43 tools::ShowHelp(
44 argv[0],
45 "[--adb_sock=<adb sock>]",
46 base::StringPrintf(
47 " <adb sock> is the Abstract Unix Domain Socket path "
48 " where Adb is configured to forward from."
49 " Default is %s\n", kDefaultAdbSocket).c_str());
50 return 0;
51 }
52 if (!tools::HasNoSpawnDaemonSwitch(command_line)) {
53 tools::SpawnDaemon(0);
54 }
55
56 signal(SIGTERM, KillHandler);
57 signal(SIGINT, KillHandler);
58
59 forwarder::DeviceController controller(g_notifier.Get().receiver_fd());
60 // TODO(felipeg): We should check if the controller was correctly started
61 // before printing Ready.
62 printf("Device Forwarder Ready.\n");
63 controller.Start(adb_socket_path);
64
65 return 0;
66 }
OLDNEW
« no previous file with comments | « tools/android/forwarder2/device_controller.cc ('k') | tools/android/forwarder2/device_listener.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698