diff options
author | ConorDavenport <cnrdavenport@gmail.com> | 2020-01-28 19:17:26 +0300 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2020-02-02 20:06:42 +0300 |
commit | 99c8c6d80ff97ac7d53e01722142ac37756aabf1 (patch) | |
tree | 31a68a8857f6ada0252ca90eb79e56185e569ed6 /src/node_crypto.cc | |
parent | aec9ad8f6c8a75518d81279ec5e7188348e508de (diff) |
src: remove duplicate field env in CryptoJob class
Removed field env from cryptojob class, replaced with
function env() inherited from ThreadPoolWork
PR-URL: https://github.com/nodejs/node/pull/31554
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Diffstat (limited to 'src/node_crypto.cc')
-rw-r--r-- | src/node_crypto.cc | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/src/node_crypto.cc b/src/node_crypto.cc index b589eac6947..459f5479ac4 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -6194,9 +6194,8 @@ bool ECDH::IsKeyPairValid() { // TODO(addaleax): If there is an `AsyncWrap`, it currently has no access to // this object. This makes proper reporting of memory usage impossible. struct CryptoJob : public ThreadPoolWork { - Environment* const env; std::unique_ptr<AsyncWrap> async_wrap; - inline explicit CryptoJob(Environment* env) : ThreadPoolWork(env), env(env) {} + inline explicit CryptoJob(Environment* env) : ThreadPoolWork(env) {} inline void AfterThreadPoolWork(int status) final; virtual void AfterThreadPoolWork() = 0; static inline void Run(std::unique_ptr<CryptoJob> job, Local<Value> wrap); @@ -6207,8 +6206,8 @@ void CryptoJob::AfterThreadPoolWork(int status) { CHECK(status == 0 || status == UV_ECANCELED); std::unique_ptr<CryptoJob> job(this); if (status == UV_ECANCELED) return; - HandleScope handle_scope(env->isolate()); - Context::Scope context_scope(env->context()); + HandleScope handle_scope(env()->isolate()); + Context::Scope context_scope(env()->context()); CHECK_EQ(false, async_wrap->persistent().IsWeak()); AfterThreadPoolWork(); } @@ -6249,12 +6248,12 @@ struct RandomBytesJob : public CryptoJob { inline void AfterThreadPoolWork() override { Local<Value> arg = ToResult(); - async_wrap->MakeCallback(env->ondone_string(), 1, &arg); + async_wrap->MakeCallback(env()->ondone_string(), 1, &arg); } inline Local<Value> ToResult() const { - if (errors.empty()) return Undefined(env->isolate()); - return errors.ToException(env).ToLocalChecked(); + if (errors.empty()) return Undefined(env()->isolate()); + return errors.ToException(env()).ToLocalChecked(); } }; @@ -6306,11 +6305,11 @@ struct PBKDF2Job : public CryptoJob { inline void AfterThreadPoolWork() override { Local<Value> arg = ToResult(); - async_wrap->MakeCallback(env->ondone_string(), 1, &arg); + async_wrap->MakeCallback(env()->ondone_string(), 1, &arg); } inline Local<Value> ToResult() const { - return Boolean::New(env->isolate(), success.FromJust()); + return Boolean::New(env()->isolate(), success.FromJust()); } inline void Cleanse() { @@ -6386,12 +6385,12 @@ struct ScryptJob : public CryptoJob { inline void AfterThreadPoolWork() override { Local<Value> arg = ToResult(); - async_wrap->MakeCallback(env->ondone_string(), 1, &arg); + async_wrap->MakeCallback(env()->ondone_string(), 1, &arg); } inline Local<Value> ToResult() const { - if (errors.empty()) return Undefined(env->isolate()); - return errors.ToException(env).ToLocalChecked(); + if (errors.empty()) return Undefined(env()->isolate()); + return errors.ToException(env()).ToLocalChecked(); } inline void Cleanse() { @@ -6720,7 +6719,7 @@ class GenerateKeyPairJob : public CryptoJob { inline void AfterThreadPoolWork() override { Local<Value> args[3]; ToResult(&args[0], &args[1], &args[2]); - async_wrap->MakeCallback(env->ondone_string(), 3, args); + async_wrap->MakeCallback(env()->ondone_string(), 3, args); } inline void ToResult(Local<Value>* err, @@ -6728,14 +6727,14 @@ class GenerateKeyPairJob : public CryptoJob { Local<Value>* privkey) { if (pkey_ && EncodeKeys(pubkey, privkey)) { CHECK(errors_.empty()); - *err = Undefined(env->isolate()); + *err = Undefined(env()->isolate()); } else { if (errors_.empty()) errors_.Capture(); CHECK(!errors_.empty()); - *err = errors_.ToException(env).ToLocalChecked(); - *pubkey = Undefined(env->isolate()); - *privkey = Undefined(env->isolate()); + *err = errors_.ToException(env()).ToLocalChecked(); + *pubkey = Undefined(env()->isolate()); + *privkey = Undefined(env()->isolate()); } } @@ -6744,20 +6743,21 @@ class GenerateKeyPairJob : public CryptoJob { if (public_key_encoding_.output_key_object_) { // Note that this has the downside of containing sensitive data of the // private key. - if (!KeyObject::Create(env, kKeyTypePublic, pkey_).ToLocal(pubkey)) + if (!KeyObject::Create(env(), kKeyTypePublic, pkey_).ToLocal(pubkey)) return false; } else { - if (!WritePublicKey(env, pkey_.get(), public_key_encoding_) + if (!WritePublicKey(env(), pkey_.get(), public_key_encoding_) .ToLocal(pubkey)) return false; } // Now do the same for the private key. if (private_key_encoding_.output_key_object_) { - if (!KeyObject::Create(env, kKeyTypePrivate, pkey_).ToLocal(privkey)) + if (!KeyObject::Create(env(), kKeyTypePrivate, pkey_) + .ToLocal(privkey)) return false; } else { - if (!WritePrivateKey(env, pkey_.get(), private_key_encoding_) + if (!WritePrivateKey(env(), pkey_.get(), private_key_encoding_) .ToLocal(privkey)) return false; } |