diff options
author | Trevor Norris <trev.norris@gmail.com> | 2013-09-27 10:30:02 -0700 |
---|---|---|
committer | Trevor Norris <trev.norris@gmail.com> | 2013-10-31 14:17:51 -0700 |
commit | 8b8e3b67980d5be9feb03839c2821bd8be3680a3 (patch) | |
tree | e777901c8b5c760ee6355c96e1bc928f56bbf185 /src/node_zlib.cc | |
parent | efa62fd9cc817434206d9fd8592b7bbeaa240e9c (diff) | |
download | android-node-v8-8b8e3b67980d5be9feb03839c2821bd8be3680a3.tar.gz android-node-v8-8b8e3b67980d5be9feb03839c2821bd8be3680a3.tar.bz2 android-node-v8-8b8e3b67980d5be9feb03839c2821bd8be3680a3.zip |
async-wrap: integrate with WeakObject
Making WeakObject inherit from AsyncWrap allows us to peak into almost
all the MakeCallback calls in Node internals.
Diffstat (limited to 'src/node_zlib.cc')
-rw-r--r-- | src/node_zlib.cc | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/src/node_zlib.cc b/src/node_zlib.cc index e2b37d86b1..aed93fe7c6 100644 --- a/src/node_zlib.cc +++ b/src/node_zlib.cc @@ -73,11 +73,10 @@ class ZCtx : public WeakObject { public: ZCtx(Environment* env, Local<Object> wrap, node_zlib_mode mode) - : WeakObject(env->isolate(), wrap), + : WeakObject(env, wrap), chunk_size_(0), dictionary_(NULL), dictionary_len_(0), - env_(env), err_(0), flush_(0), init_done_(false), @@ -95,11 +94,6 @@ class ZCtx : public WeakObject { Close(); } - - inline Environment* env() const { - return env_; - } - void Close() { assert(!write_in_progress_ && "write in progress"); assert(init_done_ && "close before init"); @@ -200,7 +194,7 @@ class ZCtx : public WeakObject { ZCtx::Process, ZCtx::After); - args.GetReturnValue().Set(ctx->weak_object(node_isolate)); + args.GetReturnValue().Set(ctx->object()); } @@ -290,9 +284,8 @@ class ZCtx : public WeakObject { ctx->write_in_progress_ = false; // call the write() cb - Local<Object> handle = ctx->weak_object(node_isolate); Local<Value> args[2] = { avail_in, avail_out }; - MakeCallback(env, handle, env->callback_string(), ARRAY_SIZE(args), args); + ctx->MakeCallback(env->callback_string(), ARRAY_SIZE(args), args); ctx->Unref(); } @@ -307,13 +300,12 @@ class ZCtx : public WeakObject { message = ctx->strm_.msg; } - Local<Object> handle = ctx->weak_object(node_isolate); HandleScope scope(node_isolate); Local<Value> args[2] = { OneByteString(node_isolate, message), Number::New(ctx->err_) }; - MakeCallback(env, handle, env->onerror_string(), ARRAY_SIZE(args), args); + ctx->MakeCallback(env->onerror_string(), ARRAY_SIZE(args), args); // no hope of rescue. ctx->write_in_progress_ = false; @@ -540,7 +532,6 @@ class ZCtx : public WeakObject { int chunk_size_; Bytef* dictionary_; size_t dictionary_len_; - Environment* const env_; int err_; int flush_; bool init_done_; |