Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(406)

Side by Side Diff: remoting/protocol/pseudotcp_adapter.h

Issue 1197853003: Add P2PDatagramSocket and P2PStreamSocket interfaces. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/protocol/p2p_stream_socket.h ('k') | remoting/protocol/pseudotcp_adapter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_stream_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 class P2PDatagramSocket;
21 // oriented net::StreamSocket using PseudoTcp. Because net::StreamSockets 21
22 // can be deleted during callbacks, while PseudoTcp cannot, the core of the 22 // PseudoTcpAdapter adapts a P2PDatagramSocket to P2PStreamSocket using
23 // PseudoTcpAdapter is reference counted, with a reference held by the 23 // PseudoTcp. Because P2PStreamSockets can be deleted during callbacks,
24 // adapter, and an additional reference held on the stack during callbacks. 24 // while PseudoTcp cannot, the core of the PseudoTcpAdapter is reference
25 class PseudoTcpAdapter : public net::StreamSocket, base::NonThreadSafe { 25 // counted, with a reference held by the adapter, and an additional reference
26 // held on the stack during callbacks.
27 class PseudoTcpAdapter : public P2PStreamSocket, base::NonThreadSafe {
26 public: 28 public:
27 explicit PseudoTcpAdapter(scoped_ptr<net::Socket> socket); 29 explicit PseudoTcpAdapter(scoped_ptr<P2PDatagramSocket> socket);
28 ~PseudoTcpAdapter() override; 30 ~PseudoTcpAdapter() override;
29 31
30 // net::Socket implementation. 32 // P2PStreamSocket implementation.
31 int Read(net::IOBuffer* buffer, 33 int Read(const scoped_refptr<net::IOBuffer>& buffer, int buffer_size,
32 int buffer_size,
33 const net::CompletionCallback& callback) override; 34 const net::CompletionCallback& callback) override;
34 int Write(net::IOBuffer* buffer, 35 int Write(const scoped_refptr<net::IOBuffer>& buffer, 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;
38 int SetSendBufferSize(int32 size) override;
39 37
40 // net::StreamSocket implementation. 38 int Connect(const net::CompletionCallback& callback);
41 int Connect(const net::CompletionCallback& callback) override; 39
42 void Disconnect() override; 40 // Set receive and send buffer sizes.
43 bool IsConnected() const override; 41 int SetReceiveBufferSize(int32 size);
44 bool IsConnectedAndIdle() const override; 42 int SetSendBufferSize(int32 size);
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 43
60 // Set the delay for sending ACK. 44 // Set the delay for sending ACK.
61 void SetAckDelay(int delay_ms); 45 void SetAckDelay(int delay_ms);
62 46
63 // Set whether Nagle's algorithm is enabled. 47 // Set whether Nagle's algorithm is enabled.
64 void SetNoDelay(bool no_delay); 48 void SetNoDelay(bool no_delay);
65 49
66 // When write_waits_for_send flag is set to true the Write() method 50 // 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 51 // 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 52 // write completes (it still doesn't wait until the data is received
(...skipping 19 matching lines...) Expand all
88 72
89 net::BoundNetLog net_log_; 73 net::BoundNetLog net_log_;
90 74
91 DISALLOW_COPY_AND_ASSIGN(PseudoTcpAdapter); 75 DISALLOW_COPY_AND_ASSIGN(PseudoTcpAdapter);
92 }; 76 };
93 77
94 } // namespace protocol 78 } // namespace protocol
95 } // namespace remoting 79 } // namespace remoting
96 80
97 #endif // REMOTING_PROTOCOL_PSEUDOTCP_ADAPTER_H_ 81 #endif // REMOTING_PROTOCOL_PSEUDOTCP_ADAPTER_H_
OLDNEW
« no previous file with comments | « remoting/protocol/p2p_stream_socket.h ('k') | remoting/protocol/pseudotcp_adapter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698