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

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: 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/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..b9e5c44c9a95607a4195e88781ac4fecff12ede2
--- /dev/null
+++ b/native_client_sdk/src/libraries/nacl_io/fifo_packet.h
@@ -0,0 +1,59 @@
+// 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 <string.h>
+
+#include <list>
+#include <vector>
+
+#include "nacl_io/fifo_interface.h"
+#include "ppapi/c/pp_resource.h"
+
+#include "sdk_util/macros.h"
+
+namespace nacl_io {
+
+class Packet;
+
+// FIFOPacket
+//
+// A FIFOPackiet is linked list of packets. Data is stored and returned
+// in packet size increments. FIFOPacket signals EMPTY where there are
+// no packets, and FULL when the total bytes of all packets meets or
+// exceeds the max size hint.
+class FIFOPacket : public FIFOInterface {
+ public:
+ explicit FIFOPacket(size_t size);
+ virtual ~FIFOPacket();
+
+ virtual bool IsEmpty();
+ virtual bool IsFull();
+ virtual bool Resize(size_t len);
+
+ size_t ReadAvailable();
+ size_t WriteAvailable();
+
+ // Return a pointer to the top packet without releasing ownership.
+ Packet* PeekPacket();
+
+ // Relinquish top packet, and remove it from the FIFO.
+ Packet* ReadPacket();
+
+ // Take ownership of packet and place it in the FIFO.
+ void WritePacket(Packet* packet);
+
+ private:
+ std::list<Packet*> packets_;
+ uint32_t max_bytes_;
+ uint32_t cur_bytes_;
+
+ DISALLOW_COPY_AND_ASSIGN(FIFOPacket);
+};
+
+} // namespace nacl_io
+
+#endif // LIBRARIES_NACL_IO_FIFO_PACKET_H_
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/fifo_null.h ('k') | native_client_sdk/src/libraries/nacl_io/fifo_packet.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698