OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 REMOTING_PROTOCOL_PSEUDOTCP_ADAPTER_H_ | 5 #ifndef REMOTING_PROTOCOL_PSEUDOTCP_ADAPTER_H_ |
6 #define REMOTING_PROTOCOL_PSEUDOTCP_ADAPTER_H_ | 6 #define REMOTING_PROTOCOL_PSEUDOTCP_ADAPTER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/threading/non_thread_safe.h" | 12 #include "base/threading/non_thread_safe.h" |
13 #include "net/log/net_log.h" | 13 #include "net/log/net_log.h" |
14 #include "net/socket/stream_socket.h" | 14 #include "remoting/protocol/p2p_socket.h" |
15 #include "third_party/webrtc/p2p/base/pseudotcp.h" | 15 #include "third_party/webrtc/p2p/base/pseudotcp.h" |
16 | 16 |
17 namespace remoting { | 17 namespace remoting { |
18 namespace protocol { | 18 namespace protocol { |
19 | 19 |
20 // PseudoTcpAdapter adapts a connectionless net::Socket to a connection- | 20 // PseudoTcpAdapter adapts a P2PDatagramSocket to P2PStreamSocket using |
21 // oriented net::StreamSocket using PseudoTcp. Because net::StreamSockets | 21 // PseudoTcp. Because net::StreamSockets can be deleted during callbacks, |
Wez
2015/06/22 15:49:07
nit: Because P2PStreamSockets...
Sergey Ulanov
2015/07/10 00:49:54
Done.
| |
22 // can be deleted during callbacks, while PseudoTcp cannot, the core of the | 22 // while PseudoTcp cannot, the core of the PseudoTcpAdapter is reference |
23 // PseudoTcpAdapter is reference counted, with a reference held by the | 23 // counted, with a reference held by the adapter, and an additional reference |
24 // adapter, and an additional reference held on the stack during callbacks. | 24 // held on the stack during callbacks. |
25 class PseudoTcpAdapter : public net::StreamSocket, base::NonThreadSafe { | 25 class PseudoTcpAdapter : public P2PStreamSocket, base::NonThreadSafe { |
26 public: | 26 public: |
27 explicit PseudoTcpAdapter(scoped_ptr<net::Socket> socket); | 27 explicit PseudoTcpAdapter(scoped_ptr<P2PDatagramSocket> socket); |
28 ~PseudoTcpAdapter() override; | 28 ~PseudoTcpAdapter() override; |
29 | 29 |
30 // net::Socket implementation. | 30 // P2PStreamSocket implementation. |
31 int Read(net::IOBuffer* buffer, | 31 int Read(net::IOBuffer* buffer, |
32 int buffer_size, | 32 int buffer_size, |
33 const net::CompletionCallback& callback) override; | 33 const net::CompletionCallback& callback) override; |
34 int Write(net::IOBuffer* buffer, | 34 int Write(net::IOBuffer* buffer, |
35 int buffer_size, | 35 int buffer_size, |
36 const net::CompletionCallback& callback) override; | 36 const net::CompletionCallback& callback) override; |
37 int SetReceiveBufferSize(int32 size) override; | 37 int SetReceiveBufferSize(int32 size) override; |
38 int SetSendBufferSize(int32 size) override; | 38 int SetSendBufferSize(int32 size) override; |
39 | 39 |
40 // net::StreamSocket implementation. | 40 int Connect(const net::CompletionCallback& callback); |
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; | |
55 void GetConnectionAttempts(net::ConnectionAttempts* out) const override; | |
56 void ClearConnectionAttempts() override {} | |
57 void AddConnectionAttempts(const net::ConnectionAttempts& attempts) override { | |
58 } | |
59 | 41 |
60 // Set the delay for sending ACK. | 42 // Set the delay for sending ACK. |
61 void SetAckDelay(int delay_ms); | 43 void SetAckDelay(int delay_ms); |
62 | 44 |
63 // Set whether Nagle's algorithm is enabled. | 45 // Set whether Nagle's algorithm is enabled. |
64 void SetNoDelay(bool no_delay); | 46 void SetNoDelay(bool no_delay); |
65 | 47 |
66 // When write_waits_for_send flag is set to true the Write() method | 48 // When write_waits_for_send flag is set to true the Write() method |
67 // will wait until the data is sent to the remote end before the | 49 // will wait until the data is sent to the remote end before the |
68 // write completes (it still doesn't wait until the data is received | 50 // write completes (it still doesn't wait until the data is received |
(...skipping 19 matching lines...) Expand all Loading... | |
88 | 70 |
89 net::BoundNetLog net_log_; | 71 net::BoundNetLog net_log_; |
90 | 72 |
91 DISALLOW_COPY_AND_ASSIGN(PseudoTcpAdapter); | 73 DISALLOW_COPY_AND_ASSIGN(PseudoTcpAdapter); |
92 }; | 74 }; |
93 | 75 |
94 } // namespace protocol | 76 } // namespace protocol |
95 } // namespace remoting | 77 } // namespace remoting |
96 | 78 |
97 #endif // REMOTING_PROTOCOL_PSEUDOTCP_ADAPTER_H_ | 79 #endif // REMOTING_PROTOCOL_PSEUDOTCP_ADAPTER_H_ |
OLD | NEW |