OLD | NEW |
1 // Copyright (c) 2012 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 JINGLE_GLUE_PSEUDOTCP_ADAPTER_H_ | 5 #ifndef REMOTING_PROTOCOL_PSEUDOTCP_ADAPTER_H_ |
6 #define JINGLE_GLUE_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 "net/socket/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 jingle_glue { | 17 namespace remoting { |
| 18 namespace protocol { |
18 | 19 |
19 // PseudoTcpAdapter adapts a connectionless net::Socket to a connection- | 20 // PseudoTcpAdapter adapts a connectionless net::Socket to a connection- |
20 // oriented net::StreamSocket using PseudoTcp. Because net::StreamSockets | 21 // oriented net::StreamSocket using PseudoTcp. Because net::StreamSockets |
21 // can be deleted during callbacks, while PseudoTcp cannot, the core of the | 22 // can be deleted during callbacks, while PseudoTcp cannot, the core of the |
22 // PseudoTcpAdapter is reference counted, with a reference held by the | 23 // PseudoTcpAdapter is reference counted, with a reference held by the |
23 // adapter, and an additional reference held on the stack during callbacks. | 24 // adapter, and an additional reference held on the stack during callbacks. |
24 class PseudoTcpAdapter : public net::StreamSocket, base::NonThreadSafe { | 25 class PseudoTcpAdapter : public net::StreamSocket, base::NonThreadSafe { |
25 public: | 26 public: |
26 // Creates an adapter for the supplied Socket. |socket| should already | 27 explicit PseudoTcpAdapter(scoped_ptr<net::Socket> socket); |
27 // be ready for use, and ownership of it will be assumed by the adapter. | |
28 explicit PseudoTcpAdapter(net::Socket* socket); | |
29 ~PseudoTcpAdapter() override; | 28 ~PseudoTcpAdapter() override; |
30 | 29 |
31 // net::Socket implementation. | 30 // net::Socket implementation. |
32 int Read(net::IOBuffer* buffer, | 31 int Read(net::IOBuffer* buffer, |
33 int buffer_size, | 32 int buffer_size, |
34 const net::CompletionCallback& callback) override; | 33 const net::CompletionCallback& callback) override; |
35 int Write(net::IOBuffer* buffer, | 34 int Write(net::IOBuffer* buffer, |
36 int buffer_size, | 35 int buffer_size, |
37 const net::CompletionCallback& callback) override; | 36 const net::CompletionCallback& callback) override; |
38 int SetReceiveBufferSize(int32 size) override; | 37 int SetReceiveBufferSize(int32 size) override; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 private: | 84 private: |
86 class Core; | 85 class Core; |
87 | 86 |
88 scoped_refptr<Core> core_; | 87 scoped_refptr<Core> core_; |
89 | 88 |
90 net::BoundNetLog net_log_; | 89 net::BoundNetLog net_log_; |
91 | 90 |
92 DISALLOW_COPY_AND_ASSIGN(PseudoTcpAdapter); | 91 DISALLOW_COPY_AND_ASSIGN(PseudoTcpAdapter); |
93 }; | 92 }; |
94 | 93 |
95 } // namespace jingle_glue | 94 } // namespace protocol |
| 95 } // namespace remoting |
96 | 96 |
97 #endif // JINGLE_GLUE_PSEUDOTCP_ADAPTER_H_ | 97 #endif // REMOTING_PROTOCOL_PSEUDOTCP_ADAPTER_H_ |
OLD | NEW |