@@ -400,20 +400,22 @@ std::unique_ptr<worker::TransferData> Blob::CloneForMessaging() const {
400
400
}
401
401
402
402
void Blob::StoreDataObject (const v8::FunctionCallbackInfo<v8::Value>& args) {
403
- Environment* env = Environment::GetCurrent (args);
404
- BlobBindingData* binding_data = Realm::GetBindingData<BlobBindingData>(args);
403
+ Realm* realm = Realm::GetCurrent (args);
405
404
406
405
CHECK (args[0 ]->IsString ()); // ID key
407
- CHECK (Blob::HasInstance (env, args[1 ])); // Blob
406
+ CHECK (Blob::HasInstance (realm-> env () , args[1 ])); // Blob
408
407
CHECK (args[2 ]->IsUint32 ()); // Length
409
408
CHECK (args[3 ]->IsString ()); // Type
410
409
411
- Utf8Value key (env->isolate (), args[0 ]);
410
+ BlobBindingData* binding_data = realm->GetBindingData <BlobBindingData>();
411
+ Isolate* isolate = realm->isolate ();
412
+
413
+ Utf8Value key (isolate, args[0 ]);
412
414
Blob* blob;
413
415
ASSIGN_OR_RETURN_UNWRAP (&blob, args[1 ]);
414
416
415
417
size_t length = args[2 ].As <Uint32>()->Value ();
416
- Utf8Value type (env-> isolate () , args[3 ]);
418
+ Utf8Value type (isolate, args[3 ]);
417
419
418
420
binding_data->store_data_object (
419
421
std::string (*key, key.length ()),
@@ -427,9 +429,11 @@ void Blob::StoreDataObject(const v8::FunctionCallbackInfo<v8::Value>& args) {
427
429
void Blob::RevokeObjectURL (const FunctionCallbackInfo<Value>& args) {
428
430
CHECK_GE (args.Length (), 1 );
429
431
CHECK (args[0 ]->IsString ());
430
- BlobBindingData* binding_data = Realm::GetBindingData<BlobBindingData>(args);
431
- Environment* env = Environment::GetCurrent (args);
432
- Utf8Value input (env->isolate (), args[0 ].As <String>());
432
+ Realm* realm = Realm::GetCurrent (args);
433
+ BlobBindingData* binding_data = realm->GetBindingData <BlobBindingData>();
434
+ Isolate* isolate = realm->isolate ();
435
+
436
+ Utf8Value input (isolate, args[0 ].As <String>());
433
437
auto out = ada::parse<ada::url_aggregator>(input.ToStringView ());
434
438
435
439
if (!out) {
@@ -449,36 +453,30 @@ void Blob::RevokeObjectURL(const FunctionCallbackInfo<Value>& args) {
449
453
}
450
454
451
455
void Blob::GetDataObject (const v8::FunctionCallbackInfo<v8::Value>& args) {
452
- BlobBindingData* binding_data = Realm::GetBindingData<BlobBindingData>(args);
453
-
454
- Environment* env = Environment::GetCurrent (args);
455
456
CHECK (args[0 ]->IsString ());
457
+ Realm* realm = Realm::GetCurrent (args);
458
+ BlobBindingData* binding_data = realm->GetBindingData <BlobBindingData>();
459
+ Isolate* isolate = realm->isolate ();
456
460
457
- Utf8Value key (env-> isolate () , args[0 ]);
461
+ Utf8Value key (isolate, args[0 ]);
458
462
459
463
BlobBindingData::StoredDataObject stored =
460
464
binding_data->get_data_object (std::string (*key, key.length ()));
461
465
if (stored.blob ) {
462
466
Local<Value> type;
463
- if (!String::NewFromUtf8 (
464
- env-> isolate (),
465
- stored. type . c_str () ,
466
- v8::NewStringType:: kNormal ,
467
- static_cast < int >(stored. type . length ())) .ToLocal (&type)) {
467
+ if (!String::NewFromUtf8 (isolate,
468
+ stored. type . c_str (),
469
+ v8::NewStringType:: kNormal ,
470
+ static_cast < int >(stored. type . length ()))
471
+ .ToLocal (&type)) {
468
472
return ;
469
473
}
470
474
471
- Local<Value> values[] = {
472
- stored.blob ->object (),
473
- Uint32::NewFromUnsigned (env->isolate (), stored.length ),
474
- type
475
- };
475
+ Local<Value> values[] = {stored.blob ->object (),
476
+ Uint32::NewFromUnsigned (isolate, stored.length ),
477
+ type};
476
478
477
- args.GetReturnValue ().Set (
478
- Array::New (
479
- env->isolate (),
480
- values,
481
- arraysize (values)));
479
+ args.GetReturnValue ().Set (Array::New (isolate, values, arraysize (values)));
482
480
}
483
481
}
484
482
0 commit comments