@@ -6197,9 +6197,8 @@ bool ECDH::IsKeyPairValid() {
6197
6197
// TODO(addaleax): If there is an `AsyncWrap`, it currently has no access to
6198
6198
// this object. This makes proper reporting of memory usage impossible.
6199
6199
struct CryptoJob : public ThreadPoolWork {
6200
- Environment* const env;
6201
6200
std::unique_ptr<AsyncWrap> async_wrap;
6202
- inline explicit CryptoJob (Environment* env) : ThreadPoolWork(env), env(env) {}
6201
+ inline explicit CryptoJob (Environment* env) : ThreadPoolWork(env) {}
6203
6202
inline void AfterThreadPoolWork (int status) final ;
6204
6203
virtual void AfterThreadPoolWork () = 0;
6205
6204
static inline void Run (std::unique_ptr<CryptoJob> job, Local<Value> wrap);
@@ -6210,8 +6209,8 @@ void CryptoJob::AfterThreadPoolWork(int status) {
6210
6209
CHECK (status == 0 || status == UV_ECANCELED);
6211
6210
std::unique_ptr<CryptoJob> job (this );
6212
6211
if (status == UV_ECANCELED) return ;
6213
- HandleScope handle_scope (env->isolate ());
6214
- Context::Scope context_scope (env->context ());
6212
+ HandleScope handle_scope (env () ->isolate ());
6213
+ Context::Scope context_scope (env () ->context ());
6215
6214
CHECK_EQ (false , async_wrap->persistent ().IsWeak ());
6216
6215
AfterThreadPoolWork ();
6217
6216
}
@@ -6252,12 +6251,12 @@ struct RandomBytesJob : public CryptoJob {
6252
6251
6253
6252
inline void AfterThreadPoolWork () override {
6254
6253
Local<Value> arg = ToResult ();
6255
- async_wrap->MakeCallback (env->ondone_string (), 1 , &arg);
6254
+ async_wrap->MakeCallback (env () ->ondone_string (), 1 , &arg);
6256
6255
}
6257
6256
6258
6257
inline Local<Value> ToResult () const {
6259
- if (errors.empty ()) return Undefined (env->isolate ());
6260
- return errors.ToException (env).ToLocalChecked ();
6258
+ if (errors.empty ()) return Undefined (env () ->isolate ());
6259
+ return errors.ToException (env () ).ToLocalChecked ();
6261
6260
}
6262
6261
};
6263
6262
@@ -6309,11 +6308,11 @@ struct PBKDF2Job : public CryptoJob {
6309
6308
6310
6309
inline void AfterThreadPoolWork () override {
6311
6310
Local<Value> arg = ToResult ();
6312
- async_wrap->MakeCallback (env->ondone_string (), 1 , &arg);
6311
+ async_wrap->MakeCallback (env () ->ondone_string (), 1 , &arg);
6313
6312
}
6314
6313
6315
6314
inline Local<Value> ToResult () const {
6316
- return Boolean::New (env->isolate (), success.FromJust ());
6315
+ return Boolean::New (env () ->isolate (), success.FromJust ());
6317
6316
}
6318
6317
6319
6318
inline void Cleanse () {
@@ -6389,12 +6388,12 @@ struct ScryptJob : public CryptoJob {
6389
6388
6390
6389
inline void AfterThreadPoolWork () override {
6391
6390
Local<Value> arg = ToResult ();
6392
- async_wrap->MakeCallback (env->ondone_string (), 1 , &arg);
6391
+ async_wrap->MakeCallback (env () ->ondone_string (), 1 , &arg);
6393
6392
}
6394
6393
6395
6394
inline Local<Value> ToResult () const {
6396
- if (errors.empty ()) return Undefined (env->isolate ());
6397
- return errors.ToException (env).ToLocalChecked ();
6395
+ if (errors.empty ()) return Undefined (env () ->isolate ());
6396
+ return errors.ToException (env () ).ToLocalChecked ();
6398
6397
}
6399
6398
6400
6399
inline void Cleanse () {
@@ -6723,22 +6722,22 @@ class GenerateKeyPairJob : public CryptoJob {
6723
6722
inline void AfterThreadPoolWork () override {
6724
6723
Local<Value> args[3 ];
6725
6724
ToResult (&args[0 ], &args[1 ], &args[2 ]);
6726
- async_wrap->MakeCallback (env->ondone_string (), 3 , args);
6725
+ async_wrap->MakeCallback (env () ->ondone_string (), 3 , args);
6727
6726
}
6728
6727
6729
6728
inline void ToResult (Local<Value>* err,
6730
6729
Local<Value>* pubkey,
6731
6730
Local<Value>* privkey) {
6732
6731
if (pkey_ && EncodeKeys (pubkey, privkey)) {
6733
6732
CHECK (errors_.empty ());
6734
- *err = Undefined (env->isolate ());
6733
+ *err = Undefined (env () ->isolate ());
6735
6734
} else {
6736
6735
if (errors_.empty ())
6737
6736
errors_.Capture ();
6738
6737
CHECK (!errors_.empty ());
6739
- *err = errors_.ToException (env).ToLocalChecked ();
6740
- *pubkey = Undefined (env->isolate ());
6741
- *privkey = Undefined (env->isolate ());
6738
+ *err = errors_.ToException (env () ).ToLocalChecked ();
6739
+ *pubkey = Undefined (env () ->isolate ());
6740
+ *privkey = Undefined (env () ->isolate ());
6742
6741
}
6743
6742
}
6744
6743
@@ -6747,20 +6746,21 @@ class GenerateKeyPairJob : public CryptoJob {
6747
6746
if (public_key_encoding_.output_key_object_ ) {
6748
6747
// Note that this has the downside of containing sensitive data of the
6749
6748
// private key.
6750
- if (!KeyObject::Create (env, kKeyTypePublic , pkey_).ToLocal (pubkey))
6749
+ if (!KeyObject::Create (env () , kKeyTypePublic , pkey_).ToLocal (pubkey))
6751
6750
return false ;
6752
6751
} else {
6753
- if (!WritePublicKey (env, pkey_.get (), public_key_encoding_)
6752
+ if (!WritePublicKey (env () , pkey_.get (), public_key_encoding_)
6754
6753
.ToLocal (pubkey))
6755
6754
return false ;
6756
6755
}
6757
6756
6758
6757
// Now do the same for the private key.
6759
6758
if (private_key_encoding_.output_key_object_ ) {
6760
- if (!KeyObject::Create (env, kKeyTypePrivate , pkey_).ToLocal (privkey))
6759
+ if (!KeyObject::Create (env (), kKeyTypePrivate , pkey_)
6760
+ .ToLocal (privkey))
6761
6761
return false ;
6762
6762
} else {
6763
- if (!WritePrivateKey (env, pkey_.get (), private_key_encoding_)
6763
+ if (!WritePrivateKey (env () , pkey_.get (), private_key_encoding_)
6764
6764
.ToLocal (privkey))
6765
6765
return false ;
6766
6766
}
0 commit comments