Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(435)

Side by Side Diff: native_client_sdk/src/libraries/nacl_io/socket/udp_node.cc

Issue 349703003: [NaCl SDK] Add some more logging to nacl_io. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix linux host build Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/socket/tcp_node.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
11 11
12 #include "nacl_io/log.h"
12 #include "nacl_io/pepper_interface.h" 13 #include "nacl_io/pepper_interface.h"
13 #include "nacl_io/socket/packet.h" 14 #include "nacl_io/socket/packet.h"
14 #include "nacl_io/socket/udp_event_emitter.h" 15 #include "nacl_io/socket/udp_event_emitter.h"
15 #include "nacl_io/stream/stream_fs.h" 16 #include "nacl_io/stream/stream_fs.h"
16 17
17 namespace { 18 namespace {
18 const size_t kMaxPacketSize = 65536; 19 const size_t kMaxPacketSize = 65536;
19 const size_t kDefaultFifoSize = kMaxPacketSize * 8; 20 const size_t kDefaultFifoSize = kMaxPacketSize * 8;
20 } 21 }
21 22
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 163
163 UdpEventEmitter* UdpNode::GetEventEmitter() { 164 UdpEventEmitter* UdpNode::GetEventEmitter() {
164 return emitter_.get(); 165 return emitter_.get();
165 } 166 }
166 167
167 Error UdpNode::Init(int open_flags) { 168 Error UdpNode::Init(int open_flags) {
168 Error err = SocketNode::Init(open_flags); 169 Error err = SocketNode::Init(open_flags);
169 if (err != 0) 170 if (err != 0)
170 return err; 171 return err;
171 172
172 if (UDPInterface() == NULL) 173 if (UDPInterface() == NULL) {
174 LOG_ERROR("Got NULL interface: UDP");
173 return EACCES; 175 return EACCES;
176 }
174 177
175 socket_resource_ = 178 socket_resource_ =
176 UDPInterface()->Create(filesystem_->ppapi()->GetInstance()); 179 UDPInterface()->Create(filesystem_->ppapi()->GetInstance());
177 if (0 == socket_resource_) 180 if (0 == socket_resource_) {
181 LOG_ERROR("Unable to create UDP resource.");
178 return EACCES; 182 return EACCES;
183 }
179 184
180 return 0; 185 return 0;
181 } 186 }
182 187
183 void UdpNode::QueueInput() { 188 void UdpNode::QueueInput() {
184 UdpRecvWork* work = new UdpRecvWork(emitter_); 189 UdpRecvWork* work = new UdpRecvWork(emitter_);
185 stream()->EnqueueWork(work); 190 stream()->EnqueueWork(work);
186 } 191 }
187 192
188 void UdpNode::QueueOutput() { 193 void UdpNode::QueueOutput() {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 int capped_len = static_cast<int32_t>(std::min<int>(len, kMaxPacketSize)); 298 int capped_len = static_cast<int32_t>(std::min<int>(len, kMaxPacketSize));
294 Packet* packet = new Packet(filesystem_->ppapi()); 299 Packet* packet = new Packet(filesystem_->ppapi());
295 packet->Copy(buf, capped_len, addr); 300 packet->Copy(buf, capped_len, addr);
296 301
297 emitter_->WriteTXPacket_Locked(packet); 302 emitter_->WriteTXPacket_Locked(packet);
298 *out_len = capped_len; 303 *out_len = capped_len;
299 return 0; 304 return 0;
300 } 305 }
301 306
302 } // namespace nacl_io 307 } // namespace nacl_io
OLDNEW
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/socket/tcp_node.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698