| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/threading/non_thread_safe.h" | 15 #include "base/sequence_checker.h" |
| 16 #include "net/log/net_log_with_source.h" | 16 #include "net/log/net_log_with_source.h" |
| 17 #include "remoting/protocol/p2p_stream_socket.h" | 17 #include "remoting/protocol/p2p_stream_socket.h" |
| 18 #include "third_party/webrtc/p2p/base/pseudotcp.h" | 18 #include "third_party/webrtc/p2p/base/pseudotcp.h" |
| 19 | 19 |
| 20 namespace remoting { | 20 namespace remoting { |
| 21 namespace protocol { | 21 namespace protocol { |
| 22 | 22 |
| 23 class P2PDatagramSocket; | 23 class P2PDatagramSocket; |
| 24 | 24 |
| 25 // PseudoTcpAdapter adapts a P2PDatagramSocket to P2PStreamSocket using | 25 // PseudoTcpAdapter adapts a P2PDatagramSocket to P2PStreamSocket using |
| 26 // PseudoTcp. Because P2PStreamSockets can be deleted during callbacks, | 26 // PseudoTcp. Because P2PStreamSockets can be deleted during callbacks, |
| 27 // while PseudoTcp cannot, the core of the PseudoTcpAdapter is reference | 27 // while PseudoTcp cannot, the core of the PseudoTcpAdapter is reference |
| 28 // counted, with a reference held by the adapter, and an additional reference | 28 // counted, with a reference held by the adapter, and an additional reference |
| 29 // held on the stack during callbacks. | 29 // held on the stack during callbacks. |
| 30 class PseudoTcpAdapter : public P2PStreamSocket, base::NonThreadSafe { | 30 class PseudoTcpAdapter : public P2PStreamSocket { |
| 31 public: | 31 public: |
| 32 explicit PseudoTcpAdapter(std::unique_ptr<P2PDatagramSocket> socket); | 32 explicit PseudoTcpAdapter(std::unique_ptr<P2PDatagramSocket> socket); |
| 33 ~PseudoTcpAdapter() override; | 33 ~PseudoTcpAdapter() override; |
| 34 | 34 |
| 35 // P2PStreamSocket implementation. | 35 // P2PStreamSocket implementation. |
| 36 int Read(const scoped_refptr<net::IOBuffer>& buffer, int buffer_size, | 36 int Read(const scoped_refptr<net::IOBuffer>& buffer, int buffer_size, |
| 37 const net::CompletionCallback& callback) override; | 37 const net::CompletionCallback& callback) override; |
| 38 int Write(const scoped_refptr<net::IOBuffer>& buffer, int buffer_size, | 38 int Write(const scoped_refptr<net::IOBuffer>& buffer, int buffer_size, |
| 39 const net::CompletionCallback& callback) override; | 39 const net::CompletionCallback& callback) override; |
| 40 | 40 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 68 // flow-control solution. | 68 // flow-control solution. |
| 69 void SetWriteWaitsForSend(bool write_waits_for_send); | 69 void SetWriteWaitsForSend(bool write_waits_for_send); |
| 70 | 70 |
| 71 private: | 71 private: |
| 72 class Core; | 72 class Core; |
| 73 | 73 |
| 74 scoped_refptr<Core> core_; | 74 scoped_refptr<Core> core_; |
| 75 | 75 |
| 76 net::NetLogWithSource net_log_; | 76 net::NetLogWithSource net_log_; |
| 77 | 77 |
| 78 SEQUENCE_CHECKER(sequence_checker_); |
| 79 |
| 78 DISALLOW_COPY_AND_ASSIGN(PseudoTcpAdapter); | 80 DISALLOW_COPY_AND_ASSIGN(PseudoTcpAdapter); |
| 79 }; | 81 }; |
| 80 | 82 |
| 81 } // namespace protocol | 83 } // namespace protocol |
| 82 } // namespace remoting | 84 } // namespace remoting |
| 83 | 85 |
| 84 #endif // REMOTING_PROTOCOL_PSEUDOTCP_ADAPTER_H_ | 86 #endif // REMOTING_PROTOCOL_PSEUDOTCP_ADAPTER_H_ |
| OLD | NEW |