summaryrefslogtreecommitdiffstats
path: root/dom/ipc/StructuredCloneData.h
diff options
context:
space:
mode:
Diffstat (limited to 'dom/ipc/StructuredCloneData.h')
-rw-r--r--dom/ipc/StructuredCloneData.h23
1 files changed, 12 insertions, 11 deletions
diff --git a/dom/ipc/StructuredCloneData.h b/dom/ipc/StructuredCloneData.h
index 9e427e938..64cfd1935 100644
--- a/dom/ipc/StructuredCloneData.h
+++ b/dom/ipc/StructuredCloneData.h
@@ -31,8 +31,8 @@ public:
static already_AddRefed<SharedJSAllocatedData>
CreateFromExternalData(const char* aData, size_t aDataLength)
{
- JSStructuredCloneData buf;
- buf.WriteBytes(aData, aDataLength);
+ JSStructuredCloneData buf(JS::StructuredCloneScope::DifferentProcess);
+ buf.AppendBytes(aData, aDataLength);
RefPtr<SharedJSAllocatedData> sharedData =
new SharedJSAllocatedData(Move(buf));
return sharedData.forget();
@@ -41,12 +41,8 @@ public:
static already_AddRefed<SharedJSAllocatedData>
CreateFromExternalData(const JSStructuredCloneData& aData)
{
- JSStructuredCloneData buf;
- auto iter = aData.Iter();
- while (!iter.Done()) {
- buf.WriteBytes(iter.Data(), iter.RemainingInSegment());
- iter.Advance(aData, iter.RemainingInSegment());
- }
+ JSStructuredCloneData buf(aData.scope());
+ buf.Append(aData);
RefPtr<SharedJSAllocatedData> sharedData =
new SharedJSAllocatedData(Move(buf));
return sharedData.forget();
@@ -70,6 +66,7 @@ public:
: StructuredCloneHolder(StructuredCloneHolder::CloningSupported,
StructuredCloneHolder::TransferringSupported,
StructuredCloneHolder::StructuredCloneScope::DifferentProcess)
+ , mExternalData(StructuredCloneHolder::StructuredCloneScope::DifferentProcess)
, mInitialized(false)
{}
@@ -113,10 +110,9 @@ public:
bool UseExternalData(const JSStructuredCloneData& aData)
{
- auto iter = aData.Iter();
+ auto iter = aData.Start();
bool success = false;
- mExternalData =
- aData.Borrow<js::SystemAllocPolicy>(iter, aData.Size(), &success);
+ mExternalData = aData.Borrow(iter, aData.Size(), &success);
mInitialized = true;
return success;
}
@@ -133,6 +129,11 @@ public:
return mSharedData ? mSharedData->Data() : mExternalData;
}
+ void InitScope(JS::StructuredCloneScope aScope)
+ {
+ Data().initScope(aScope);
+ }
+
size_t DataLength() const
{
return mSharedData ? mSharedData->DataLength() : mExternalData.Size();