Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / devtools / device / adb / adb_client_socket.h
blobf331b02965e51af2a23965c3a322306029a131c8
1 // Copyright 2014 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 CHROME_BROWSER_DEVTOOLS_DEVICE_ADB_ADB_CLIENT_SOCKET_H_
6 #define CHROME_BROWSER_DEVTOOLS_DEVICE_ADB_ADB_CLIENT_SOCKET_H_
8 #include "base/callback.h"
9 #include "net/base/io_buffer.h"
10 #include "net/socket/stream_socket.h"
12 class AdbClientSocket {
13 public:
14 typedef base::Callback<void(int, const std::string&)> CommandCallback;
15 typedef base::Callback<void(int result,
16 scoped_ptr<net::StreamSocket>)> SocketCallback;
18 static void AdbQuery(int port,
19 const std::string& query,
20 const CommandCallback& callback);
23 static void TransportQuery(int port,
24 const std::string& serial,
25 const std::string& socket_name,
26 const SocketCallback& callback);
28 protected:
29 explicit AdbClientSocket(int port);
30 ~AdbClientSocket();
32 void Connect(const net::CompletionCallback& callback);
34 void SendCommand(const std::string& command,
35 bool is_void,
36 const CommandCallback& callback);
38 scoped_ptr<net::StreamSocket> socket_;
40 private:
41 void ReadResponse(const CommandCallback& callback, bool is_void, int result);
43 void OnResponseHeader(const CommandCallback& callback,
44 bool is_void,
45 scoped_refptr<net::IOBuffer> response_buffer,
46 int result);
48 void OnResponseData(const CommandCallback& callback,
49 const std::string& response,
50 scoped_refptr<net::IOBuffer> response_buffer,
51 int bytes_left,
52 int result);
54 std::string host_;
55 int port_;
57 DISALLOW_COPY_AND_ASSIGN(AdbClientSocket);
60 #endif // CHROME_BROWSER_DEVTOOLS_DEVICE_ADB_ADB_CLIENT_SOCKET_H_