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

Side by Side Diff: native_client_sdk/src/libraries/nacl_io/packet.cc

Issue 23498015: [NaCl SDK] Support non blocking TCP/UDP (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge Created 7 years, 3 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
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "nacl_io/packet.h"
6
7 #include <string.h>
8
9 #include "nacl_io/pepper_interface.h"
10
11 namespace nacl_io {
12
13 Packet::Packet(PepperInterface* ppapi)
14 : ppapi_(ppapi),
15 addr_(0),
16 buffer_(NULL),
17 len_(0) {}
18
19 Packet:: ~Packet() {
20 if ((NULL != ppapi_) && addr_)
21 ppapi_->ReleaseResource(addr_);
22 delete[] buffer_;
23 }
24
25 void Packet::Take(const void *buffer, size_t len, PP_Resource addr) {
26 addr_ = addr;
27 len_ = len;
28 buffer_ = static_cast<char*>(const_cast<void*>(buffer));
29 }
30
31 void Packet::Copy(const void *buffer, size_t len, PP_Resource addr) {
32 addr_ = addr;
33 len_ = len;
34 buffer_ = new char[len];
35
36 memcpy(buffer_, buffer, len);
37 if (addr && (NULL != ppapi_))
38 ppapi_->AddRefResource(addr);
39 }
40
41 } // namespace nacl_io
OLDNEW
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/packet.h ('k') | native_client_sdk/src/libraries/nacl_io/pepper/all_interfaces.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698