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

Unified Diff: native_client_sdk/src/libraries/nacl_io/fifo_packet.h

Issue 23498015: [NaCl SDK] Support non blocking TCP/UDP (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove event friends, rename EventListenerPoll 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/fifo_packet.h
diff --git a/native_client_sdk/src/libraries/nacl_io/fifo_packet.h b/native_client_sdk/src/libraries/nacl_io/fifo_packet.h
new file mode 100644
index 0000000000000000000000000000000000000000..1b6286bf627a63cfb7b1361179ea5292c361daba
--- /dev/null
+++ b/native_client_sdk/src/libraries/nacl_io/fifo_packet.h
@@ -0,0 +1,66 @@
+// 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.
+
+#ifndef LIBRARIES_NACL_IO_FIFO_PACKET_H_
+#define LIBRARIES_NACL_IO_FIFO_PACKET_H_
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <list>
+
+#include "nacl_io/fifo_interface.h"
+#include "ppapi/c/pp_resource.h"
+
+namespace nacl_io {
+
+struct Packet {
+ Packet(const char *buffer, int32_t len, PP_Resource addr)
+ : len_(len),
+ addr_(addr) {
+ buffer_ = new char[len];
+ memcpy(buffer_, buffer, len);
+ }
+
binji 2013/09/12 01:47:57 missing copy constructor and assignment operator.
noelallen1 2013/09/12 23:19:03 Done.
+ ~Packet() {
+ delete[] buffer_;
+ }
+
+ char* buffer_;
binji 2013/09/12 01:47:57 use std::vector
noelallen1 2013/09/12 23:19:03 Done.
+ int32_t len_;
+ PP_Resource addr_;
+};
+
+class FIFOPacket {
+ public:
+ explicit FIFOPacket(size_t size);
+ ~FIFOPacket();
+
+ virtual bool IsEmpty();
binji 2013/09/12 01:47:57 why virtual?
noelallen1 2013/09/12 23:19:03 Derived from FIFOInterface (was in a different CL)
+ virtual bool IsFull();
+ virtual bool Resize(size_t len);
+
+ // Reads out no more than the requested len without updating the tail.
+ // Returns actual amount read.
+ Packet* PeekPacket();
binji 2013/09/12 01:47:57 What is the Packet ownership? (for all these funct
noelallen1 2013/09/12 23:19:03 Done.
+
+ // Reads out the data making room in the FIFO. Returns actual amount
+ // read.
+ Packet* ReadPacket();
+
+ // Writes into the FIFO no more than len bytes, returns actual amount
+ // written.
+ uint32_t WritePacket(Packet* packet);
+
+
+private:
binji 2013/09/12 01:47:57 nit: indent 1
noelallen1 2013/09/12 23:19:03 Done.
+ std::list<UDPPacket*> packets_;
binji 2013/09/12 01:47:57 UDPPacket? I don't see that defined anywhere.
noelallen1 2013/09/12 23:19:03 Done.
+ uint32_t max_bytes_;
+ uint32_t cur_bytes_;
+};
+
+} // namespace nacl_io
+
+#endif // LIBRARIES_NACL_IO_FIFO_PACKET_H_

Powered by Google App Engine
This is Rietveld 408576698