Eager Gesture Recognition on Aura
[chromium-blink-merge.git] / native_client_sdk / src / libraries / nacl_io / socket / tcp_event_emitter.h
blob00f9f7672c8c474509d7d79c4d3e76b7853c3618
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();
41 uint32_t BytesInOutputFIFO();
42 uint32_t SpaceInInputFIFO();
44 protected:
45 virtual FIFOChar* in_fifo() { return &in_fifo_; }
46 virtual FIFOChar* out_fifo() { return &out_fifo_; }
48 private:
49 FIFOChar in_fifo_;
50 FIFOChar out_fifo_;
51 bool error_;
52 bool listening_;
53 PP_Resource accepted_socket_;
54 DISALLOW_COPY_AND_ASSIGN(TcpEventEmitter);
57 } // namespace nacl_io
59 #endif // LIBRARIES_NACL_IO_SOCKET_TCP_EVENT_EMITTER_H_