Bug 809587 - Increment the JS malloc counter when doing canvas.toBlob(). r=khuey

This commit is contained in:
Justin Lebar 2012-11-07 17:49:21 -08:00
parent 1105101292
commit d267acb3ce

View File

@ -622,6 +622,11 @@ nsHTMLCanvasElement::ToBlob(nsIFileCallback* aCallback,
nsRefPtr<nsDOMMemoryFile> blob =
new nsDOMMemoryFile(imgData, imgSize, type);
JSContext* cx = nsContentUtils::GetCurrentJSContext();
if (cx) {
JS_updateMallocCounter(cx, imgSize);
}
nsRefPtr<ToBlobRunnable> runnable = new ToBlobRunnable(aCallback, blob);
return NS_DispatchToCurrentThread(runnable);
}
@ -667,6 +672,11 @@ nsHTMLCanvasElement::MozGetAsFileImpl(const nsAString& aName,
rv = NS_ReadInputStreamToBuffer(stream, &imgData, (uint32_t)imgSize);
NS_ENSURE_SUCCESS(rv, rv);
JSContext* cx = nsContentUtils::GetCurrentJSContext();
if (cx) {
JS_updateMallocCounter(cx, imgSize);
}
// The DOMFile takes ownership of the buffer
nsRefPtr<nsDOMMemoryFile> file =
new nsDOMMemoryFile(imgData, (uint32_t)imgSize, aName, type);