Bug 1209919 - Improving naming and comments in StructuredCloneHelper, r=smaug

This commit is contained in:
Andrea Marchesini 2015-09-30 13:22:08 +01:00
parent 562485e3b1
commit 89c14c0dbe
20 changed files with 299 additions and 287 deletions

View File

@ -10,7 +10,7 @@
#include "mozilla/dom/BlobBinding.h"
#include "mozilla/dom/Exceptions.h"
#include "mozilla/dom/File.h"
#include "mozilla/dom/StructuredCloneHelper.h"
#include "mozilla/dom/StructuredCloneHolder.h"
#include "mozilla/dom/ToJSValue.h"
#include "mozilla/Maybe.h"
#include "nsCycleCollectionParticipant.h"
@ -198,7 +198,7 @@ private:
class ConsoleRunnable : public nsRunnable
, public WorkerFeature
, public StructuredCloneHelperInternal
, public StructuredCloneHolderBase
{
public:
explicit ConsoleRunnable(Console* aConsole)
@ -211,8 +211,8 @@ public:
virtual
~ConsoleRunnable()
{
// Shutdown the StructuredCloneHelperInternal class.
Shutdown();
// Clear the StructuredCloneHolderBase class.
Clear();
}
bool
@ -352,10 +352,10 @@ protected:
RunConsole(JSContext* aCx, nsPIDOMWindow* aOuterWindow,
nsPIDOMWindow* aInnerWindow) = 0;
virtual JSObject* ReadCallback(JSContext* aCx,
JSStructuredCloneReader* aReader,
uint32_t aTag,
uint32_t aIndex) override
virtual JSObject* CustomReadHandler(JSContext* aCx,
JSStructuredCloneReader* aReader,
uint32_t aTag,
uint32_t aIndex) override
{
AssertIsOnMainThread();
@ -378,9 +378,9 @@ protected:
return nullptr;
}
virtual bool WriteCallback(JSContext* aCx,
JSStructuredCloneWriter* aWriter,
JS::Handle<JSObject*> aObj) override
virtual bool CustomWriteHandler(JSContext* aCx,
JSStructuredCloneWriter* aWriter,
JS::Handle<JSObject*> aObj) override
{
nsRefPtr<Blob> blob;
if (NS_SUCCEEDED(UNWRAP_OBJECT(Blob, aObj, blob)) &&

View File

@ -29,7 +29,7 @@ PostMessageEvent::PostMessageEvent(nsGlobalWindow* aSource,
nsGlobalWindow* aTargetWindow,
nsIPrincipal* aProvidedPrincipal,
bool aTrustedCaller)
: StructuredCloneHelper(CloningSupported, TransferringSupported,
: StructuredCloneHolder(CloningSupported, TransferringSupported,
SameProcessSameThread),
mSource(aSource),
mCallerOrigin(aCallerOrigin),

View File

@ -7,7 +7,7 @@
#ifndef mozilla_dom_PostMessageEvent_h
#define mozilla_dom_PostMessageEvent_h
#include "mozilla/dom/StructuredCloneHelper.h"
#include "mozilla/dom/StructuredCloneHolder.h"
#include "nsCOMPtr.h"
#include "mozilla/nsRefPtr.h"
#include "nsTArray.h"
@ -25,7 +25,7 @@ namespace dom {
* which asynchronously creates and dispatches events.
*/
class PostMessageEvent final : public nsRunnable
, public StructuredCloneHelper
, public StructuredCloneHolder
{
public:
NS_DECL_NSIRUNNABLE

View File

@ -4,7 +4,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "StructuredCloneHelper.h"
#include "StructuredCloneHolder.h"
#include "ImageContainer.h"
#include "mozilla/AutoRestore.h"
@ -55,10 +55,10 @@ StructuredCloneCallbacksRead(JSContext* aCx,
uint32_t aTag, uint32_t aIndex,
void* aClosure)
{
StructuredCloneHelperInternal* helper =
static_cast<StructuredCloneHelperInternal*>(aClosure);
MOZ_ASSERT(helper);
return helper->ReadCallback(aCx, aReader, aTag, aIndex);
StructuredCloneHolderBase* holder =
static_cast<StructuredCloneHolderBase*>(aClosure);
MOZ_ASSERT(holder);
return holder->CustomReadHandler(aCx, aReader, aTag, aIndex);
}
bool
@ -67,10 +67,10 @@ StructuredCloneCallbacksWrite(JSContext* aCx,
JS::Handle<JSObject*> aObj,
void* aClosure)
{
StructuredCloneHelperInternal* helper =
static_cast<StructuredCloneHelperInternal*>(aClosure);
MOZ_ASSERT(helper);
return helper->WriteCallback(aCx, aWriter, aObj);
StructuredCloneHolderBase* holder =
static_cast<StructuredCloneHolderBase*>(aClosure);
MOZ_ASSERT(holder);
return holder->CustomWriteHandler(aCx, aWriter, aObj);
}
bool
@ -82,11 +82,11 @@ StructuredCloneCallbacksReadTransfer(JSContext* aCx,
void* aClosure,
JS::MutableHandleObject aReturnObject)
{
StructuredCloneHelperInternal* helper =
static_cast<StructuredCloneHelperInternal*>(aClosure);
MOZ_ASSERT(helper);
return helper->ReadTransferCallback(aCx, aReader, aTag, aContent,
aExtraData, aReturnObject);
StructuredCloneHolderBase* holder =
static_cast<StructuredCloneHolderBase*>(aClosure);
MOZ_ASSERT(holder);
return holder->CustomReadTransferHandler(aCx, aReader, aTag, aContent,
aExtraData, aReturnObject);
}
bool
@ -99,11 +99,11 @@ StructuredCloneCallbacksWriteTransfer(JSContext* aCx,
void** aContent,
uint64_t* aExtraData)
{
StructuredCloneHelperInternal* helper =
static_cast<StructuredCloneHelperInternal*>(aClosure);
MOZ_ASSERT(helper);
return helper->WriteTransferCallback(aCx, aObj, aTag, aOwnership, aContent,
aExtraData);
StructuredCloneHolderBase* holder =
static_cast<StructuredCloneHolderBase*>(aClosure);
MOZ_ASSERT(holder);
return holder->CustomWriteTransferHandler(aCx, aObj, aTag, aOwnership,
aContent, aExtraData);
}
void
@ -113,10 +113,11 @@ StructuredCloneCallbacksFreeTransfer(uint32_t aTag,
uint64_t aExtraData,
void* aClosure)
{
StructuredCloneHelperInternal* helper =
static_cast<StructuredCloneHelperInternal*>(aClosure);
MOZ_ASSERT(helper);
return helper->FreeTransferCallback(aTag, aOwnership, aContent, aExtraData);
StructuredCloneHolderBase* holder =
static_cast<StructuredCloneHolderBase*>(aClosure);
MOZ_ASSERT(holder);
return holder->CustomFreeTransferHandler(aTag, aOwnership, aContent,
aExtraData);
}
void
@ -137,45 +138,45 @@ const JSStructuredCloneCallbacks gCallbacks = {
} // anonymous namespace
// StructuredCloneHelperInternal class
// StructuredCloneHolderBase class
StructuredCloneHelperInternal::StructuredCloneHelperInternal()
StructuredCloneHolderBase::StructuredCloneHolderBase()
#ifdef DEBUG
: mShutdownCalled(false)
: mClearCalled(false)
#endif
{}
StructuredCloneHelperInternal::~StructuredCloneHelperInternal()
StructuredCloneHolderBase::~StructuredCloneHolderBase()
{
#ifdef DEBUG
MOZ_ASSERT(mShutdownCalled);
MOZ_ASSERT(mClearCalled);
#endif
}
void
StructuredCloneHelperInternal::Shutdown()
StructuredCloneHolderBase::Clear()
{
#ifdef DEBUG
mShutdownCalled = true;
mClearCalled = true;
#endif
mBuffer = nullptr;
}
bool
StructuredCloneHelperInternal::Write(JSContext* aCx,
JS::Handle<JS::Value> aValue)
StructuredCloneHolderBase::Write(JSContext* aCx,
JS::Handle<JS::Value> aValue)
{
return Write(aCx, aValue, JS::UndefinedHandleValue);
}
bool
StructuredCloneHelperInternal::Write(JSContext* aCx,
JS::Handle<JS::Value> aValue,
JS::Handle<JS::Value> aTransfer)
StructuredCloneHolderBase::Write(JSContext* aCx,
JS::Handle<JS::Value> aValue,
JS::Handle<JS::Value> aTransfer)
{
MOZ_ASSERT(!mBuffer, "Double Write is not allowed");
MOZ_ASSERT(!mShutdownCalled, "This method cannot be called after Shutdown.");
MOZ_ASSERT(!mClearCalled, "This method cannot be called after Clear.");
mBuffer = new JSAutoStructuredCloneBuffer(&gCallbacks, this);
@ -188,71 +189,71 @@ StructuredCloneHelperInternal::Write(JSContext* aCx,
}
bool
StructuredCloneHelperInternal::Read(JSContext* aCx,
JS::MutableHandle<JS::Value> aValue)
StructuredCloneHolderBase::Read(JSContext* aCx,
JS::MutableHandle<JS::Value> aValue)
{
MOZ_ASSERT(mBuffer, "Read() without Write() is not allowed.");
MOZ_ASSERT(!mShutdownCalled, "This method cannot be called after Shutdown.");
MOZ_ASSERT(!mClearCalled, "This method cannot be called after Clear.");
bool ok = mBuffer->read(aCx, aValue, &gCallbacks, this);
return ok;
}
bool
StructuredCloneHelperInternal::ReadTransferCallback(JSContext* aCx,
JSStructuredCloneReader* aReader,
uint32_t aTag,
void* aContent,
uint64_t aExtraData,
JS::MutableHandleObject aReturnObject)
StructuredCloneHolderBase::CustomReadTransferHandler(JSContext* aCx,
JSStructuredCloneReader* aReader,
uint32_t aTag,
void* aContent,
uint64_t aExtraData,
JS::MutableHandleObject aReturnObject)
{
MOZ_CRASH("Nothing to read.");
return false;
}
bool
StructuredCloneHelperInternal::WriteTransferCallback(JSContext* aCx,
JS::Handle<JSObject*> aObj,
uint32_t* aTag,
JS::TransferableOwnership* aOwnership,
void** aContent,
uint64_t* aExtraData)
StructuredCloneHolderBase::CustomWriteTransferHandler(JSContext* aCx,
JS::Handle<JSObject*> aObj,
uint32_t* aTag,
JS::TransferableOwnership* aOwnership,
void** aContent,
uint64_t* aExtraData)
{
// No transfers are supported by default.
return false;
}
void
StructuredCloneHelperInternal::FreeTransferCallback(uint32_t aTag,
JS::TransferableOwnership aOwnership,
void* aContent,
uint64_t aExtraData)
StructuredCloneHolderBase::CustomFreeTransferHandler(uint32_t aTag,
JS::TransferableOwnership aOwnership,
void* aContent,
uint64_t aExtraData)
{
MOZ_CRASH("Nothing to free.");
}
// StructuredCloneHelper class
// StructuredCloneHolder class
StructuredCloneHelper::StructuredCloneHelper(CloningSupport aSupportsCloning,
StructuredCloneHolder::StructuredCloneHolder(CloningSupport aSupportsCloning,
TransferringSupport aSupportsTransferring,
ContextSupport aContext)
: mSupportsCloning(aSupportsCloning == CloningSupported)
, mSupportsTransferring(aSupportsTransferring == TransferringSupported)
, mContext(aContext)
, mSupportedContext(aContext)
, mParent(nullptr)
#ifdef DEBUG
, mCreationThread(NS_GetCurrentThread())
#endif
{}
StructuredCloneHelper::~StructuredCloneHelper()
StructuredCloneHolder::~StructuredCloneHolder()
{
Shutdown();
Clear();
MOZ_ASSERT(mTransferredPorts.IsEmpty());
}
void
StructuredCloneHelper::Write(JSContext* aCx,
StructuredCloneHolder::Write(JSContext* aCx,
JS::Handle<JS::Value> aValue,
ErrorResult& aRv)
{
@ -260,20 +261,20 @@ StructuredCloneHelper::Write(JSContext* aCx,
}
void
StructuredCloneHelper::Write(JSContext* aCx,
StructuredCloneHolder::Write(JSContext* aCx,
JS::Handle<JS::Value> aValue,
JS::Handle<JS::Value> aTransfer,
ErrorResult& aRv)
{
MOZ_ASSERT_IF(mContext == SameProcessSameThread,
MOZ_ASSERT_IF(mSupportedContext == SameProcessSameThread,
mCreationThread == NS_GetCurrentThread());
if (!StructuredCloneHelperInternal::Write(aCx, aValue, aTransfer)) {
if (!StructuredCloneHolderBase::Write(aCx, aValue, aTransfer)) {
aRv.Throw(NS_ERROR_DOM_DATA_CLONE_ERR);
return;
}
if (mContext != SameProcessSameThread) {
if (mSupportedContext != SameProcessSameThread) {
for (uint32_t i = 0, len = mBlobImplArray.Length(); i < len; ++i) {
if (!mBlobImplArray[i]->MayBeClonedToOtherThreads()) {
aRv.Throw(NS_ERROR_DOM_DATA_CLONE_ERR);
@ -284,18 +285,18 @@ StructuredCloneHelper::Write(JSContext* aCx,
}
void
StructuredCloneHelper::Read(nsISupports* aParent,
StructuredCloneHolder::Read(nsISupports* aParent,
JSContext* aCx,
JS::MutableHandle<JS::Value> aValue,
ErrorResult& aRv)
{
MOZ_ASSERT_IF(mContext == SameProcessSameThread,
MOZ_ASSERT_IF(mSupportedContext == SameProcessSameThread,
mCreationThread == NS_GetCurrentThread());
mozilla::AutoRestore<nsISupports*> guard(mParent);
mParent = aParent;
if (!StructuredCloneHelperInternal::Read(aCx, aValue)) {
if (!StructuredCloneHolderBase::Read(aCx, aValue)) {
JS_ClearPendingException(aCx);
aRv.Throw(NS_ERROR_DOM_DATA_CLONE_ERR);
}
@ -304,12 +305,12 @@ StructuredCloneHelper::Read(nsISupports* aParent,
if (mSupportsTransferring) {
mBlobImplArray.Clear();
mClonedImages.Clear();
Shutdown();
Clear();
}
}
void
StructuredCloneHelper::ReadFromBuffer(nsISupports* aParent,
StructuredCloneHolder::ReadFromBuffer(nsISupports* aParent,
JSContext* aCx,
uint64_t* aBuffer,
size_t aBufferLength,
@ -321,7 +322,7 @@ StructuredCloneHelper::ReadFromBuffer(nsISupports* aParent,
}
void
StructuredCloneHelper::ReadFromBuffer(nsISupports* aParent,
StructuredCloneHolder::ReadFromBuffer(nsISupports* aParent,
JSContext* aCx,
uint64_t* aBuffer,
size_t aBufferLength,
@ -329,7 +330,7 @@ StructuredCloneHelper::ReadFromBuffer(nsISupports* aParent,
JS::MutableHandle<JS::Value> aValue,
ErrorResult& aRv)
{
MOZ_ASSERT_IF(mContext == SameProcessSameThread,
MOZ_ASSERT_IF(mSupportedContext == SameProcessSameThread,
mCreationThread == NS_GetCurrentThread());
MOZ_ASSERT(!mBuffer, "ReadFromBuffer() must be called without a Write().");
@ -346,10 +347,10 @@ StructuredCloneHelper::ReadFromBuffer(nsISupports* aParent,
}
void
StructuredCloneHelper::MoveBufferDataToArray(FallibleTArray<uint8_t>& aArray,
StructuredCloneHolder::MoveBufferDataToArray(FallibleTArray<uint8_t>& aArray,
ErrorResult& aRv)
{
MOZ_ASSERT_IF(mContext == SameProcessSameThread,
MOZ_ASSERT_IF(mSupportedContext == SameProcessSameThread,
mCreationThread == NS_GetCurrentThread());
MOZ_ASSERT(mBuffer, "MoveBuffer() cannot be called without a Write().");
@ -369,7 +370,7 @@ StructuredCloneHelper::MoveBufferDataToArray(FallibleTArray<uint8_t>& aArray,
}
void
StructuredCloneHelper::FreeBuffer(uint64_t* aBuffer,
StructuredCloneHolder::FreeBuffer(uint64_t* aBuffer,
size_t aBufferLength)
{
MOZ_ASSERT(!mBuffer, "FreeBuffer() must be called without a Write().");
@ -380,7 +381,7 @@ StructuredCloneHelper::FreeBuffer(uint64_t* aBuffer,
}
/* static */ JSObject*
StructuredCloneHelper::ReadFullySerializableObjects(JSContext* aCx,
StructuredCloneHolder::ReadFullySerializableObjects(JSContext* aCx,
JSStructuredCloneReader* aReader,
uint32_t aTag,
uint32_t aIndex)
@ -524,7 +525,7 @@ StructuredCloneHelper::ReadFullySerializableObjects(JSContext* aCx,
}
/* static */ bool
StructuredCloneHelper::WriteFullySerializableObjects(JSContext* aCx,
StructuredCloneHolder::WriteFullySerializableObjects(JSContext* aCx,
JSStructuredCloneWriter* aWriter,
JS::Handle<JSObject*> aObj)
{
@ -686,11 +687,11 @@ EnsureBlobForBackgroundManager(BlobImpl* aBlobImpl,
JSObject*
ReadBlob(JSContext* aCx,
uint32_t aIndex,
StructuredCloneHelper* aHelper)
StructuredCloneHolder* aHolder)
{
MOZ_ASSERT(aHelper);
MOZ_ASSERT(aIndex < aHelper->BlobImpls().Length());
nsRefPtr<BlobImpl> blobImpl = aHelper->BlobImpls()[aIndex];
MOZ_ASSERT(aHolder);
MOZ_ASSERT(aIndex < aHolder->BlobImpls().Length());
nsRefPtr<BlobImpl> blobImpl = aHolder->BlobImpls()[aIndex];
blobImpl = EnsureBlobForBackgroundManager(blobImpl);
MOZ_ASSERT(blobImpl);
@ -702,7 +703,7 @@ ReadBlob(JSContext* aCx,
// while destructors are running.
JS::Rooted<JS::Value> val(aCx);
{
nsRefPtr<Blob> blob = Blob::Create(aHelper->ParentDuringRead(), blobImpl);
nsRefPtr<Blob> blob = Blob::Create(aHolder->ParentDuringRead(), blobImpl);
if (!ToJSValue(aCx, blob, &val)) {
return nullptr;
}
@ -714,19 +715,19 @@ ReadBlob(JSContext* aCx,
bool
WriteBlob(JSStructuredCloneWriter* aWriter,
Blob* aBlob,
StructuredCloneHelper* aHelper)
StructuredCloneHolder* aHolder)
{
MOZ_ASSERT(aWriter);
MOZ_ASSERT(aBlob);
MOZ_ASSERT(aHelper);
MOZ_ASSERT(aHolder);
nsRefPtr<BlobImpl> blobImpl = EnsureBlobForBackgroundManager(aBlob->Impl());
MOZ_ASSERT(blobImpl);
// We store the position of the blobImpl in the array as index.
if (JS_WriteUint32Pair(aWriter, SCTAG_DOM_BLOB,
aHelper->BlobImpls().Length())) {
aHelper->BlobImpls().AppendElement(blobImpl);
aHolder->BlobImpls().Length())) {
aHolder->BlobImpls().AppendElement(blobImpl);
return true;
}
@ -738,14 +739,14 @@ JSObject*
ReadFileList(JSContext* aCx,
JSStructuredCloneReader* aReader,
uint32_t aCount,
StructuredCloneHelper* aHelper)
StructuredCloneHolder* aHolder)
{
MOZ_ASSERT(aCx);
MOZ_ASSERT(aReader);
JS::Rooted<JS::Value> val(aCx);
{
nsRefPtr<FileList> fileList = new FileList(aHelper->ParentDuringRead());
nsRefPtr<FileList> fileList = new FileList(aHolder->ParentDuringRead());
uint32_t tag, offset;
// Offset is the index of the blobImpl from which we can find the blobImpl
@ -759,15 +760,15 @@ ReadFileList(JSContext* aCx,
// |aCount| is the number of BlobImpls to use from the |offset|.
for (uint32_t i = 0; i < aCount; ++i) {
uint32_t index = offset + i;
MOZ_ASSERT(index < aHelper->BlobImpls().Length());
MOZ_ASSERT(index < aHolder->BlobImpls().Length());
nsRefPtr<BlobImpl> blobImpl = aHelper->BlobImpls()[index];
nsRefPtr<BlobImpl> blobImpl = aHolder->BlobImpls()[index];
MOZ_ASSERT(blobImpl->IsFile());
blobImpl = EnsureBlobForBackgroundManager(blobImpl);
MOZ_ASSERT(blobImpl);
nsRefPtr<File> file = File::Create(aHelper->ParentDuringRead(), blobImpl);
nsRefPtr<File> file = File::Create(aHolder->ParentDuringRead(), blobImpl);
if (!fileList->Append(file)) {
return nullptr;
}
@ -787,11 +788,11 @@ ReadFileList(JSContext* aCx,
bool
WriteFileList(JSStructuredCloneWriter* aWriter,
FileList* aFileList,
StructuredCloneHelper* aHelper)
StructuredCloneHolder* aHolder)
{
MOZ_ASSERT(aWriter);
MOZ_ASSERT(aFileList);
MOZ_ASSERT(aHelper);
MOZ_ASSERT(aHolder);
// A FileList is serialized writing the X number of elements and the offset
// from mBlobImplArray. The Read will take X elements from mBlobImplArray
@ -799,7 +800,7 @@ WriteFileList(JSStructuredCloneWriter* aWriter,
if (!JS_WriteUint32Pair(aWriter, SCTAG_DOM_FILELIST,
aFileList->Length()) ||
!JS_WriteUint32Pair(aWriter, 0,
aHelper->BlobImpls().Length())) {
aHolder->BlobImpls().Length())) {
return false;
}
@ -808,7 +809,7 @@ WriteFileList(JSStructuredCloneWriter* aWriter,
EnsureBlobForBackgroundManager(aFileList->Item(i)->Impl());
MOZ_ASSERT(blobImpl);
aHelper->BlobImpls().AppendElement(blobImpl);
aHolder->BlobImpls().AppendElement(blobImpl);
}
return true;
@ -819,17 +820,17 @@ JSObject*
ReadFormData(JSContext* aCx,
JSStructuredCloneReader* aReader,
uint32_t aCount,
StructuredCloneHelper* aHelper)
StructuredCloneHolder* aHolder)
{
MOZ_ASSERT(aCx);
MOZ_ASSERT(aReader);
MOZ_ASSERT(aHelper);
MOZ_ASSERT(aHolder);
// See the serialization of the FormData for the format.
JS::Rooted<JS::Value> val(aCx);
{
nsRefPtr<nsFormData> formData =
new nsFormData(aHelper->ParentDuringRead());
new nsFormData(aHolder->ParentDuringRead());
Optional<nsAString> thirdArg;
for (uint32_t i = 0; i < aCount; ++i) {
@ -844,14 +845,14 @@ ReadFormData(JSContext* aCx,
}
if (tag == SCTAG_DOM_BLOB) {
MOZ_ASSERT(indexOrLengthOfString < aHelper->BlobImpls().Length());
MOZ_ASSERT(indexOrLengthOfString < aHolder->BlobImpls().Length());
nsRefPtr<BlobImpl> blobImpl =
aHelper->BlobImpls()[indexOrLengthOfString];
aHolder->BlobImpls()[indexOrLengthOfString];
MOZ_ASSERT(blobImpl->IsFile());
nsRefPtr<File> file =
File::Create(aHelper->ParentDuringRead(), blobImpl);
File::Create(aHolder->ParentDuringRead(), blobImpl);
MOZ_ASSERT(file);
formData->Append(name, *file, thirdArg);
@ -891,11 +892,11 @@ ReadFormData(JSContext* aCx,
bool
WriteFormData(JSStructuredCloneWriter* aWriter,
nsFormData* aFormData,
StructuredCloneHelper* aHelper)
StructuredCloneHolder* aHolder)
{
MOZ_ASSERT(aWriter);
MOZ_ASSERT(aFormData);
MOZ_ASSERT(aHelper);
MOZ_ASSERT(aHolder);
if (!JS_WriteUint32Pair(aWriter, SCTAG_DOM_FORMDATA,
aFormData->Length())) {
@ -905,13 +906,13 @@ WriteFormData(JSStructuredCloneWriter* aWriter,
class MOZ_STACK_CLASS Closure final
{
JSStructuredCloneWriter* mWriter;
StructuredCloneHelper* mHelper;
StructuredCloneHolder* mHolder;
public:
Closure(JSStructuredCloneWriter* aWriter,
StructuredCloneHelper* aHelper)
StructuredCloneHolder* aHolder)
: mWriter(aWriter),
mHelper(aHelper)
mHolder(aHolder)
{ }
static bool
@ -926,11 +927,11 @@ WriteFormData(JSStructuredCloneWriter* aWriter,
if (isFile) {
BlobImpl* blobImpl = aFile->Impl();
if (!JS_WriteUint32Pair(closure->mWriter, SCTAG_DOM_BLOB,
closure->mHelper->BlobImpls().Length())) {
closure->mHolder->BlobImpls().Length())) {
return false;
}
closure->mHelper->BlobImpls().AppendElement(blobImpl);
closure->mHolder->BlobImpls().AppendElement(blobImpl);
return true;
}
@ -944,17 +945,17 @@ WriteFormData(JSStructuredCloneWriter* aWriter,
return true;
}
};
Closure closure(aWriter, aHelper);
Closure closure(aWriter, aHolder);
return aFormData->ForEach(Closure::Write, &closure);
}
} // anonymous namespace
JSObject*
StructuredCloneHelper::ReadCallback(JSContext* aCx,
JSStructuredCloneReader* aReader,
uint32_t aTag,
uint32_t aIndex)
StructuredCloneHolder::CustomReadHandler(JSContext* aCx,
JSStructuredCloneReader* aReader,
uint32_t aTag,
uint32_t aIndex)
{
MOZ_ASSERT(mSupportsCloning);
@ -971,8 +972,8 @@ StructuredCloneHelper::ReadCallback(JSContext* aCx,
}
if (aTag == SCTAG_DOM_IMAGEBITMAP) {
MOZ_ASSERT(mContext == SameProcessSameThread ||
mContext == SameProcessDifferentThread);
MOZ_ASSERT(mSupportedContext == SameProcessSameThread ||
mSupportedContext == SameProcessDifferentThread);
// Get the current global object.
// This can be null.
@ -986,9 +987,9 @@ StructuredCloneHelper::ReadCallback(JSContext* aCx,
}
bool
StructuredCloneHelper::WriteCallback(JSContext* aCx,
JSStructuredCloneWriter* aWriter,
JS::Handle<JSObject*> aObj)
StructuredCloneHolder::CustomWriteHandler(JSContext* aCx,
JSStructuredCloneWriter* aWriter,
JS::Handle<JSObject*> aObj)
{
if (!mSupportsCloning) {
return false;
@ -1019,8 +1020,8 @@ StructuredCloneHelper::WriteCallback(JSContext* aCx,
}
// See if this is an ImageBitmap object.
if (mContext == SameProcessSameThread ||
mContext == SameProcessDifferentThread) {
if (mSupportedContext == SameProcessSameThread ||
mSupportedContext == SameProcessDifferentThread) {
ImageBitmap* imageBitmap = nullptr;
if (NS_SUCCEEDED(UNWRAP_OBJECT(ImageBitmap, aObj, imageBitmap))) {
return ImageBitmap::WriteStructuredClone(aWriter,
@ -1033,12 +1034,12 @@ StructuredCloneHelper::WriteCallback(JSContext* aCx,
}
bool
StructuredCloneHelper::ReadTransferCallback(JSContext* aCx,
JSStructuredCloneReader* aReader,
uint32_t aTag,
void* aContent,
uint64_t aExtraData,
JS::MutableHandleObject aReturnObject)
StructuredCloneHolder::CustomReadTransferHandler(JSContext* aCx,
JSStructuredCloneReader* aReader,
uint32_t aTag,
void* aContent,
uint64_t aExtraData,
JS::MutableHandleObject aReturnObject)
{
MOZ_ASSERT(mSupportsTransferring);
@ -1073,12 +1074,12 @@ StructuredCloneHelper::ReadTransferCallback(JSContext* aCx,
}
bool
StructuredCloneHelper::WriteTransferCallback(JSContext* aCx,
JS::Handle<JSObject*> aObj,
uint32_t* aTag,
JS::TransferableOwnership* aOwnership,
void** aContent,
uint64_t* aExtraData)
StructuredCloneHolder::CustomWriteTransferHandler(JSContext* aCx,
JS::Handle<JSObject*> aObj,
uint32_t* aTag,
JS::TransferableOwnership* aOwnership,
void** aContent,
uint64_t* aExtraData)
{
if (!mSupportsTransferring) {
return false;
@ -1106,10 +1107,10 @@ StructuredCloneHelper::WriteTransferCallback(JSContext* aCx,
}
void
StructuredCloneHelper::FreeTransferCallback(uint32_t aTag,
JS::TransferableOwnership aOwnership,
void* aContent,
uint64_t aExtraData)
StructuredCloneHolder::CustomFreeTransferHandler(uint32_t aTag,
JS::TransferableOwnership aOwnership,
void* aContent,
uint64_t aExtraData)
{
MOZ_ASSERT(mSupportsTransferring);

View File

@ -3,8 +3,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_StructuredCloneHelper_h
#define mozilla_dom_StructuredCloneHelper_h
#ifndef mozilla_dom_StructuredCloneHolder_h
#define mozilla_dom_StructuredCloneHolder_h
#include "js/StructuredClone.h"
#include "mozilla/Move.h"
@ -24,69 +24,74 @@ class Image;
namespace dom {
class StructuredCloneHelperInternal
class StructuredCloneHolderBase
{
public:
StructuredCloneHelperInternal();
virtual ~StructuredCloneHelperInternal();
StructuredCloneHolderBase();
virtual ~StructuredCloneHolderBase();
// These methods should be implemented in order to clone data.
// Read more documentation in js/public/StructuredClone.h.
virtual JSObject* ReadCallback(JSContext* aCx,
JSStructuredCloneReader* aReader,
uint32_t aTag,
uint32_t aIndex) = 0;
virtual JSObject* CustomReadHandler(JSContext* aCx,
JSStructuredCloneReader* aReader,
uint32_t aTag,
uint32_t aIndex) = 0;
virtual bool WriteCallback(JSContext* aCx,
JSStructuredCloneWriter* aWriter,
JS::Handle<JSObject*> aObj) = 0;
virtual bool CustomWriteHandler(JSContext* aCx,
JSStructuredCloneWriter* aWriter,
JS::Handle<JSObject*> aObj) = 0;
// This method has to be called when this object is not needed anymore.
// It will free memory and the buffer. This has to be called because
// otherwise the buffer will be freed in the DTOR of this class and at that
// point we cannot use the overridden methods.
void Shutdown();
void Clear();
// If these 3 methods are not implement, transfering objects will not be
// allowed.
// allowed. Otherwise only arrayBuffers will be transferred.
virtual bool
ReadTransferCallback(JSContext* aCx,
JSStructuredCloneReader* aReader,
uint32_t aTag,
void* aContent,
uint64_t aExtraData,
JS::MutableHandleObject aReturnObject);
CustomReadTransferHandler(JSContext* aCx,
JSStructuredCloneReader* aReader,
uint32_t aTag,
void* aContent,
uint64_t aExtraData,
JS::MutableHandleObject aReturnObject);
virtual bool
WriteTransferCallback(JSContext* aCx,
JS::Handle<JSObject*> aObj,
// Output:
uint32_t* aTag,
JS::TransferableOwnership* aOwnership,
void** aContent,
uint64_t* aExtraData);
CustomWriteTransferHandler(JSContext* aCx,
JS::Handle<JSObject*> aObj,
// Output:
uint32_t* aTag,
JS::TransferableOwnership* aOwnership,
void** aContent,
uint64_t* aExtraData);
virtual void
FreeTransferCallback(uint32_t aTag,
JS::TransferableOwnership aOwnership,
void* aContent,
uint64_t aExtraData);
CustomFreeTransferHandler(uint32_t aTag,
JS::TransferableOwnership aOwnership,
void* aContent,
uint64_t aExtraData);
// These methods are what you should use.
// These methods are what you should use to read/write data.
// Execute the serialization of aValue using the Structured Clone Algorithm.
// The data can read back using Read().
bool Write(JSContext* aCx,
JS::Handle<JS::Value> aValue);
// Like Write() but it supports the transferring of objects.
bool Write(JSContext* aCx,
JS::Handle<JS::Value> aValue,
JS::Handle<JS::Value> aTransfer);
// If Write() has been called, this method retrieves data and stores it into
// aValue.
bool Read(JSContext* aCx,
JS::MutableHandle<JS::Value> aValue);
bool HasBeenWritten() const
bool HasData() const
{
return !!mBuffer;
}
@ -107,7 +112,7 @@ protected:
nsAutoPtr<JSAutoStructuredCloneBuffer> mBuffer;
#ifdef DEBUG
bool mShutdownCalled;
bool mClearCalled;
#endif
};
@ -115,7 +120,7 @@ class BlobImpl;
class MessagePort;
class MessagePortIdentifier;
class StructuredCloneHelper : public StructuredCloneHelperInternal
class StructuredCloneHolder : public StructuredCloneHolderBase
{
public:
enum CloningSupport
@ -145,10 +150,10 @@ public:
// be read and written. Additional checks about the nature of the objects
// will be done based on this context value because not all the objects can
// be sent between threads or processes.
explicit StructuredCloneHelper(CloningSupport aSupportsCloning,
explicit StructuredCloneHolder(CloningSupport aSupportsCloning,
TransferringSupport aSupportsTransferring,
ContextSupport aContextSupport);
virtual ~StructuredCloneHelper();
virtual ~StructuredCloneHolder();
// Normally you should just use Write() and Read().
@ -167,11 +172,12 @@ public:
ErrorResult &aRv);
// Sometimes, when IPC is involved, you must send a buffer after a Write().
// This method 'steals' the internal data from this helper class.
// You should free this buffer with FreeBuffer().
// This method 'steals' the internal data from this class.
// You should free this buffer with StructuredCloneHolder::FreeBuffer().
void MoveBufferDataToArray(FallibleTArray<uint8_t>& aArray,
ErrorResult& aRv);
// Call this method to know if this object is keeping some DOM object alive.
bool HasClonedDOMObjects() const
{
return !mBlobImplArray.IsEmpty() ||
@ -184,6 +190,8 @@ public:
return mBlobImplArray;
}
// The parent object is set internally just during the Read(). This method
// can be used by read functions to retrieve it.
nsISupports* ParentDuringRead() const
{
return mParent;
@ -209,35 +217,40 @@ public:
return mClonedImages;
}
// Custom Callbacks
// Implementations of the virtual methods to allow cloning of objects which
// JS engine itself doesn't clone.
virtual JSObject* ReadCallback(JSContext* aCx,
JSStructuredCloneReader* aReader,
uint32_t aTag,
uint32_t aIndex) override;
virtual JSObject* CustomReadHandler(JSContext* aCx,
JSStructuredCloneReader* aReader,
uint32_t aTag,
uint32_t aIndex) override;
virtual bool WriteCallback(JSContext* aCx,
JSStructuredCloneWriter* aWriter,
JS::Handle<JSObject*> aObj) override;
virtual bool CustomWriteHandler(JSContext* aCx,
JSStructuredCloneWriter* aWriter,
JS::Handle<JSObject*> aObj) override;
virtual bool ReadTransferCallback(JSContext* aCx,
JSStructuredCloneReader* aReader,
uint32_t aTag,
void* aContent,
uint64_t aExtraData,
JS::MutableHandleObject aReturnObject) override;
virtual bool CustomReadTransferHandler(JSContext* aCx,
JSStructuredCloneReader* aReader,
uint32_t aTag,
void* aContent,
uint64_t aExtraData,
JS::MutableHandleObject aReturnObject) override;
virtual bool WriteTransferCallback(JSContext* aCx,
JS::Handle<JSObject*> aObj,
uint32_t* aTag,
JS::TransferableOwnership* aOwnership,
void** aContent,
uint64_t* aExtraData) override;
virtual bool CustomWriteTransferHandler(JSContext* aCx,
JS::Handle<JSObject*> aObj,
uint32_t* aTag,
JS::TransferableOwnership* aOwnership,
void** aContent,
uint64_t* aExtraData) override;
virtual void FreeTransferCallback(uint32_t aTag,
JS::TransferableOwnership aOwnership,
void* aContent,
uint64_t aExtraData) override;
virtual void CustomFreeTransferHandler(uint32_t aTag,
JS::TransferableOwnership aOwnership,
void* aContent,
uint64_t aExtraData) override;
// These 2 static methods are useful to read/write fully serializable objects.
// They can be used by custom StructuredCloneHolderBase classes to
// serialize objects such as ImageData, CryptoKey, RTCCertificate, etc.
static JSObject* ReadFullySerializableObjects(JSContext* aCx,
JSStructuredCloneReader* aReader,
@ -273,10 +286,9 @@ protected:
bool mSupportsCloning;
bool mSupportsTransferring;
ContextSupport mContext;
// Useful for the structured clone algorithm:
ContextSupport mSupportedContext;
// Used for cloning blobs in the structured cloning algorithm.
nsTArray<nsRefPtr<BlobImpl>> mBlobImplArray;
// This is used for sharing the backend of ImageBitmaps.
@ -285,8 +297,7 @@ protected:
// instance, so no race condition will occur.
nsTArray<nsRefPtr<layers::Image>> mClonedImages;
// This raw pointer is set and unset into the ::Read(). It's always null
// outside that method. For this reason it's a raw pointer.
// This raw pointer is only set within ::Read() and is unset by the end.
nsISupports* MOZ_NON_OWNING_REF mParent;
// This array contains the ports once we've finished the reading. It's
@ -306,4 +317,4 @@ protected:
} // dom namespace
} // mozilla namespace
#endif // mozilla_dom_StructuredCloneHelper_h
#endif // mozilla_dom_StructuredCloneHolder_h

View File

@ -200,7 +200,7 @@ EXPORTS.mozilla.dom += [
'ScreenOrientation.h',
'ScriptSettings.h',
'ShadowRoot.h',
'StructuredCloneHelper.h',
'StructuredCloneHolder.h',
'StructuredCloneTags.h',
'StyleSheetList.h',
'SubtleCrypto.h',
@ -344,7 +344,7 @@ UNIFIED_SOURCES += [
'ScreenOrientation.cpp',
'ScriptSettings.cpp',
'ShadowRoot.cpp',
'StructuredCloneHelper.cpp',
'StructuredCloneHolder.cpp',
'StyleSheetList.cpp',
'SubtleCrypto.cpp',
'Text.cpp',

View File

@ -9,7 +9,7 @@
#include "mozilla/dom/BroadcastChannelBinding.h"
#include "mozilla/dom/Navigator.h"
#include "mozilla/dom/File.h"
#include "mozilla/dom/StructuredCloneHelper.h"
#include "mozilla/dom/StructuredCloneHolder.h"
#include "mozilla/ipc/BackgroundChild.h"
#include "mozilla/ipc/BackgroundUtils.h"
#include "mozilla/ipc/PBackgroundChild.h"
@ -31,13 +31,13 @@ namespace dom {
using namespace workers;
class BroadcastChannelMessage final : public StructuredCloneHelper
class BroadcastChannelMessage final : public StructuredCloneHolder
{
public:
NS_INLINE_DECL_REFCOUNTING(BroadcastChannelMessage)
BroadcastChannelMessage()
: StructuredCloneHelper(CloningSupported, TransferringNotSupported,
: StructuredCloneHolder(CloningSupported, TransferringNotSupported,
DifferentProcess)
{}

View File

@ -34,7 +34,7 @@
#include "mozilla/dom/IDBMutableFileBinding.h"
#include "mozilla/dom/BlobBinding.h"
#include "mozilla/dom/IDBObjectStoreBinding.h"
#include "mozilla/dom/StructuredCloneHelper.h"
#include "mozilla/dom/StructuredCloneHolder.h"
#include "mozilla/dom/StructuredCloneTags.h"
#include "mozilla/dom/indexedDB/PBackgroundIDBSharedTypes.h"
#include "mozilla/dom/ipc/BlobChild.h"
@ -367,7 +367,7 @@ StructuredCloneWriteCallback(JSContext* aCx,
}
}
return StructuredCloneHelper::WriteFullySerializableObjects(aCx, aWriter, aObj);
return StructuredCloneHolder::WriteFullySerializableObjects(aCx, aWriter, aObj);
}
nsresult
@ -893,7 +893,7 @@ CommonStructuredCloneReadCallback(JSContext* aCx,
return result;
}
return StructuredCloneHelper::ReadFullySerializableObjects(aCx, aReader,
return StructuredCloneHolder::ReadFullySerializableObjects(aCx, aReader,
aTag, aData);
}
@ -1109,7 +1109,7 @@ IDBObjectStore::DeserializeValue(JSContext* aCx,
nullptr
};
// FIXME: Consider to use StructuredCloneHelper here and in other
// FIXME: Consider to use StructuredCloneHolder here and in other
// deserializing methods.
if (!JS_ReadStructuredClone(aCx, data, dataLen, JS_STRUCTURED_CLONE_VERSION,
aValue, &callbacks, &aCloneReadInfo)) {

View File

@ -70,7 +70,7 @@ StructuredCloneData::Write(JSContext* aCx,
{
MOZ_ASSERT(!mData);
StructuredCloneHelper::Write(aCx, aValue, aRv);
StructuredCloneHolder::Write(aCx, aValue, aRv);
if (NS_WARN_IF(aRv.Failed())) {
return;
}

View File

@ -7,7 +7,7 @@
#ifndef mozilla_dom_ipc_StructuredCloneData_h
#define mozilla_dom_ipc_StructuredCloneData_h
#include "mozilla/dom/StructuredCloneHelper.h"
#include "mozilla/dom/StructuredCloneHolder.h"
namespace IPC {
class Message;
@ -17,13 +17,13 @@ namespace mozilla {
namespace dom {
namespace ipc {
class StructuredCloneData : public StructuredCloneHelper
class StructuredCloneData : public StructuredCloneHolder
{
public:
StructuredCloneData()
: StructuredCloneHelper(StructuredCloneHelper::CloningSupported,
StructuredCloneHelper::TransferringNotSupported,
StructuredCloneHelper::DifferentProcess)
: StructuredCloneHolder(StructuredCloneHolder::CloningSupported,
StructuredCloneHolder::TransferringNotSupported,
StructuredCloneHolder::DifferentProcess)
, mData(nullptr)
, mDataLength(0)
, mDataOwned(eNone)

View File

@ -46,7 +46,7 @@ SharedMessagePortMessage::Write(JSContext* aCx,
JS::Handle<JS::Value> aTransfer,
ErrorResult& aRv)
{
StructuredCloneHelper::Write(aCx, aValue, aTransfer, aRv);
StructuredCloneHolder::Write(aCx, aValue, aTransfer, aRv);
if (NS_WARN_IF(aRv.Failed())) {
return;
}

View File

@ -6,7 +6,7 @@
#ifndef mozilla_dom_SharedMessagePortMessage_h
#define mozilla_dom_SharedMessagePortMessage_h
#include "mozilla/dom/StructuredCloneHelper.h"
#include "mozilla/dom/StructuredCloneHolder.h"
namespace mozilla {
namespace dom {
@ -15,7 +15,7 @@ class MessagePortChild;
class MessagePortMessage;
class MessagePortParent;
class SharedMessagePortMessage final : public StructuredCloneHelper
class SharedMessagePortMessage final : public StructuredCloneHolder
{
public:
NS_INLINE_DECL_REFCOUNTING(SharedMessagePortMessage)
@ -23,7 +23,7 @@ public:
nsTArray<uint8_t> mData;
SharedMessagePortMessage()
: StructuredCloneHelper(CloningSupported, TransferringSupported,
: StructuredCloneHolder(CloningSupported, TransferringSupported,
DifferentProcess)
{}

View File

@ -1619,8 +1619,8 @@ PromiseWorkerProxy::CleanProperties()
mWorkerPromise = nullptr;
mWorkerPrivate = nullptr;
// Shutdown the StructuredCloneHelperInternal class.
Shutdown();
// Clear the StructuredCloneHolderBase class.
Clear();
}
bool
@ -1692,7 +1692,7 @@ PromiseWorkerProxy::RunCallback(JSContext* aCx,
return;
}
// The |aValue| is written into the StructuredCloneHelperInternal.
// The |aValue| is written into the StructuredCloneHolderBase.
if (!Write(aCx, aValue)) {
JS_ClearPendingException(aCx);
MOZ_ASSERT(false, "cannot serialize the value with the StructuredCloneAlgorithm!");
@ -1757,10 +1757,10 @@ PromiseWorkerProxy::CleanUp(JSContext* aCx)
}
JSObject*
PromiseWorkerProxy::ReadCallback(JSContext* aCx,
JSStructuredCloneReader* aReader,
uint32_t aTag,
uint32_t aIndex)
PromiseWorkerProxy::CustomReadHandler(JSContext* aCx,
JSStructuredCloneReader* aReader,
uint32_t aTag,
uint32_t aIndex)
{
if (NS_WARN_IF(!mCallbacks)) {
return nullptr;
@ -1770,9 +1770,9 @@ PromiseWorkerProxy::ReadCallback(JSContext* aCx,
}
bool
PromiseWorkerProxy::WriteCallback(JSContext* aCx,
JSStructuredCloneWriter* aWriter,
JS::Handle<JSObject*> aObj)
PromiseWorkerProxy::CustomWriteHandler(JSContext* aCx,
JSStructuredCloneWriter* aWriter,
JS::Handle<JSObject*> aObj)
{
if (NS_WARN_IF(!mCallbacks)) {
return false;

View File

@ -10,7 +10,7 @@
// Required for Promise::PromiseTaskSync.
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/PromiseNativeHandler.h"
#include "mozilla/dom/StructuredCloneHelper.h"
#include "mozilla/dom/StructuredCloneHolder.h"
#include "mozilla/dom/workers/bindings/WorkerFeature.h"
#include "nsProxyRelease.h"
@ -113,7 +113,7 @@ class WorkerPrivate;
class PromiseWorkerProxy : public PromiseNativeHandler
, public workers::WorkerFeature
, public StructuredCloneHelperInternal
, public StructuredCloneHolderBase
{
friend class PromiseWorkerProxyRunnable;
@ -169,16 +169,16 @@ public:
return mCleanedUp;
}
// StructuredCloneHelperInternal
// StructuredCloneHolderBase
JSObject* ReadCallback(JSContext* aCx,
JSStructuredCloneReader* aReader,
uint32_t aTag,
uint32_t aIndex) override;
JSObject* CustomReadHandler(JSContext* aCx,
JSStructuredCloneReader* aReader,
uint32_t aTag,
uint32_t aIndex) override;
bool WriteCallback(JSContext* aCx,
JSStructuredCloneWriter* aWriter,
JS::Handle<JSObject*> aObj) override;
bool CustomWriteHandler(JSContext* aCx,
JSStructuredCloneWriter* aWriter,
JS::Handle<JSObject*> aObj) override;
protected:
virtual void ResolvedCallback(JSContext* aCx,

View File

@ -16,7 +16,7 @@
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/PromiseWorkerProxy.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/StructuredCloneHelper.h"
#include "mozilla/dom/StructuredCloneHolder.h"
#include "mozilla/ErrorResult.h"
#include "WorkerPrivate.h"
@ -208,7 +208,7 @@ protected:
// A DataStoreRunnable to run DataStore::Put(...) on the main thread.
class DataStorePutRunnable final : public DataStoreProxyRunnable
, public StructuredCloneHelper
, public StructuredCloneHolder
{
const StringOrUnsignedLong& mId;
const nsString mRevisionId;
@ -224,7 +224,7 @@ public:
const nsAString& aRevisionId,
ErrorResult& aRv)
: DataStoreProxyRunnable(aWorkerPrivate, aBackingStore, aWorkerPromise)
, StructuredCloneHelper(CloningNotSupported, TransferringNotSupported,
, StructuredCloneHolder(CloningNotSupported, TransferringNotSupported,
SameProcessDifferentThread)
, mId(aId)
, mRevisionId(aRevisionId)
@ -270,7 +270,7 @@ protected:
// A DataStoreRunnable to run DataStore::Add(...) on the main thread.
class DataStoreAddRunnable final : public DataStoreProxyRunnable
, public StructuredCloneHelper
, public StructuredCloneHolder
{
const Optional<StringOrUnsignedLong>& mId;
const nsString mRevisionId;
@ -286,7 +286,7 @@ public:
const nsAString& aRevisionId,
ErrorResult& aRv)
: DataStoreProxyRunnable(aWorkerPrivate, aBackingStore, aWorkerPromise)
, StructuredCloneHelper(CloningNotSupported, TransferringNotSupported,
, StructuredCloneHolder(CloningNotSupported, TransferringNotSupported,
SameProcessDifferentThread)
, mId(aId)
, mRevisionId(aRevisionId)

View File

@ -76,13 +76,13 @@ namespace {
class ServiceWorkerClientPostMessageRunnable final
: public nsRunnable
, public StructuredCloneHelper
, public StructuredCloneHolder
{
uint64_t mWindowId;
public:
explicit ServiceWorkerClientPostMessageRunnable(uint64_t aWindowId)
: StructuredCloneHelper(CloningSupported, TransferringSupported,
: StructuredCloneHolder(CloningSupported, TransferringSupported,
SameProcessDifferentThread)
, mWindowId(aWindowId)
{}

View File

@ -58,7 +58,7 @@
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/PromiseDebugging.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/StructuredCloneHelper.h"
#include "mozilla/dom/StructuredCloneHolder.h"
#include "mozilla/dom/TabChild.h"
#include "mozilla/dom/WorkerBinding.h"
#include "mozilla/dom/WorkerDebuggerGlobalScopeBinding.h"
@ -599,7 +599,7 @@ private:
};
class MessageEventRunnable final : public WorkerRunnable
, public StructuredCloneHelper
, public StructuredCloneHolder
{
// This is only used for messages dispatched to a service worker.
nsAutoPtr<ServiceWorkerClientInfo> mEventSource;
@ -608,7 +608,7 @@ public:
MessageEventRunnable(WorkerPrivate* aWorkerPrivate,
TargetAndBusyBehavior aBehavior)
: WorkerRunnable(aWorkerPrivate, aBehavior)
, StructuredCloneHelper(CloningSupported, TransferringSupported,
, StructuredCloneHolder(CloningSupported, TransferringSupported,
SameProcessDifferentThread)
{
}

View File

@ -52,7 +52,7 @@ namespace dom {
class Function;
class MessagePort;
class MessagePortIdentifier;
class StructuredCloneHelper;
class StructuredCloneHolder;
} // namespace dom
namespace ipc {
class PrincipalInfo;

View File

@ -18,7 +18,7 @@
#include "mozilla/dom/Exceptions.h"
#include "mozilla/dom/File.h"
#include "mozilla/dom/ProgressEvent.h"
#include "mozilla/dom/StructuredCloneHelper.h"
#include "mozilla/dom/StructuredCloneHolder.h"
#include "nsComponentManagerUtils.h"
#include "nsContentUtils.h"
#include "nsFormData.h"
@ -251,7 +251,7 @@ private:
class SendRunnable final
: public WorkerThreadProxySyncRunnable
, public StructuredCloneHelper
, public StructuredCloneHolder
{
nsString mStringBody;
nsCOMPtr<nsIEventTarget> mSyncLoopTarget;
@ -261,7 +261,7 @@ public:
SendRunnable(WorkerPrivate* aWorkerPrivate, Proxy* aProxy,
const nsAString& aStringBody)
: WorkerThreadProxySyncRunnable(aWorkerPrivate, aProxy)
, StructuredCloneHelper(CloningSupported, TransferringNotSupported,
, StructuredCloneHolder(CloningSupported, TransferringNotSupported,
SameProcessDifferentThread)
, mStringBody(aStringBody)
, mHasUploadListeners(false)
@ -521,7 +521,7 @@ private:
};
class EventRunnable final : public MainThreadProxyRunnable
, public StructuredCloneHelper
, public StructuredCloneHolder
{
nsString mType;
nsString mResponseType;
@ -567,7 +567,7 @@ public:
EventRunnable(Proxy* aProxy, bool aUploadEvent, const nsString& aType,
bool aLengthComputable, uint64_t aLoaded, uint64_t aTotal)
: MainThreadProxyRunnable(aProxy->mWorkerPrivate, aProxy),
StructuredCloneHelper(CloningSupported, TransferringNotSupported,
StructuredCloneHolder(CloningSupported, TransferringNotSupported,
SameProcessDifferentThread),
mType(aType), mResponse(JS::UndefinedValue()), mLoaded(aLoaded),
mTotal(aTotal), mEventStreamId(aProxy->mInnerEventStreamId), mStatus(0),
@ -578,7 +578,7 @@ public:
EventRunnable(Proxy* aProxy, bool aUploadEvent, const nsString& aType)
: MainThreadProxyRunnable(aProxy->mWorkerPrivate, aProxy),
StructuredCloneHelper(CloningSupported, TransferringNotSupported,
StructuredCloneHolder(CloningSupported, TransferringNotSupported,
SameProcessDifferentThread),
mType(aType), mResponse(JS::UndefinedValue()), mLoaded(0), mTotal(0),
mEventStreamId(aProxy->mInnerEventStreamId), mStatus(0), mReadyState(0),
@ -1333,7 +1333,7 @@ EventRunnable::WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
state->mResponseResult = mResponseResult;
if (NS_SUCCEEDED(mResponseResult)) {
if (HasBeenWritten()) {
if (HasData()) {
MOZ_ASSERT(mResponse.isUndefined());
ErrorResult rv;
@ -1506,7 +1506,7 @@ SendRunnable::MainThreadRun()
{
nsCOMPtr<nsIVariant> variant;
if (HasBeenWritten()) {
if (HasData()) {
AutoSafeJSContext cx;
JSAutoRequest ar(cx);

View File

@ -13,7 +13,7 @@
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/BlobBinding.h"
#include "mozilla/dom/File.h"
#include "mozilla/dom/StructuredCloneHelper.h"
#include "mozilla/dom/StructuredCloneHolder.h"
#ifdef MOZ_NFC
#include "mozilla/dom/MozNDEFRecord.h"
#endif
@ -67,7 +67,7 @@ bool IsFileList(JSObject* obj)
}
class MOZ_STACK_CLASS StackScopedCloneData
: public StructuredCloneHelperInternal
: public StructuredCloneHolderBase
{
public:
StackScopedCloneData(JSContext* aCx, StackScopedCloneOptions* aOptions)
@ -78,13 +78,13 @@ public:
~StackScopedCloneData()
{
Shutdown();
Clear();
}
JSObject* ReadCallback(JSContext* aCx,
JSStructuredCloneReader* aReader,
uint32_t aTag,
uint32_t aData)
JSObject* CustomReadHandler(JSContext* aCx,
JSStructuredCloneReader* aReader,
uint32_t aTag,
uint32_t aData)
{
if (aTag == SCTAG_REFLECTOR) {
MOZ_ASSERT(!aData);
@ -170,9 +170,9 @@ public:
return nullptr;
}
bool WriteCallback(JSContext* aCx,
JSStructuredCloneWriter* aWriter,
JS::Handle<JSObject*> aObj)
bool CustomWriteHandler(JSContext* aCx,
JSStructuredCloneWriter* aWriter,
JS::Handle<JSObject*> aObj)
{
{
Blob* blob = nullptr;