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