| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #ifndef WEBRTC_BASE_ASYNCTCPSOCKET_H_ | 11 #ifndef WEBRTC_BASE_ASYNCTCPSOCKET_H_ |
| 12 #define WEBRTC_BASE_ASYNCTCPSOCKET_H_ | 12 #define WEBRTC_BASE_ASYNCTCPSOCKET_H_ |
| 13 | 13 |
| 14 #include <memory> |
| 15 |
| 14 #include "webrtc/base/asyncpacketsocket.h" | 16 #include "webrtc/base/asyncpacketsocket.h" |
| 15 #include "webrtc/base/buffer.h" | 17 #include "webrtc/base/buffer.h" |
| 16 #include "webrtc/base/scoped_ptr.h" | |
| 17 #include "webrtc/base/socketfactory.h" | 18 #include "webrtc/base/socketfactory.h" |
| 18 | 19 |
| 19 namespace rtc { | 20 namespace rtc { |
| 20 | 21 |
| 21 // Simulates UDP semantics over TCP. Send and Recv packet sizes | 22 // Simulates UDP semantics over TCP. Send and Recv packet sizes |
| 22 // are preserved, and drops packets silently on Send, rather than | 23 // are preserved, and drops packets silently on Send, rather than |
| 23 // buffer them in user space. | 24 // buffer them in user space. |
| 24 class AsyncTCPSocketBase : public AsyncPacketSocket { | 25 class AsyncTCPSocketBase : public AsyncPacketSocket { |
| 25 public: | 26 public: |
| 26 AsyncTCPSocketBase(AsyncSocket* socket, bool listen, size_t max_packet_size); | 27 AsyncTCPSocketBase(AsyncSocket* socket, bool listen, size_t max_packet_size); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 bool IsOutBufferEmpty() const { return outbuf_.size() == 0; } | 64 bool IsOutBufferEmpty() const { return outbuf_.size() == 0; } |
| 64 void ClearOutBuffer() { outbuf_.Clear(); } | 65 void ClearOutBuffer() { outbuf_.Clear(); } |
| 65 | 66 |
| 66 private: | 67 private: |
| 67 // Called by the underlying socket | 68 // Called by the underlying socket |
| 68 void OnConnectEvent(AsyncSocket* socket); | 69 void OnConnectEvent(AsyncSocket* socket); |
| 69 void OnReadEvent(AsyncSocket* socket); | 70 void OnReadEvent(AsyncSocket* socket); |
| 70 void OnWriteEvent(AsyncSocket* socket); | 71 void OnWriteEvent(AsyncSocket* socket); |
| 71 void OnCloseEvent(AsyncSocket* socket, int error); | 72 void OnCloseEvent(AsyncSocket* socket, int error); |
| 72 | 73 |
| 73 scoped_ptr<AsyncSocket> socket_; | 74 std::unique_ptr<AsyncSocket> socket_; |
| 74 bool listen_; | 75 bool listen_; |
| 75 Buffer inbuf_; | 76 Buffer inbuf_; |
| 76 Buffer outbuf_; | 77 Buffer outbuf_; |
| 77 size_t max_insize_; | 78 size_t max_insize_; |
| 78 size_t max_outsize_; | 79 size_t max_outsize_; |
| 79 | 80 |
| 80 RTC_DISALLOW_COPY_AND_ASSIGN(AsyncTCPSocketBase); | 81 RTC_DISALLOW_COPY_AND_ASSIGN(AsyncTCPSocketBase); |
| 81 }; | 82 }; |
| 82 | 83 |
| 83 class AsyncTCPSocket : public AsyncTCPSocketBase { | 84 class AsyncTCPSocket : public AsyncTCPSocketBase { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 97 void ProcessInput(char* data, size_t* len) override; | 98 void ProcessInput(char* data, size_t* len) override; |
| 98 void HandleIncomingConnection(AsyncSocket* socket) override; | 99 void HandleIncomingConnection(AsyncSocket* socket) override; |
| 99 | 100 |
| 100 private: | 101 private: |
| 101 RTC_DISALLOW_COPY_AND_ASSIGN(AsyncTCPSocket); | 102 RTC_DISALLOW_COPY_AND_ASSIGN(AsyncTCPSocket); |
| 102 }; | 103 }; |
| 103 | 104 |
| 104 } // namespace rtc | 105 } // namespace rtc |
| 105 | 106 |
| 106 #endif // WEBRTC_BASE_ASYNCTCPSOCKET_H_ | 107 #endif // WEBRTC_BASE_ASYNCTCPSOCKET_H_ |
| OLD | NEW |