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 <stdint.h> |
| 9 |
| 10 #include "base/macros.h" |
8 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
9 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
10 #include "base/threading/non_thread_safe.h" | 13 #include "base/threading/non_thread_safe.h" |
11 #include "chrome/browser/devtools/device/usb/android_usb_device.h" | 14 #include "chrome/browser/devtools/device/usb/android_usb_device.h" |
12 #include "net/base/ip_endpoint.h" | 15 #include "net/base/ip_endpoint.h" |
13 #include "net/socket/stream_socket.h" | 16 #include "net/socket/stream_socket.h" |
14 | 17 |
15 namespace base { | 18 namespace base { |
16 class MessageLoop; | 19 class MessageLoop; |
17 } | 20 } |
18 | 21 |
19 class AndroidUsbSocket : public net::StreamSocket, | 22 class AndroidUsbSocket : public net::StreamSocket, |
20 public base::NonThreadSafe { | 23 public base::NonThreadSafe { |
21 public: | 24 public: |
22 AndroidUsbSocket(scoped_refptr<AndroidUsbDevice> device, | 25 AndroidUsbSocket(scoped_refptr<AndroidUsbDevice> device, |
23 uint32 socket_id, | 26 uint32_t socket_id, |
24 const std::string& command, | 27 const std::string& command, |
25 base::Closure delete_callback); | 28 base::Closure delete_callback); |
26 ~AndroidUsbSocket() override; | 29 ~AndroidUsbSocket() override; |
27 | 30 |
28 void HandleIncoming(scoped_ptr<AdbMessage> message); | 31 void HandleIncoming(scoped_ptr<AdbMessage> message); |
29 | 32 |
30 void Terminated(bool closed_by_device); | 33 void Terminated(bool closed_by_device); |
31 | 34 |
32 // net::StreamSocket implementation. | 35 // net::StreamSocket implementation. |
33 int Read(net::IOBuffer* buf, | 36 int Read(net::IOBuffer* buf, |
34 int buf_len, | 37 int buf_len, |
35 const net::CompletionCallback& callback) override; | 38 const net::CompletionCallback& callback) override; |
36 int Write(net::IOBuffer* buf, | 39 int Write(net::IOBuffer* buf, |
37 int buf_len, | 40 int buf_len, |
38 const net::CompletionCallback& callback) override; | 41 const net::CompletionCallback& callback) override; |
39 int SetReceiveBufferSize(int32 size) override; | 42 int SetReceiveBufferSize(int32_t size) override; |
40 int SetSendBufferSize(int32 size) override; | 43 int SetSendBufferSize(int32_t size) override; |
41 int Connect(const net::CompletionCallback& callback) override; | 44 int Connect(const net::CompletionCallback& callback) override; |
42 void Disconnect() override; | 45 void Disconnect() override; |
43 bool IsConnected() const override; | 46 bool IsConnected() const override; |
44 bool IsConnectedAndIdle() const override; | 47 bool IsConnectedAndIdle() const override; |
45 int GetPeerAddress(net::IPEndPoint* address) const override; | 48 int GetPeerAddress(net::IPEndPoint* address) const override; |
46 int GetLocalAddress(net::IPEndPoint* address) const override; | 49 int GetLocalAddress(net::IPEndPoint* address) const override; |
47 const net::BoundNetLog& NetLog() const override; | 50 const net::BoundNetLog& NetLog() const override; |
48 void SetSubresourceSpeculation() override; | 51 void SetSubresourceSpeculation() override; |
49 void SetOmniboxSpeculation() override; | 52 void SetOmniboxSpeculation() override; |
50 bool WasEverUsed() const override; | 53 bool WasEverUsed() const override; |
51 bool UsingTCPFastOpen() const override; | 54 bool UsingTCPFastOpen() const override; |
52 bool WasNpnNegotiated() const override; | 55 bool WasNpnNegotiated() const override; |
53 net::NextProto GetNegotiatedProtocol() const override; | 56 net::NextProto GetNegotiatedProtocol() const override; |
54 bool GetSSLInfo(net::SSLInfo* ssl_info) override; | 57 bool GetSSLInfo(net::SSLInfo* ssl_info) override; |
55 void GetConnectionAttempts(net::ConnectionAttempts* out) const override; | 58 void GetConnectionAttempts(net::ConnectionAttempts* out) const override; |
56 void ClearConnectionAttempts() override {} | 59 void ClearConnectionAttempts() override {} |
57 void AddConnectionAttempts(const net::ConnectionAttempts& attempts) override { | 60 void AddConnectionAttempts(const net::ConnectionAttempts& attempts) override { |
58 } | 61 } |
59 int64_t GetTotalReceivedBytes() const override; | 62 int64_t GetTotalReceivedBytes() const override; |
60 | 63 |
61 private: | 64 private: |
62 void RespondToReader(bool disconnect); | 65 void RespondToReader(bool disconnect); |
63 void RespondToWriter(int result); | 66 void RespondToWriter(int result); |
64 | 67 |
65 scoped_refptr<AndroidUsbDevice> device_; | 68 scoped_refptr<AndroidUsbDevice> device_; |
66 std::string command_; | 69 std::string command_; |
67 uint32 local_id_; | 70 uint32_t local_id_; |
68 uint32 remote_id_; | 71 uint32_t remote_id_; |
69 net::BoundNetLog net_log_; | 72 net::BoundNetLog net_log_; |
70 bool is_connected_; | 73 bool is_connected_; |
71 std::string read_buffer_; | 74 std::string read_buffer_; |
72 scoped_refptr<net::IOBuffer> read_io_buffer_; | 75 scoped_refptr<net::IOBuffer> read_io_buffer_; |
73 int read_length_; | 76 int read_length_; |
74 int write_length_; | 77 int write_length_; |
75 net::CompletionCallback connect_callback_; | 78 net::CompletionCallback connect_callback_; |
76 net::CompletionCallback read_callback_; | 79 net::CompletionCallback read_callback_; |
77 net::CompletionCallback write_callback_; | 80 net::CompletionCallback write_callback_; |
78 base::Closure delete_callback_; | 81 base::Closure delete_callback_; |
79 base::WeakPtrFactory<AndroidUsbSocket> weak_factory_; | 82 base::WeakPtrFactory<AndroidUsbSocket> weak_factory_; |
80 | 83 |
81 DISALLOW_COPY_AND_ASSIGN(AndroidUsbSocket); | 84 DISALLOW_COPY_AND_ASSIGN(AndroidUsbSocket); |
82 }; | 85 }; |
83 | 86 |
84 #endif // CHROME_BROWSER_DEVTOOLS_DEVICE_USB_ANDROID_USB_SOCKET_H_ | 87 #endif // CHROME_BROWSER_DEVTOOLS_DEVICE_USB_ANDROID_USB_SOCKET_H_ |
OLD | NEW |