Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / tools / android / forwarder2 / command.h
blob8e222ef7bb96502ad97d705bdc09a9eb6a5e38de
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 #ifndef TOOLS_ANDROID_FORWARDER2_COMMAND_H_
6 #define TOOLS_ANDROID_FORWARDER2_COMMAND_H_
8 #include "base/basictypes.h"
10 namespace forwarder2 {
12 class Socket;
14 namespace command {
16 enum Type {
17 ACCEPT_ERROR = 0,
18 ACCEPT_SUCCESS,
19 ACK,
20 ADB_DATA_SOCKET_ERROR,
21 ADB_DATA_SOCKET_SUCCESS,
22 BIND_ERROR,
23 BIND_SUCCESS,
24 DATA_CONNECTION,
25 HOST_SERVER_ERROR,
26 HOST_SERVER_SUCCESS,
27 KILL_ALL_LISTENERS,
28 LISTEN,
29 UNLISTEN,
30 UNLISTEN_ERROR,
31 UNLISTEN_SUCCESS,
34 } // namespace command
36 bool ReadCommand(Socket* socket,
37 int* port_out,
38 command::Type* command_type_out);
40 // Helper function to read the command from the |socket| and return true if the
41 // |command| is equal to the given command parameter.
42 bool ReceivedCommand(command::Type command, Socket* socket);
44 bool SendCommand(command::Type command, int port, Socket* socket);
46 } // namespace forwarder
48 #endif // TOOLS_ANDROID_FORWARDER2_COMMAND_H_