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

Side by Side 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 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 #ifndef LIBRARIES_NACL_IO_FIFO_PACKET_H_
6 #define LIBRARIES_NACL_IO_FIFO_PACKET_H_
7
8 #include <stdint.h>
9 #include <stdlib.h>
10 #include <string.h>
11
12 #include <list>
13
14 #include "nacl_io/fifo_interface.h"
15 #include "ppapi/c/pp_resource.h"
16
17 namespace nacl_io {
18
19 struct Packet {
20 Packet(const char *buffer, int32_t len, PP_Resource addr)
21 : len_(len),
22 addr_(addr) {
23 buffer_ = new char[len];
24 memcpy(buffer_, buffer, len);
25 }
26
binji 2013/09/12 01:47:57 missing copy constructor and assignment operator.
noelallen1 2013/09/12 23:19:03 Done.
27 ~Packet() {
28 delete[] buffer_;
29 }
30
31 char* buffer_;
binji 2013/09/12 01:47:57 use std::vector
noelallen1 2013/09/12 23:19:03 Done.
32 int32_t len_;
33 PP_Resource addr_;
34 };
35
36 class FIFOPacket {
37 public:
38 explicit FIFOPacket(size_t size);
39 ~FIFOPacket();
40
41 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)
42 virtual bool IsFull();
43 virtual bool Resize(size_t len);
44
45 // Reads out no more than the requested len without updating the tail.
46 // Returns actual amount read.
47 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.
48
49 // Reads out the data making room in the FIFO. Returns actual amount
50 // read.
51 Packet* ReadPacket();
52
53 // Writes into the FIFO no more than len bytes, returns actual amount
54 // written.
55 uint32_t WritePacket(Packet* packet);
56
57
58 private:
binji 2013/09/12 01:47:57 nit: indent 1
noelallen1 2013/09/12 23:19:03 Done.
59 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.
60 uint32_t max_bytes_;
61 uint32_t cur_bytes_;
62 };
63
64 } // namespace nacl_io
65
66 #endif // LIBRARIES_NACL_IO_FIFO_PACKET_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698