OLD | NEW |
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 <signal.h> | 5 #include <signal.h> |
6 #include <stdio.h> | 6 #include <stdio.h> |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 signal(SIGTERM, KillHandler); | 55 signal(SIGTERM, KillHandler); |
56 signal(SIGINT, KillHandler); | 56 signal(SIGINT, KillHandler); |
57 controller_thread_.reset(new base::Thread("controller_thread")); | 57 controller_thread_.reset(new base::Thread("controller_thread")); |
58 controller_thread_->Start(); | 58 controller_thread_->Start(); |
59 } | 59 } |
60 | 60 |
61 virtual void OnClientConnected(scoped_ptr<Socket> client_socket) OVERRIDE { | 61 virtual void OnClientConnected(scoped_ptr<Socket> client_socket) OVERRIDE { |
62 char buf[kBufSize]; | 62 char buf[kBufSize]; |
63 const int bytes_read = client_socket->Read(buf, sizeof(buf)); | 63 const int bytes_read = client_socket->Read(buf, sizeof(buf)); |
64 if (bytes_read <= 0) { | 64 if (bytes_read <= 0) { |
65 if (client_socket->exited()) | 65 if (client_socket->DidReceiveEvent()) |
66 return; | 66 return; |
67 PError("Read()"); | 67 PError("Read()"); |
68 return; | 68 return; |
69 } | 69 } |
70 const std::string adb_socket_path(buf, bytes_read); | 70 const std::string adb_socket_path(buf, bytes_read); |
71 if (adb_socket_path == adb_socket_path_) { | 71 if (adb_socket_path == adb_socket_path_) { |
72 client_socket->WriteString("OK"); | 72 client_socket->WriteString("OK"); |
73 return; | 73 return; |
74 } | 74 } |
75 if (!adb_socket_path_.empty()) { | 75 if (!adb_socket_path_.empty()) { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 return 1; | 171 return 1; |
172 return client_delegate.has_failed(); | 172 return client_delegate.has_failed(); |
173 } | 173 } |
174 | 174 |
175 } // namespace | 175 } // namespace |
176 } // namespace forwarder2 | 176 } // namespace forwarder2 |
177 | 177 |
178 int main(int argc, char** argv) { | 178 int main(int argc, char** argv) { |
179 return forwarder2::RunDeviceForwarder(argc, argv); | 179 return forwarder2::RunDeviceForwarder(argc, argv); |
180 } | 180 } |
OLD | NEW |