Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / native_client_sdk / src / libraries / nacl_io / socket / tcp_event_emitter.h
blob707cb17c5151f137c38645d6bd6d8dfc4d4a7509
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"
16 namespace nacl_io {
18 class TcpEventEmitter;
19 class Node;
21 typedef sdk_util::ScopedRef<TcpEventEmitter> ScopedTcpEventEmitter;
23 class TcpEventEmitter : public StreamEventEmitter {
24 public:
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();
45 protected:
46 virtual FIFOChar* in_fifo() { return &in_fifo_; }
47 virtual FIFOChar* out_fifo() { return &out_fifo_; }
49 private:
50 FIFOChar in_fifo_;
51 FIFOChar out_fifo_;
52 bool error_;
53 bool listening_;
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_