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.
5 #include "nacl_io/event_emitter_tcp.h"
11 #include "nacl_io/fifo_char.h"
12 #include "sdk_util/auto_lock.h"
16 EventEmitterTCP::EventEmitterTCP(size_t rsize, size_t wsize)
24 uint32_t EventEmitterTCP::ReadIn_Locked(char* data, uint32_t len) {
25 uint32_t count = in_fifo_.Read(data, len);
26 UpdateStatus_Locked();
30 void EventEmitterTCP::UpdateStatus_Locked() {
32 RaiseEvents_Locked(POLLIN | POLLOUT);
38 RaiseEvents_Locked(POLLIN);
42 EventEmitterStream::UpdateStatus_Locked();
45 void EventEmitterTCP::SetListening_Locked() {
47 UpdateStatus_Locked();
50 uint32_t EventEmitterTCP::WriteIn_Locked(const char* data, uint32_t len) {
51 uint32_t count = in_fifo_.Write(data, len);
53 UpdateStatus_Locked();
57 uint32_t EventEmitterTCP::ReadOut_Locked(char* data, uint32_t len) {
58 uint32_t count = out_fifo_.Read(data, len);
60 UpdateStatus_Locked();
64 uint32_t EventEmitterTCP::WriteOut_Locked(const char* data, uint32_t len) {
65 uint32_t count = out_fifo_.Write(data, len);
67 UpdateStatus_Locked();
71 void EventEmitterTCP::ConnectDone_Locked() {
72 RaiseEvents_Locked(POLLOUT);
73 UpdateStatus_Locked();
76 bool EventEmitterTCP::GetError_Locked() {
80 void EventEmitterTCP::SetError_Locked() {
82 UpdateStatus_Locked();
85 void EventEmitterTCP::SetAcceptedSocket_Locked(PP_Resource socket) {
86 accepted_socket_ = socket;
87 UpdateStatus_Locked();
90 PP_Resource EventEmitterTCP::GetAcceptedSocket_Locked() {
91 int rtn = accepted_socket_;
93 UpdateStatus_Locked();
97 } // namespace nacl_io