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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: native_client_sdk/src/libraries/nacl_io/packet.cc
diff --git a/native_client_sdk/src/libraries/nacl_io/packet.cc b/native_client_sdk/src/libraries/nacl_io/packet.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9d87bbf47d727cefd513d102fef39d1443094efe
--- /dev/null
+++ b/native_client_sdk/src/libraries/nacl_io/packet.cc
@@ -0,0 +1,38 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "nacl_io/packet.h"
+
+#include "nacl_io/pepper_interface.h"
+
+namespace nacl_io {
+
+Packet::Packet(PepperInterface* ppapi)
+ : ppapi_(ppapi),
+ addr_(0),
+ buffer_(NULL),
+ len_(0) {}
+
+Packet:: ~Packet() {
+ if ((NULL != ppapi_) && addr_)
+ ppapi_->ReleaseResource(addr_);
binji 2013/09/19 00:48:55 delete[] buffer_;
noelallen1 2013/09/19 21:29:27 Done.
+}
+
+void Packet::Take(const void *buffer, size_t len, PP_Resource addr) {
+ addr_ = addr;
+ len_ = len;
+ buffer_ = static_cast<char*>(const_cast<void*>(buffer));
+}
+
+void Packet::Copy(const void *buffer, size_t len, PP_Resource addr) {
+ addr_ = addr;
+ len_ = len;
+ buffer_ = new char[len];
+
+ memcpy(buffer_, buffer, len);
+ if (addr && (NULL != ppapi_))
+ ppapi_->AddRefResource(addr);
+}
+
+} // namespace nacl_io

Powered by Google App Engine
This is Rietveld 408576698