1 // Copyright 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.
5 #ifndef LIBRARIES_NACL_IO_SOCKET_TCP_EVENT_EMITTER_H_
6 #define LIBRARIES_NACL_IO_SOCKET_TCP_EVENT_EMITTER_H_
8 #include "nacl_io/fifo_char.h"
9 #include "nacl_io/stream/stream_event_emitter.h"
11 #include <ppapi/c/pp_resource.h>
13 #include "sdk_util/macros.h"
14 #include "sdk_util/scoped_ref.h"
18 class TcpEventEmitter
;
21 typedef sdk_util::ScopedRef
<TcpEventEmitter
> ScopedTcpEventEmitter
;
23 class TcpEventEmitter
: public StreamEventEmitter
{
25 TcpEventEmitter(size_t rsize
, size_t wsize
);
27 uint32_t ReadIn_Locked(char* buffer
, uint32_t len
);
28 uint32_t WriteIn_Locked(const char* buffer
, uint32_t len
);
30 uint32_t ReadOut_Locked(char* buffer
, uint32_t len
);
31 uint32_t WriteOut_Locked(const char* buffer
, uint32_t len
);
33 bool GetError_Locked();
34 void SetError_Locked();
35 void ConnectDone_Locked();
36 PP_Resource
GetAcceptedSocket_Locked();
37 void SetAcceptedSocket_Locked(PP_Resource socket
);
38 void UpdateStatus_Locked();
39 void SetListening_Locked();
40 void SetRecvEndOfStream_Locked();
42 uint32_t BytesInOutputFIFO();
43 uint32_t SpaceInInputFIFO();
46 virtual FIFOChar
* in_fifo() { return &in_fifo_
; }
47 virtual FIFOChar
* out_fifo() { return &out_fifo_
; }
54 bool recv_endofstream_
;
55 PP_Resource accepted_socket_
;
56 DISALLOW_COPY_AND_ASSIGN(TcpEventEmitter
);
59 } // namespace nacl_io
61 #endif // LIBRARIES_NACL_IO_SOCKET_TCP_EVENT_EMITTER_H_