Make castv2 performance test work.
[chromium-blink-merge.git] / chrome / browser / devtools / device / usb / android_usb_socket.h
blob85ef11284e23c24a0857dd4f6d97441f9b723714
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_USB_ANDROID_USB_SOCKET_H_
6 #define CHROME_BROWSER_DEVTOOLS_DEVICE_USB_ANDROID_USB_SOCKET_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/weak_ptr.h"
10 #include "base/threading/non_thread_safe.h"
11 #include "chrome/browser/devtools/device/usb/android_usb_device.h"
12 #include "net/base/ip_endpoint.h"
13 #include "net/socket/stream_socket.h"
15 namespace base {
16 class MessageLoop;
19 class AndroidUsbSocket : public net::StreamSocket,
20 public base::NonThreadSafe {
21 public:
22 AndroidUsbSocket(scoped_refptr<AndroidUsbDevice> device,
23 uint32 socket_id,
24 const std::string& command,
25 base::Closure delete_callback);
26 ~AndroidUsbSocket() override;
28 void HandleIncoming(scoped_ptr<AdbMessage> message);
30 void Terminated(bool closed_by_device);
32 // net::StreamSocket implementation.
33 int Read(net::IOBuffer* buf,
34 int buf_len,
35 const net::CompletionCallback& callback) override;
36 int Write(net::IOBuffer* buf,
37 int buf_len,
38 const net::CompletionCallback& callback) override;
39 int SetReceiveBufferSize(int32 size) override;
40 int SetSendBufferSize(int32 size) override;
41 int Connect(const net::CompletionCallback& callback) override;
42 void Disconnect() override;
43 bool IsConnected() const override;
44 bool IsConnectedAndIdle() const override;
45 int GetPeerAddress(net::IPEndPoint* address) const override;
46 int GetLocalAddress(net::IPEndPoint* address) const override;
47 const net::BoundNetLog& NetLog() const override;
48 void SetSubresourceSpeculation() override;
49 void SetOmniboxSpeculation() override;
50 bool WasEverUsed() const override;
51 bool UsingTCPFastOpen() const override;
52 bool WasNpnNegotiated() const override;
53 net::NextProto GetNegotiatedProtocol() const override;
54 bool GetSSLInfo(net::SSLInfo* ssl_info) override;
56 private:
57 void RespondToReader(bool disconnect);
58 void RespondToWriter(int result);
60 scoped_refptr<AndroidUsbDevice> device_;
61 std::string command_;
62 uint32 local_id_;
63 uint32 remote_id_;
64 net::BoundNetLog net_log_;
65 bool is_connected_;
66 std::string read_buffer_;
67 scoped_refptr<net::IOBuffer> read_io_buffer_;
68 int read_length_;
69 int write_length_;
70 net::CompletionCallback connect_callback_;
71 net::CompletionCallback read_callback_;
72 net::CompletionCallback write_callback_;
73 base::Closure delete_callback_;
74 base::WeakPtrFactory<AndroidUsbSocket> weak_factory_;
76 DISALLOW_COPY_AND_ASSIGN(AndroidUsbSocket);
79 #endif // CHROME_BROWSER_DEVTOOLS_DEVICE_USB_ANDROID_USB_SOCKET_H_