OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #ifndef CHROME_TEST_CHROMEDRIVER_NET_ADB_CLIENT_SOCKET_H_ | 5 #ifndef CHROME_TEST_CHROMEDRIVER_NET_ADB_CLIENT_SOCKET_H_ |
6 #define CHROME_TEST_CHROMEDRIVER_NET_ADB_CLIENT_SOCKET_H_ | 6 #define CHROME_TEST_CHROMEDRIVER_NET_ADB_CLIENT_SOCKET_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 const std::string& socket_name, | 30 const std::string& socket_name, |
31 const std::string& request, | 31 const std::string& request, |
32 const CommandCallback& callback); | 32 const CommandCallback& callback); |
33 | 33 |
34 static void HttpQuery(int port, | 34 static void HttpQuery(int port, |
35 const std::string& serial, | 35 const std::string& serial, |
36 const std::string& socket_name, | 36 const std::string& socket_name, |
37 const std::string& request, | 37 const std::string& request, |
38 const SocketCallback& callback); | 38 const SocketCallback& callback); |
39 | 39 |
| 40 static void SendFile(int port, |
| 41 const std::string& serial, |
| 42 const std::string& filename, |
| 43 const std::string& content, |
| 44 const CommandCallback& callback); |
| 45 |
40 explicit AdbClientSocket(int port); | 46 explicit AdbClientSocket(int port); |
41 ~AdbClientSocket(); | 47 ~AdbClientSocket(); |
42 | 48 |
43 protected: | 49 protected: |
44 void Connect(const net::CompletionCallback& callback); | 50 void Connect(const net::CompletionCallback& callback); |
45 | 51 |
46 void SendCommand(const std::string& command, | 52 void SendCommand(const std::string& command, |
47 bool is_void, | 53 bool is_void, |
48 bool has_length, | 54 bool has_length, |
49 const CommandCallback& callback); | 55 const CommandCallback& callback); |
50 | 56 |
51 std::unique_ptr<net::StreamSocket> socket_; | 57 std::unique_ptr<net::StreamSocket> socket_; |
52 | 58 |
53 private: | |
54 void ReadResponse(const CommandCallback& callback, | 59 void ReadResponse(const CommandCallback& callback, |
55 bool is_void, | 60 bool is_void, |
56 bool has_length, | 61 bool has_length, |
57 int result); | 62 int result); |
58 | 63 |
| 64 private: |
59 void OnResponseStatus(const CommandCallback& callback, | 65 void OnResponseStatus(const CommandCallback& callback, |
60 bool is_void, | 66 bool is_void, |
61 bool has_length, | 67 bool has_length, |
62 scoped_refptr<net::IOBuffer> response_buffer, | 68 scoped_refptr<net::IOBuffer> response_buffer, |
63 int result); | 69 int result); |
64 | 70 |
65 void OnResponseLength(const CommandCallback& callback, | 71 void OnResponseLength(const CommandCallback& callback, |
66 const std::string& response, | 72 const std::string& response, |
67 scoped_refptr<net::IOBuffer> response_buffer, | 73 scoped_refptr<net::IOBuffer> response_buffer, |
68 int result); | 74 int result); |
69 | 75 |
70 void OnResponseData(const CommandCallback& callback, | 76 void OnResponseData(const CommandCallback& callback, |
71 const std::string& response, | 77 const std::string& response, |
72 scoped_refptr<net::IOBuffer> response_buffer, | 78 scoped_refptr<net::IOBuffer> response_buffer, |
73 int bytes_left, | 79 int bytes_left, |
74 int result); | 80 int result); |
75 | 81 |
76 int port_; | 82 int port_; |
77 | 83 |
78 DISALLOW_COPY_AND_ASSIGN(AdbClientSocket); | 84 DISALLOW_COPY_AND_ASSIGN(AdbClientSocket); |
79 }; | 85 }; |
80 | 86 |
81 #endif // CHROME_TEST_CHROMEDRIVER_NET_ADB_CLIENT_SOCKET_H_ | 87 #endif // CHROME_TEST_CHROMEDRIVER_NET_ADB_CLIENT_SOCKET_H_ |
OLD | NEW |