diff options
Diffstat (limited to 'dom/ipc')
-rw-r--r-- | dom/ipc/StructuredCloneData.cpp | 4 | ||||
-rw-r--r-- | dom/ipc/StructuredCloneData.h | 23 |
2 files changed, 14 insertions, 13 deletions
diff --git a/dom/ipc/StructuredCloneData.cpp b/dom/ipc/StructuredCloneData.cpp index 98f56904f..2c1fff2ac 100644 --- a/dom/ipc/StructuredCloneData.cpp +++ b/dom/ipc/StructuredCloneData.cpp @@ -88,7 +88,7 @@ StructuredCloneData::Write(JSContext* aCx, return; } - JSStructuredCloneData data; + JSStructuredCloneData data(mBuffer->scope()); mBuffer->abandon(); mBuffer->steal(&data); mBuffer = nullptr; @@ -107,7 +107,7 @@ StructuredCloneData::ReadIPCParams(const IPC::Message* aMsg, PickleIterator* aIter) { MOZ_ASSERT(!mInitialized); - JSStructuredCloneData data; + JSStructuredCloneData data(JS::StructuredCloneScope::DifferentProcess); if (!ReadParam(aMsg, aIter, &data)) { return false; } 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(); |