mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1022773 - Return value rooting for workers, r=bent
--HG-- extra : rebase_source : 5793c693fb00a71f203202beed491de8ef492093
This commit is contained in:
parent
abace8aef1
commit
36ca527ad7
@ -117,34 +117,37 @@ GetDataStoresStructuredCloneCallbacksRead(JSContext* aCx,
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsRefPtr<WorkerDataStore> workerStore =
|
// Protect workerStoreObj from moving GC during ~nsRefPtr.
|
||||||
new WorkerDataStore(workerPrivate->GlobalScope());
|
JS::Rooted<JSObject*> workerStoreObj(aCx, nullptr);
|
||||||
nsMainThreadPtrHandle<DataStore> backingStore = dataStoreholder;
|
{
|
||||||
|
nsRefPtr<WorkerDataStore> workerStore =
|
||||||
|
new WorkerDataStore(workerPrivate->GlobalScope());
|
||||||
|
nsMainThreadPtrHandle<DataStore> backingStore = dataStoreholder;
|
||||||
|
|
||||||
// When we're on the worker thread, prepare a DataStoreChangeEventProxy.
|
// When we're on the worker thread, prepare a DataStoreChangeEventProxy.
|
||||||
nsRefPtr<DataStoreChangeEventProxy> eventProxy =
|
nsRefPtr<DataStoreChangeEventProxy> eventProxy =
|
||||||
new DataStoreChangeEventProxy(workerPrivate, workerStore);
|
new DataStoreChangeEventProxy(workerPrivate, workerStore);
|
||||||
|
|
||||||
// Add the DataStoreChangeEventProxy as an event listener on the main thread.
|
// Add the DataStoreChangeEventProxy as an event listener on the main thread.
|
||||||
nsRefPtr<DataStoreAddEventListenerRunnable> runnable =
|
nsRefPtr<DataStoreAddEventListenerRunnable> runnable =
|
||||||
new DataStoreAddEventListenerRunnable(workerPrivate,
|
new DataStoreAddEventListenerRunnable(workerPrivate,
|
||||||
backingStore,
|
backingStore,
|
||||||
eventProxy);
|
eventProxy);
|
||||||
runnable->Dispatch(aCx);
|
runnable->Dispatch(aCx);
|
||||||
|
|
||||||
// Point WorkerDataStore to DataStore.
|
// Point WorkerDataStore to DataStore.
|
||||||
workerStore->SetBackingDataStore(backingStore);
|
workerStore->SetBackingDataStore(backingStore);
|
||||||
|
|
||||||
JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
|
JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
|
||||||
if (!global) {
|
if (!global) {
|
||||||
MOZ_ASSERT(false, "cannot get global!");
|
MOZ_ASSERT(false, "cannot get global!");
|
||||||
return nullptr;
|
} else {
|
||||||
}
|
workerStoreObj = workerStore->WrapObject(aCx);
|
||||||
|
if (!JS_WrapObject(aCx, &workerStoreObj)) {
|
||||||
JS::Rooted<JSObject*> workerStoreObj(aCx, workerStore->WrapObject(aCx));
|
MOZ_ASSERT(false, "cannot wrap object for workerStoreObj!");
|
||||||
if (!JS_WrapObject(aCx, &workerStoreObj)) {
|
workerStoreObj = nullptr;
|
||||||
MOZ_ASSERT(false, "cannot wrap object for workerStoreObj!");
|
}
|
||||||
return nullptr;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return workerStoreObj;
|
return workerStoreObj;
|
||||||
|
@ -300,6 +300,8 @@ struct WorkerStructuredCloneCallbacks
|
|||||||
Read(JSContext* aCx, JSStructuredCloneReader* aReader, uint32_t aTag,
|
Read(JSContext* aCx, JSStructuredCloneReader* aReader, uint32_t aTag,
|
||||||
uint32_t aData, void* aClosure)
|
uint32_t aData, void* aClosure)
|
||||||
{
|
{
|
||||||
|
JS::Rooted<JSObject*> result(aCx);
|
||||||
|
|
||||||
// See if object is a nsIDOMFile pointer.
|
// See if object is a nsIDOMFile pointer.
|
||||||
if (aTag == DOMWORKER_SCTAG_FILE) {
|
if (aTag == DOMWORKER_SCTAG_FILE) {
|
||||||
MOZ_ASSERT(!aData);
|
MOZ_ASSERT(!aData);
|
||||||
@ -318,9 +320,12 @@ struct WorkerStructuredCloneCallbacks
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
nsRefPtr<DOMFile> file = new DOMFile(fileImpl);
|
{
|
||||||
JSObject* jsFile = file::CreateFile(aCx, file);
|
// New scope to protect |result| from a moving GC during ~nsRefPtr.
|
||||||
return jsFile;
|
nsRefPtr<DOMFile> file = new DOMFile(fileImpl);
|
||||||
|
result = file::CreateFile(aCx, file);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// See if object is a nsIDOMBlob pointer.
|
// See if object is a nsIDOMBlob pointer.
|
||||||
@ -341,9 +346,12 @@ struct WorkerStructuredCloneCallbacks
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
nsRefPtr<DOMFile> blob = new DOMFile(blobImpl);
|
{
|
||||||
JSObject* jsBlob = file::CreateBlob(aCx, blob);
|
// New scope to protect |result| from a moving GC during ~nsRefPtr.
|
||||||
return jsBlob;
|
nsRefPtr<DOMFile> blob = new DOMFile(blobImpl);
|
||||||
|
result = file::CreateBlob(aCx, blob);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// See if the object is an ImageData.
|
// See if the object is an ImageData.
|
||||||
@ -360,11 +368,14 @@ struct WorkerStructuredCloneCallbacks
|
|||||||
}
|
}
|
||||||
MOZ_ASSERT(dataArray.isObject());
|
MOZ_ASSERT(dataArray.isObject());
|
||||||
|
|
||||||
// Construct the ImageData.
|
{
|
||||||
nsRefPtr<ImageData> imageData = new ImageData(width, height,
|
// Construct the ImageData.
|
||||||
dataArray.toObject());
|
nsRefPtr<ImageData> imageData = new ImageData(width, height,
|
||||||
// Wrap it in a JS::Value.
|
dataArray.toObject());
|
||||||
return imageData->WrapObject(aCx);
|
// Wrap it in a JS::Value, protected from a moving GC during ~nsRefPtr.
|
||||||
|
result = imageData->WrapObject(aCx);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Error(aCx, 0);
|
Error(aCx, 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user