OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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_BROWSER_DEVTOOLS_DEVICE_USB_ANDROID_USB_SOCKET_H_ | 5 #ifndef CHROME_BROWSER_DEVTOOLS_DEVICE_USB_ANDROID_USB_SOCKET_H_ |
6 #define CHROME_BROWSER_DEVTOOLS_DEVICE_USB_ANDROID_USB_SOCKET_H_ | 6 #define CHROME_BROWSER_DEVTOOLS_DEVICE_USB_ANDROID_USB_SOCKET_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/threading/non_thread_safe.h" | 11 #include "base/threading/non_thread_safe.h" |
12 #include "chrome/browser/devtools/device/usb/android_usb_device.h" | 12 #include "chrome/browser/devtools/device/usb/android_usb_device.h" |
13 #include "net/base/ip_endpoint.h" | 13 #include "net/base/ip_endpoint.h" |
14 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
15 #include "net/socket/stream_socket.h" | 15 #include "net/socket/stream_socket.h" |
16 | 16 |
17 namespace base { | 17 namespace base { |
18 class MessageLoop; | 18 class MessageLoop; |
19 } | 19 } |
20 | 20 |
21 class AdbMessage; | 21 class AdbMessage; |
22 | 22 |
23 class AndroidUsbSocket : public net::StreamSocket, | 23 class AndroidUsbSocket : public net::StreamSocket, |
24 public base::NonThreadSafe { | 24 public base::NonThreadSafe { |
25 public: | 25 public: |
26 AndroidUsbSocket(scoped_refptr<AndroidUsbDevice> device, | 26 AndroidUsbSocket(scoped_refptr<AndroidUsbDevice> device, |
27 uint32 socket_id, | 27 uint32 socket_id, |
28 const std::string& command, | 28 const std::string& command, |
29 base::Callback<void(uint32)> delete_callback); | 29 base::Callback<void(uint32)> delete_callback); |
30 virtual ~AndroidUsbSocket(); | 30 ~AndroidUsbSocket() override; |
31 | 31 |
32 void HandleIncoming(scoped_refptr<AdbMessage> message); | 32 void HandleIncoming(scoped_refptr<AdbMessage> message); |
33 | 33 |
34 void Terminated(bool closed_by_device); | 34 void Terminated(bool closed_by_device); |
35 | 35 |
36 // net::StreamSocket implementation. | 36 // net::StreamSocket implementation. |
37 virtual int Read(net::IOBuffer* buf, int buf_len, | 37 int Read(net::IOBuffer* buf, |
38 const net::CompletionCallback& callback) override; | 38 int buf_len, |
39 virtual int Write(net::IOBuffer* buf, int buf_len, | 39 const net::CompletionCallback& callback) override; |
40 const net::CompletionCallback& callback) override; | 40 int Write(net::IOBuffer* buf, |
41 virtual int SetReceiveBufferSize(int32 size) override; | 41 int buf_len, |
42 virtual int SetSendBufferSize(int32 size) override; | 42 const net::CompletionCallback& callback) override; |
43 virtual int Connect(const net::CompletionCallback& callback) override; | 43 int SetReceiveBufferSize(int32 size) override; |
44 virtual void Disconnect() override; | 44 int SetSendBufferSize(int32 size) override; |
45 virtual bool IsConnected() const override; | 45 int Connect(const net::CompletionCallback& callback) override; |
46 virtual bool IsConnectedAndIdle() const override; | 46 void Disconnect() override; |
47 virtual int GetPeerAddress(net::IPEndPoint* address) const override; | 47 bool IsConnected() const override; |
48 virtual int GetLocalAddress(net::IPEndPoint* address) const override; | 48 bool IsConnectedAndIdle() const override; |
49 virtual const net::BoundNetLog& NetLog() const override; | 49 int GetPeerAddress(net::IPEndPoint* address) const override; |
50 virtual void SetSubresourceSpeculation() override; | 50 int GetLocalAddress(net::IPEndPoint* address) const override; |
51 virtual void SetOmniboxSpeculation() override; | 51 const net::BoundNetLog& NetLog() const override; |
52 virtual bool WasEverUsed() const override; | 52 void SetSubresourceSpeculation() override; |
53 virtual bool UsingTCPFastOpen() const override; | 53 void SetOmniboxSpeculation() override; |
54 virtual bool WasNpnNegotiated() const override; | 54 bool WasEverUsed() const override; |
55 virtual net::NextProto GetNegotiatedProtocol() const override; | 55 bool UsingTCPFastOpen() const override; |
56 virtual bool GetSSLInfo(net::SSLInfo* ssl_info) override; | 56 bool WasNpnNegotiated() const override; |
| 57 net::NextProto GetNegotiatedProtocol() const override; |
| 58 bool GetSSLInfo(net::SSLInfo* ssl_info) override; |
57 | 59 |
58 private: | 60 private: |
59 class IORequest { | 61 class IORequest { |
60 public: | 62 public: |
61 IORequest(net::IOBuffer* buffer, | 63 IORequest(net::IOBuffer* buffer, |
62 int length, | 64 int length, |
63 const net::CompletionCallback& callback); | 65 const net::CompletionCallback& callback); |
64 ~IORequest(); | 66 ~IORequest(); |
65 | 67 |
66 scoped_refptr<net::IOBuffer> buffer; | 68 scoped_refptr<net::IOBuffer> buffer; |
(...skipping 13 matching lines...) Expand all Loading... |
80 bool is_connected_; | 82 bool is_connected_; |
81 std::string read_buffer_; | 83 std::string read_buffer_; |
82 net::CompletionCallback connect_callback_; | 84 net::CompletionCallback connect_callback_; |
83 std::deque<IORequest> read_requests_; | 85 std::deque<IORequest> read_requests_; |
84 std::deque<IORequest> write_requests_; | 86 std::deque<IORequest> write_requests_; |
85 | 87 |
86 DISALLOW_COPY_AND_ASSIGN(AndroidUsbSocket); | 88 DISALLOW_COPY_AND_ASSIGN(AndroidUsbSocket); |
87 }; | 89 }; |
88 | 90 |
89 #endif // CHROME_BROWSER_DEVTOOLS_DEVICE_USB_ANDROID_USB_SOCKET_H_ | 91 #endif // CHROME_BROWSER_DEVTOOLS_DEVICE_USB_ANDROID_USB_SOCKET_H_ |
OLD | NEW |