Skip to content
Permalink
Browse files

src: make StreamBase::GetAsyncWrap pure virtual

PR-URL: #13174
Reviewed-By: Andreas Madsen <amwebdk@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
  • Loading branch information...
addaleax authored and jasnell committed May 21, 2017
1 parent 597aff0 commit b4f6ea06eb3568cc215a6fc2d6ea7734dcc97e5c
Showing with 6 additions and 20 deletions.
  1. +5 −19 src/stream_base.cc
  2. +1 −1 src/stream_base.h
@@ -54,8 +54,8 @@ int StreamBase::Shutdown(const FunctionCallbackInfo<Value>& args) {
Local<Object> req_wrap_obj = args[0].As<Object>();

AsyncWrap* wrap = GetAsyncWrap();
if (wrap != nullptr)
env->set_init_trigger_id(wrap->get_id());
CHECK_NE(wrap, nullptr);
env->set_init_trigger_id(wrap->get_id());
ShutdownWrap* req_wrap = new ShutdownWrap(env,
req_wrap_obj,
this,
@@ -133,8 +133,6 @@ int StreamBase::Writev(const FunctionCallbackInfo<Value>& args) {
return UV_ENOBUFS;

AsyncWrap* wrap = GetAsyncWrap();
// NOTE: All tests show that GetAsyncWrap() never returns nullptr here. If it
// can then replace the CHECK_NE() with if (wrap != nullptr).
CHECK_NE(wrap, nullptr);
env->set_init_trigger_id(wrap->get_id());
WriteWrap* req_wrap = WriteWrap::New(env,
@@ -425,16 +423,9 @@ void StreamBase::EmitData(ssize_t nread,
if (argv[2].IsEmpty())
argv[2] = Undefined(env->isolate());

AsyncWrap* async = GetAsyncWrap();
if (async == nullptr) {
node::MakeCallback(env,
GetObject(),
env->onread_string(),
arraysize(argv),
argv);
} else {
async->MakeCallback(env->onread_string(), arraysize(argv), argv);
}
AsyncWrap* wrap = GetAsyncWrap();
CHECK_NE(wrap, nullptr);
wrap->MakeCallback(env->onread_string(), arraysize(argv), argv);
}


@@ -448,11 +439,6 @@ int StreamBase::GetFD() {
}


AsyncWrap* StreamBase::GetAsyncWrap() {
return nullptr;
}


Local<Object> StreamBase::GetObject() {
return GetAsyncWrap()->object();
}
@@ -248,7 +248,7 @@ class StreamBase : public StreamResource {
virtual ~StreamBase() = default;

// One of these must be implemented
virtual AsyncWrap* GetAsyncWrap();
virtual AsyncWrap* GetAsyncWrap() = 0;
virtual v8::Local<v8::Object> GetObject();

// Libuv callbacks

0 comments on commit b4f6ea0

Please sign in to comment.
You can’t perform that action at this time.