diff --git a/src/js_stream.cc b/src/js_stream.cc index ac51d38a728f81..2aeda3197739c9 100644 --- a/src/js_stream.cc +++ b/src/js_stream.cc @@ -237,14 +237,14 @@ void JSStream::ReadBuffer(const FunctionCallbackInfo& args) { do { uv_buf_t buf; ssize_t avail = len; - wrap->OnAlloc(len, &buf); + wrap->EmitAlloc(len, &buf); if (static_cast(buf.len) < avail) avail = buf.len; memcpy(buf.base, data, avail); data += avail; len -= avail; - wrap->OnRead(avail, &buf); + wrap->EmitRead(avail, &buf); } while (len != 0); } @@ -253,7 +253,7 @@ void JSStream::EmitEOF(const FunctionCallbackInfo& args) { JSStream* wrap; ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); - wrap->OnRead(UV_EOF, nullptr); + wrap->EmitRead(UV_EOF, nullptr); } diff --git a/src/stream_base.cc b/src/stream_base.cc index 4d9e1dfc6b2dba..225103cc8d727a 100644 --- a/src/stream_base.cc +++ b/src/stream_base.cc @@ -408,7 +408,7 @@ void StreamBase::AfterWrite(WriteWrap* req_wrap, int status) { // Unref handle property Local req_wrap_obj = req_wrap->object(); req_wrap_obj->Delete(env->context(), env->handle_string()).FromJust(); - OnAfterWrite(req_wrap, status); + EmitAfterWrite(req_wrap, status); Local argv[] = { Integer::New(env->isolate(), status), diff --git a/src/stream_base.h b/src/stream_base.h index 8c0a302d76dd2d..e5e69d2b0b81a8 100644 --- a/src/stream_base.h +++ b/src/stream_base.h @@ -166,19 +166,19 @@ class StreamResource { virtual void ClearError(); // Events - inline void OnAfterWrite(WriteWrap* w, int status) { + inline void EmitAfterWrite(WriteWrap* w, int status) { if (!after_write_cb_.is_empty()) after_write_cb_.fn(w, status, after_write_cb_.ctx); } - inline void OnAlloc(size_t size, uv_buf_t* buf) { + inline void EmitAlloc(size_t size, uv_buf_t* buf) { if (!alloc_cb_.is_empty()) alloc_cb_.fn(size, buf, alloc_cb_.ctx); } - inline void OnRead(ssize_t nread, - const uv_buf_t* buf, - uv_handle_type pending = UV_UNKNOWN_HANDLE) { + inline void EmitRead(ssize_t nread, + const uv_buf_t* buf, + uv_handle_type pending = UV_UNKNOWN_HANDLE) { if (nread > 0) bytes_read_ += static_cast(nread); if (!read_cb_.is_empty()) diff --git a/src/stream_wrap.cc b/src/stream_wrap.cc index 9ff6a8b69a3689..92c7da64c86937 100644 --- a/src/stream_wrap.cc +++ b/src/stream_wrap.cc @@ -171,7 +171,7 @@ void LibuvStreamWrap::OnAlloc(uv_handle_t* handle, CHECK_EQ(wrap->stream(), reinterpret_cast(handle)); - return static_cast(wrap)->OnAlloc(suggested_size, buf); + return wrap->EmitAlloc(suggested_size, buf); } @@ -269,7 +269,7 @@ void LibuvStreamWrap::OnRead(uv_stream_t* handle, } } - static_cast(wrap)->OnRead(nread, buf, type); + wrap->EmitRead(nread, buf, type); } diff --git a/src/tls_wrap.cc b/src/tls_wrap.cc index c15cf166fb29d8..c3e6e699c9c22c 100644 --- a/src/tls_wrap.cc +++ b/src/tls_wrap.cc @@ -230,11 +230,11 @@ void TLSWrap::Receive(const FunctionCallbackInfo& args) { // Copy given buffer entirely or partiall if handle becomes closed while (len > 0 && wrap->IsAlive() && !wrap->IsClosing()) { - wrap->stream_->OnAlloc(len, &buf); + wrap->stream_->EmitAlloc(len, &buf); size_t copy = buf.len > len ? len : buf.len; memcpy(buf.base, data, copy); buf.len = copy; - wrap->stream_->OnRead(buf.len, &buf); + wrap->stream_->EmitRead(buf.len, &buf); data += copy; len -= copy; @@ -443,11 +443,11 @@ void TLSWrap::ClearOut() { int avail = read; uv_buf_t buf; - OnAlloc(avail, &buf); + EmitAlloc(avail, &buf); if (static_cast(buf.len) < avail) avail = buf.len; memcpy(buf.base, current, avail); - OnRead(avail, &buf); + EmitRead(avail, &buf); // Caveat emptor: OnRead() calls into JS land which can result in // the SSL context object being destroyed. We have to carefully @@ -463,7 +463,7 @@ void TLSWrap::ClearOut() { int flags = SSL_get_shutdown(ssl_); if (!eof_ && flags & SSL_RECEIVED_SHUTDOWN) { eof_ = true; - OnRead(UV_EOF, nullptr); + EmitRead(UV_EOF, nullptr); } // We need to check whether an error occurred or the connection was @@ -744,13 +744,13 @@ void TLSWrap::DoRead(ssize_t nread, eof_ = true; } - OnRead(nread, nullptr); + EmitRead(nread, nullptr); return; } // Only client connections can receive data if (ssl_ == nullptr) { - OnRead(UV_EPROTO, nullptr); + EmitRead(UV_EPROTO, nullptr); return; }