| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "nacl_io/socket/udp_node.h" | 5 #include "nacl_io/socket/udp_node.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 : SocketNode(filesystem), | 153 : SocketNode(filesystem), |
| 154 emitter_(new UdpEventEmitter(kDefaultFifoSize, kDefaultFifoSize)) { | 154 emitter_(new UdpEventEmitter(kDefaultFifoSize, kDefaultFifoSize)) { |
| 155 emitter_->AttachStream(this); | 155 emitter_->AttachStream(this); |
| 156 } | 156 } |
| 157 | 157 |
| 158 void UdpNode::Destroy() { | 158 void UdpNode::Destroy() { |
| 159 emitter_->DetachStream(); | 159 emitter_->DetachStream(); |
| 160 SocketNode::Destroy(); | 160 SocketNode::Destroy(); |
| 161 } | 161 } |
| 162 | 162 |
| 163 UdpEventEmitter* UdpNode::GetEventEmitter() { return emitter_.get(); } | 163 UdpEventEmitter* UdpNode::GetEventEmitter() { |
| 164 return emitter_.get(); |
| 165 } |
| 164 | 166 |
| 165 Error UdpNode::Init(int open_flags) { | 167 Error UdpNode::Init(int open_flags) { |
| 166 Error err = SocketNode::Init(open_flags); | 168 Error err = SocketNode::Init(open_flags); |
| 167 if (err != 0) | 169 if (err != 0) |
| 168 return err; | 170 return err; |
| 169 | 171 |
| 170 if (UDPInterface() == NULL) | 172 if (UDPInterface() == NULL) |
| 171 return EACCES; | 173 return EACCES; |
| 172 | 174 |
| 173 socket_resource_ = | 175 socket_resource_ = |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 int capped_len = static_cast<int32_t>(std::min<int>(len, kMaxPacketSize)); | 293 int capped_len = static_cast<int32_t>(std::min<int>(len, kMaxPacketSize)); |
| 292 Packet* packet = new Packet(filesystem_->ppapi()); | 294 Packet* packet = new Packet(filesystem_->ppapi()); |
| 293 packet->Copy(buf, capped_len, addr); | 295 packet->Copy(buf, capped_len, addr); |
| 294 | 296 |
| 295 emitter_->WriteTXPacket_Locked(packet); | 297 emitter_->WriteTXPacket_Locked(packet); |
| 296 *out_len = capped_len; | 298 *out_len = capped_len; |
| 297 return 0; | 299 return 0; |
| 298 } | 300 } |
| 299 | 301 |
| 300 } // namespace nacl_io | 302 } // namespace nacl_io |
| OLD | NEW |