summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2018-06-26 00:07:36 +0200
committerJames M Snell <jasnell@gmail.com>2018-06-29 12:02:46 -0700
commitbf360d2e151f9025a990e671147117139e596bfe (patch)
tree29993251ebf63cd255bcb0d4bd9973f0a3bab012 /src
parentf5db04dcbdaf64b95bd6ca670224d2a9aec31a28 (diff)
downloadandroid-node-v8-bf360d2e151f9025a990e671147117139e596bfe.tar.gz
android-node-v8-bf360d2e151f9025a990e671147117139e596bfe.tar.bz2
android-node-v8-bf360d2e151f9025a990e671147117139e596bfe.zip
src: slightly simplify `FSEventWrap`
We don’t need to track `initialized_`, `HandleWrap` already does that for us. PR-URL: https://github.com/nodejs/node/pull/21533 Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/fs_event_wrap.cc17
1 files changed, 2 insertions, 15 deletions
diff --git a/src/fs_event_wrap.cc b/src/fs_event_wrap.cc
index a9ac679573..164614ae81 100644
--- a/src/fs_event_wrap.cc
+++ b/src/fs_event_wrap.cc
@@ -55,7 +55,6 @@ class FSEventWrap: public HandleWrap {
Local<Context> context);
static void New(const FunctionCallbackInfo<Value>& args);
static void Start(const FunctionCallbackInfo<Value>& args);
- static void Close(const FunctionCallbackInfo<Value>& args);
static void GetInitialized(const FunctionCallbackInfo<Value>& args);
size_t self_size() const override { return sizeof(*this); }
@@ -69,7 +68,6 @@ class FSEventWrap: public HandleWrap {
int status);
uv_fs_event_t handle_;
- bool initialized_ = false;
enum encoding encoding_ = kDefaultEncoding;
};
@@ -89,7 +87,7 @@ FSEventWrap::~FSEventWrap() {
void FSEventWrap::GetInitialized(const FunctionCallbackInfo<Value>& args) {
FSEventWrap* wrap = Unwrap<FSEventWrap>(args.This());
CHECK_NOT_NULL(wrap);
- args.GetReturnValue().Set(wrap->initialized_);
+ args.GetReturnValue().Set(!wrap->IsHandleClosing());
}
void FSEventWrap::Initialize(Local<Object> target,
@@ -134,7 +132,7 @@ void FSEventWrap::Start(const FunctionCallbackInfo<Value>& args) {
FSEventWrap* wrap = Unwrap<FSEventWrap>(args.This());
CHECK_NOT_NULL(wrap);
- CHECK(!wrap->initialized_);
+ CHECK(wrap->IsHandleClosing()); // Check that Start() has not been called.
const int argc = args.Length();
CHECK_GE(argc, 4);
@@ -155,7 +153,6 @@ void FSEventWrap::Start(const FunctionCallbackInfo<Value>& args) {
err = uv_fs_event_start(&wrap->handle_, OnEvent, *path, flags);
wrap->MarkAsInitialized();
- wrap->initialized_ = true;
if (err != 0) {
FSEventWrap::Close(args);
@@ -230,16 +227,6 @@ void FSEventWrap::OnEvent(uv_fs_event_t* handle, const char* filename,
wrap->MakeCallback(env->onchange_string(), arraysize(argv), argv);
}
-
-void FSEventWrap::Close(const FunctionCallbackInfo<Value>& args) {
- FSEventWrap* wrap = Unwrap<FSEventWrap>(args.Holder());
- CHECK_NOT_NULL(wrap);
- CHECK(wrap->initialized_);
-
- wrap->initialized_ = false;
- HandleWrap::Close(args);
-}
-
} // anonymous namespace
} // namespace node