OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_DEVTOOLS_ADB_CLIENT_SOCKET_H_ |
| 6 #define CHROME_BROWSER_DEVTOOLS_ADB_CLIENT_SOCKET_H_ |
| 7 |
| 8 #include "base/callback.h" |
| 9 #include "net/base/io_buffer.h" |
| 10 #include "net/socket/tcp_client_socket.h" |
| 11 |
| 12 class ADBClientSocket { |
| 13 public: |
| 14 typedef base::Callback<void(const std::string& error, |
| 15 const std::string& data)> Callback; |
| 16 |
| 17 static void Query(int port, |
| 18 const std::string& query, |
| 19 const Callback& callback); |
| 20 |
| 21 private: |
| 22 ADBClientSocket(); |
| 23 ~ADBClientSocket(); |
| 24 |
| 25 void InnerQuery(int port, const std::string& query, const Callback& callback); |
| 26 void OnConnectComplete(scoped_refptr<net::StringIOBuffer> request_buffer, |
| 27 int result); |
| 28 void OnWriteComplete(int result); |
| 29 void OnReadComplete(scoped_refptr<net::IOBuffer> response_buffer, |
| 30 int result); |
| 31 bool CheckNetResultOrDie(int result); |
| 32 void ReportSuccessAndDie(); |
| 33 void ReportInvalidResponseAndDie(); |
| 34 void ReportErrorAndDie(const std::string& error); |
| 35 void Destroy(); |
| 36 |
| 37 Callback callback_; |
| 38 scoped_ptr<net::TCPClientSocket> socket_; |
| 39 std::string response_; |
| 40 int expected_response_length_; |
| 41 |
| 42 DISALLOW_COPY_AND_ASSIGN(ADBClientSocket); |
| 43 }; |
| 44 |
| 45 #endif // CHROME_BROWSER_DEVTOOLS_ADB_CLIENT_SOCKET_H_ |
OLD | NEW |