1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_DEVTOOLS_ADB_CLIENT_SOCKET_H_
#define CHROME_BROWSER_DEVTOOLS_ADB_CLIENT_SOCKET_H_
#include "base/callback.h"
#include "net/base/io_buffer.h"
#include "net/socket/stream_socket.h"
class AdbClientSocket {
public:
typedef base::Callback<void(int, const std::string&)> CommandCallback;
typedef base::Callback<void(int result,
net::StreamSocket*)> SocketCallback;
static void AdbQuery(int port,
const std::string& query,
const CommandCallback& callback);
static void TransportQuery(int port,
const std::string& serial,
const std::string& socket_name,
const SocketCallback& callback);
static void HttpQuery(int port,
const std::string& serial,
const std::string& socket_name,
const std::string& request,
const CommandCallback& callback);
static void HttpQuery(int port,
const std::string& serial,
const std::string& socket_name,
const std::string& request,
const SocketCallback& callback);
AdbClientSocket(int port);
~AdbClientSocket();
protected:
void Connect(const net::CompletionCallback& callback);
void SendCommand(const std::string& command,
bool is_void,
const CommandCallback& callback);
scoped_ptr<net::StreamSocket> socket_;
private:
void ReadResponse(const CommandCallback& callback, bool is_void, int result);
void OnResponseHeader(const CommandCallback& callback,
bool is_void,
scoped_refptr<net::IOBuffer> response_buffer,
int result);
void OnResponseData(const CommandCallback& callback,
const std::string& response,
scoped_refptr<net::IOBuffer> response_buffer,
int bytes_left,
int result);
std::string host_;
int port_;
DISALLOW_COPY_AND_ASSIGN(AdbClientSocket);
};
#endif // CHROME_BROWSER_DEVTOOLS_ADB_CLIENT_SOCKET_H_
|