| 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 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 const SocketAddress& bind_address) { | 30 const SocketAddress& bind_address) { |
| 31 AsyncSocket* socket = | 31 AsyncSocket* socket = |
| 32 factory->CreateAsyncSocket(bind_address.family(), SOCK_DGRAM); | 32 factory->CreateAsyncSocket(bind_address.family(), SOCK_DGRAM); |
| 33 if (!socket) | 33 if (!socket) |
| 34 return NULL; | 34 return NULL; |
| 35 return Create(socket, bind_address); | 35 return Create(socket, bind_address); |
| 36 } | 36 } |
| 37 | 37 |
| 38 AsyncUDPSocket::AsyncUDPSocket(AsyncSocket* socket) | 38 AsyncUDPSocket::AsyncUDPSocket(AsyncSocket* socket) |
| 39 : socket_(socket) { | 39 : socket_(socket) { |
| 40 ASSERT(socket_); | |
| 41 size_ = BUF_SIZE; | 40 size_ = BUF_SIZE; |
| 42 buf_ = new char[size_]; | 41 buf_ = new char[size_]; |
| 43 | 42 |
| 44 // The socket should start out readable but not writable. | 43 // The socket should start out readable but not writable. |
| 45 socket_->SignalReadEvent.connect(this, &AsyncUDPSocket::OnReadEvent); | 44 socket_->SignalReadEvent.connect(this, &AsyncUDPSocket::OnReadEvent); |
| 46 socket_->SignalWriteEvent.connect(this, &AsyncUDPSocket::OnWriteEvent); | 45 socket_->SignalWriteEvent.connect(this, &AsyncUDPSocket::OnWriteEvent); |
| 47 } | 46 } |
| 48 | 47 |
| 49 AsyncUDPSocket::~AsyncUDPSocket() { | 48 AsyncUDPSocket::~AsyncUDPSocket() { |
| 50 delete [] buf_; | 49 delete [] buf_; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 // If we did not, then we should resize our buffer to be large enough. | 118 // If we did not, then we should resize our buffer to be large enough. |
| 120 SignalReadPacket(this, buf_, static_cast<size_t>(len), remote_addr, | 119 SignalReadPacket(this, buf_, static_cast<size_t>(len), remote_addr, |
| 121 CreatePacketTime(0)); | 120 CreatePacketTime(0)); |
| 122 } | 121 } |
| 123 | 122 |
| 124 void AsyncUDPSocket::OnWriteEvent(AsyncSocket* socket) { | 123 void AsyncUDPSocket::OnWriteEvent(AsyncSocket* socket) { |
| 125 SignalReadyToSend(this); | 124 SignalReadyToSend(this); |
| 126 } | 125 } |
| 127 | 126 |
| 128 } // namespace rtc | 127 } // namespace rtc |
| OLD | NEW |