| 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> |
| 11 |
| 10 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 11 #include "base/macros.h" | 13 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | |
| 14 #include "base/threading/non_thread_safe.h" | 15 #include "base/threading/non_thread_safe.h" |
| 15 #include "net/log/net_log.h" | 16 #include "net/log/net_log.h" |
| 16 #include "remoting/protocol/p2p_stream_socket.h" | 17 #include "remoting/protocol/p2p_stream_socket.h" |
| 17 #include "third_party/webrtc/p2p/base/pseudotcp.h" | 18 #include "third_party/webrtc/p2p/base/pseudotcp.h" |
| 18 | 19 |
| 19 namespace remoting { | 20 namespace remoting { |
| 20 namespace protocol { | 21 namespace protocol { |
| 21 | 22 |
| 22 class P2PDatagramSocket; | 23 class P2PDatagramSocket; |
| 23 | 24 |
| 24 // PseudoTcpAdapter adapts a P2PDatagramSocket to P2PStreamSocket using | 25 // PseudoTcpAdapter adapts a P2PDatagramSocket to P2PStreamSocket using |
| 25 // PseudoTcp. Because P2PStreamSockets can be deleted during callbacks, | 26 // PseudoTcp. Because P2PStreamSockets can be deleted during callbacks, |
| 26 // while PseudoTcp cannot, the core of the PseudoTcpAdapter is reference | 27 // while PseudoTcp cannot, the core of the PseudoTcpAdapter is reference |
| 27 // 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 |
| 28 // held on the stack during callbacks. | 29 // held on the stack during callbacks. |
| 29 class PseudoTcpAdapter : public P2PStreamSocket, base::NonThreadSafe { | 30 class PseudoTcpAdapter : public P2PStreamSocket, base::NonThreadSafe { |
| 30 public: | 31 public: |
| 31 explicit PseudoTcpAdapter(scoped_ptr<P2PDatagramSocket> socket); | 32 explicit PseudoTcpAdapter(std::unique_ptr<P2PDatagramSocket> socket); |
| 32 ~PseudoTcpAdapter() override; | 33 ~PseudoTcpAdapter() override; |
| 33 | 34 |
| 34 // P2PStreamSocket implementation. | 35 // P2PStreamSocket implementation. |
| 35 int Read(const scoped_refptr<net::IOBuffer>& buffer, int buffer_size, | 36 int Read(const scoped_refptr<net::IOBuffer>& buffer, int buffer_size, |
| 36 const net::CompletionCallback& callback) override; | 37 const net::CompletionCallback& callback) override; |
| 37 int Write(const scoped_refptr<net::IOBuffer>& buffer, int buffer_size, | 38 int Write(const scoped_refptr<net::IOBuffer>& buffer, int buffer_size, |
| 38 const net::CompletionCallback& callback) override; | 39 const net::CompletionCallback& callback) override; |
| 39 | 40 |
| 40 int Connect(const net::CompletionCallback& callback); | 41 int Connect(const net::CompletionCallback& callback); |
| 41 | 42 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 75 |
| 75 net::BoundNetLog net_log_; | 76 net::BoundNetLog net_log_; |
| 76 | 77 |
| 77 DISALLOW_COPY_AND_ASSIGN(PseudoTcpAdapter); | 78 DISALLOW_COPY_AND_ASSIGN(PseudoTcpAdapter); |
| 78 }; | 79 }; |
| 79 | 80 |
| 80 } // namespace protocol | 81 } // namespace protocol |
| 81 } // namespace remoting | 82 } // namespace remoting |
| 82 | 83 |
| 83 #endif // REMOTING_PROTOCOL_PSEUDOTCP_ADAPTER_H_ | 84 #endif // REMOTING_PROTOCOL_PSEUDOTCP_ADAPTER_H_ |
| OLD | NEW |