| 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_ASYNCUDPSOCKET_H_ | 11 #ifndef WEBRTC_BASE_ASYNCUDPSOCKET_H_ |
| 12 #define WEBRTC_BASE_ASYNCUDPSOCKET_H_ | 12 #define WEBRTC_BASE_ASYNCUDPSOCKET_H_ |
| 13 | 13 |
| 14 #include <memory> |
| 15 |
| 14 #include "webrtc/base/asyncpacketsocket.h" | 16 #include "webrtc/base/asyncpacketsocket.h" |
| 15 #include "webrtc/base/scoped_ptr.h" | |
| 16 #include "webrtc/base/socketfactory.h" | 17 #include "webrtc/base/socketfactory.h" |
| 17 | 18 |
| 18 namespace rtc { | 19 namespace rtc { |
| 19 | 20 |
| 20 // Provides the ability to receive packets asynchronously. Sends are not | 21 // Provides the ability to receive packets asynchronously. Sends are not |
| 21 // buffered since it is acceptable to drop packets under high load. | 22 // buffered since it is acceptable to drop packets under high load. |
| 22 class AsyncUDPSocket : public AsyncPacketSocket { | 23 class AsyncUDPSocket : public AsyncPacketSocket { |
| 23 public: | 24 public: |
| 24 // Binds |socket| and creates AsyncUDPSocket for it. Takes ownership | 25 // Binds |socket| and creates AsyncUDPSocket for it. Takes ownership |
| 25 // of |socket|. Returns NULL if bind() fails (|socket| is destroyed | 26 // of |socket|. Returns NULL if bind() fails (|socket| is destroyed |
| (...skipping 23 matching lines...) Expand all Loading... |
| 49 int SetOption(Socket::Option opt, int value) override; | 50 int SetOption(Socket::Option opt, int value) override; |
| 50 int GetError() const override; | 51 int GetError() const override; |
| 51 void SetError(int error) override; | 52 void SetError(int error) override; |
| 52 | 53 |
| 53 private: | 54 private: |
| 54 // Called when the underlying socket is ready to be read from. | 55 // Called when the underlying socket is ready to be read from. |
| 55 void OnReadEvent(AsyncSocket* socket); | 56 void OnReadEvent(AsyncSocket* socket); |
| 56 // Called when the underlying socket is ready to send. | 57 // Called when the underlying socket is ready to send. |
| 57 void OnWriteEvent(AsyncSocket* socket); | 58 void OnWriteEvent(AsyncSocket* socket); |
| 58 | 59 |
| 59 scoped_ptr<AsyncSocket> socket_; | 60 std::unique_ptr<AsyncSocket> socket_; |
| 60 char* buf_; | 61 char* buf_; |
| 61 size_t size_; | 62 size_t size_; |
| 62 }; | 63 }; |
| 63 | 64 |
| 64 } // namespace rtc | 65 } // namespace rtc |
| 65 | 66 |
| 66 #endif // WEBRTC_BASE_ASYNCUDPSOCKET_H_ | 67 #endif // WEBRTC_BASE_ASYNCUDPSOCKET_H_ |
| OLD | NEW |