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

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 "nacl_io/pepper_interface.h"
8
9 namespace nacl_io {
10
11 Packet::Packet(PepperInterface* ppapi)
12 : ppapi_(ppapi),
13 addr_(0),
14 buffer_(NULL),
15 len_(0) {}
16
17 Packet:: ~Packet() {
18 if ((NULL != ppapi_) && addr_)
19 ppapi_->ReleaseResource(addr_);
binji 2013/09/19 00:48:55 delete[] buffer_;
noelallen1 2013/09/19 21:29:27 Done.
20 }
21
22 void Packet::Take(const void *buffer, size_t len, PP_Resource addr) {
23 addr_ = addr;
24 len_ = len;
25 buffer_ = static_cast<char*>(const_cast<void*>(buffer));
26 }
27
28 void Packet::Copy(const void *buffer, size_t len, PP_Resource addr) {
29 addr_ = addr;
30 len_ = len;
31 buffer_ = new char[len];
32
33 memcpy(buffer_, buffer, len);
34 if (addr && (NULL != ppapi_))
35 ppapi_->AddRefResource(addr);
36 }
37
38 } // namespace nacl_io
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698