Bug 1209919 - Improving naming and comments in StructuredCloneHelper, r=smaug
authorAndrea Marchesini <amarchesini@mozilla.com>
Wed, 30 Sep 2015 13:22:08 +0100
changeset 300388 2f694f107db9485760df79d7b2432d9b57807a7c
parent 300387 2ef1cb1059ff03ead6c518ef9d09a106c751abd9
child 300389 f2f8cb92dce4ad314b3336f054f0609fdf8dbecc
child 300478 40a416eadddfea4831deba1f1185c0bbae5148a0
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1209919
milestone44.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1209919 - Improving naming and comments in StructuredCloneHelper, r=smaug
dom/base/Console.cpp
dom/base/PostMessageEvent.cpp
dom/base/PostMessageEvent.h
dom/base/StructuredCloneHelper.cpp
dom/base/StructuredCloneHelper.h
dom/base/StructuredCloneHolder.cpp
dom/base/StructuredCloneHolder.h
dom/base/moz.build
dom/broadcastchannel/BroadcastChannel.cpp
dom/indexedDB/IDBObjectStore.cpp
dom/ipc/StructuredCloneData.cpp
dom/ipc/StructuredCloneData.h
dom/messagechannel/SharedMessagePortMessage.cpp
dom/messagechannel/SharedMessagePortMessage.h
dom/promise/Promise.cpp
dom/promise/PromiseWorkerProxy.h
dom/workers/DataStore.cpp
dom/workers/ServiceWorkerClient.cpp
dom/workers/WorkerPrivate.cpp
dom/workers/WorkerPrivate.h
dom/workers/XMLHttpRequest.cpp
js/xpconnect/src/ExportHelpers.cpp
--- a/dom/base/Console.cpp
+++ b/dom/base/Console.cpp
@@ -5,17 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/dom/Console.h"
 #include "mozilla/dom/ConsoleBinding.h"
 
 #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"
 #include "nsDocument.h"
 #include "nsDOMNavigationTiming.h"
 #include "nsGlobalWindow.h"
 #include "nsJSUtils.h"
 #include "nsNetUtil.h"
@@ -193,31 +193,31 @@ public:
   }
 
 private:
   JSContext* mCx;
 };
 
 class ConsoleRunnable : public nsRunnable
                       , public WorkerFeature
-                      , public StructuredCloneHelperInternal
+                      , public StructuredCloneHolderBase
 {
 public:
   explicit ConsoleRunnable(Console* aConsole)
     : mWorkerPrivate(GetCurrentThreadWorkerPrivate())
     , mConsole(aConsole)
   {
     MOZ_ASSERT(mWorkerPrivate);
   }
 
   virtual
   ~ConsoleRunnable()
   {
-    // Shutdown the StructuredCloneHelperInternal class.
-    Shutdown();
+    // Clear the StructuredCloneHolderBase class.
+    Clear();
   }
 
   bool
   Dispatch()
   {
     mWorkerPrivate->AssertIsOnWorkerThread();
 
     JSContext* cx = mWorkerPrivate->GetJSContext();
@@ -347,20 +347,20 @@ private:
 protected:
   virtual bool
   PreDispatch(JSContext* aCx) = 0;
 
   virtual void
   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();
 
     if (aTag == CONSOLE_TAG_BLOB) {
       MOZ_ASSERT(mClonedData.mBlobs.Length() > aIndex);
 
       JS::Rooted<JS::Value> val(aCx);
       {
@@ -373,19 +373,19 @@ protected:
 
       return &val.toObject();
     }
 
     MOZ_CRASH("No other tags are supported.");
     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)) &&
         blob->Impl()->MayBeClonedToOtherThreads()) {
       if (!JS_WriteUint32Pair(aWriter, CONSOLE_TAG_BLOB,
                               mClonedData.mBlobs.Length())) {
         return false;
       }
--- a/dom/base/PostMessageEvent.cpp
+++ b/dom/base/PostMessageEvent.cpp
@@ -24,17 +24,17 @@
 namespace mozilla {
 namespace dom {
 
 PostMessageEvent::PostMessageEvent(nsGlobalWindow* aSource,
                                    const nsAString& aCallerOrigin,
                                    nsGlobalWindow* aTargetWindow,
                                    nsIPrincipal* aProvidedPrincipal,
                                    bool aTrustedCaller)
-: StructuredCloneHelper(CloningSupported, TransferringSupported,
+: StructuredCloneHolder(CloningSupported, TransferringSupported,
                         SameProcessSameThread),
   mSource(aSource),
   mCallerOrigin(aCallerOrigin),
   mTargetWindow(aTargetWindow),
   mProvidedPrincipal(aProvidedPrincipal),
   mTrustedCaller(aTrustedCaller)
 {
   MOZ_COUNT_CTOR(PostMessageEvent);
--- a/dom/base/PostMessageEvent.h
+++ b/dom/base/PostMessageEvent.h
@@ -2,17 +2,17 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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_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"
 #include "nsThreadUtils.h"
 
 class nsGlobalWindow;
 class nsIPrincipal;
 class nsPIDOMWindow;
@@ -20,17 +20,17 @@ class nsPIDOMWindow;
 namespace mozilla {
 namespace dom {
 
 /**
  * Class used to represent events generated by calls to Window.postMessage,
  * which asynchronously creates and dispatches events.
  */
 class PostMessageEvent final : public nsRunnable
-                             , public StructuredCloneHelper
+                             , public StructuredCloneHolder
 {
 public:
   NS_DECL_NSIRUNNABLE
 
   PostMessageEvent(nsGlobalWindow* aSource,
                    const nsAString& aCallerOrigin,
                    nsGlobalWindow* aTargetWindow,
                    nsIPrincipal* aProvidedPrincipal,
rename from dom/base/StructuredCloneHelper.cpp
rename to dom/base/StructuredCloneHolder.cpp
--- a/dom/base/StructuredCloneHelper.cpp
+++ b/dom/base/StructuredCloneHolder.cpp
@@ -1,15 +1,15 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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"
 #include "mozilla/dom/BlobBinding.h"
 #include "mozilla/dom/CryptoKey.h"
 #include "mozilla/dom/File.h"
 #include "mozilla/dom/FileList.h"
 #include "mozilla/dom/FileListBinding.h"
@@ -50,78 +50,79 @@ namespace dom {
 namespace {
 
 JSObject*
 StructuredCloneCallbacksRead(JSContext* aCx,
                              JSStructuredCloneReader* aReader,
                              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
 StructuredCloneCallbacksWrite(JSContext* aCx,
                               JSStructuredCloneWriter* aWriter,
                               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
 StructuredCloneCallbacksReadTransfer(JSContext* aCx,
                                      JSStructuredCloneReader* aReader,
                                      uint32_t aTag,
                                      void* aContent,
                                      uint64_t aExtraData,
                                      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
 StructuredCloneCallbacksWriteTransfer(JSContext* aCx,
                                       JS::Handle<JSObject*> aObj,
                                       void* aClosure,
                                       // Output:
                                       uint32_t* aTag,
                                       JS::TransferableOwnership* aOwnership,
                                       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
 StructuredCloneCallbacksFreeTransfer(uint32_t aTag,
                                      JS::TransferableOwnership aOwnership,
                                      void* aContent,
                                      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
 StructuredCloneCallbacksError(JSContext* aCx,
                               uint32_t aErrorId)
 {
   NS_WARNING("Failed to clone data.");
 }
@@ -132,229 +133,229 @@ const JSStructuredCloneCallbacks gCallba
   StructuredCloneCallbacksError,
   StructuredCloneCallbacksReadTransfer,
   StructuredCloneCallbacksWriteTransfer,
   StructuredCloneCallbacksFreeTransfer
 };
 
 } // 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);
 
   if (!mBuffer->write(aCx, aValue, aTransfer, &gCallbacks, this)) {
     mBuffer = nullptr;
     return false;
   }
 
   return true;
 }
 
 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)
 {
   Write(aCx, aValue, JS::UndefinedHandleValue, aRv);
 }
 
 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);
         return;
       }
     }
   }
 }
 
 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);
   }
 
   // If we are tranferring something, we cannot call 'Read()' more than once.
   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,
                                       JS::MutableHandle<JS::Value> aValue,
                                       ErrorResult& aRv)
 {
   ReadFromBuffer(aParent, aCx, aBuffer, aBufferLength,
                  JS_STRUCTURED_CLONE_VERSION, aValue, aRv);
 }
 
 void
-StructuredCloneHelper::ReadFromBuffer(nsISupports* aParent,
+StructuredCloneHolder::ReadFromBuffer(nsISupports* aParent,
                                       JSContext* aCx,
                                       uint64_t* aBuffer,
                                       size_t aBufferLength,
                                       uint32_t aAlgorithmVersion,
                                       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().");
   MOZ_ASSERT(aBuffer);
 
   mozilla::AutoRestore<nsISupports*> guard(mParent);
   mParent = aParent;
 
   if (!JS_ReadStructuredClone(aCx, aBuffer, aBufferLength, aAlgorithmVersion,
                               aValue, &gCallbacks, this)) {
     JS_ClearPendingException(aCx);
     aRv.Throw(NS_ERROR_DOM_DATA_CLONE_ERR);
   }
 }
 
 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().");
 
   if (NS_WARN_IF(!aArray.SetLength(BufferSize(), mozilla::fallible))) {
     aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
     return;
   }
@@ -364,28 +365,28 @@ StructuredCloneHelper::MoveBufferDataToA
   mBuffer->steal(&buffer, &size);
   mBuffer = nullptr;
 
   memcpy(aArray.Elements(), buffer, size);
   js_free(buffer);
 }
 
 void
-StructuredCloneHelper::FreeBuffer(uint64_t* aBuffer,
+StructuredCloneHolder::FreeBuffer(uint64_t* aBuffer,
                                   size_t aBufferLength)
 {
   MOZ_ASSERT(!mBuffer, "FreeBuffer() must be called without a Write().");
   MOZ_ASSERT(aBuffer);
   MOZ_ASSERT(aBufferLength);
 
   JS_ClearStructuredClone(aBuffer, aBufferLength, &gCallbacks, this, false);
 }
 
 /* static */ JSObject*
-StructuredCloneHelper::ReadFullySerializableObjects(JSContext* aCx,
+StructuredCloneHolder::ReadFullySerializableObjects(JSContext* aCx,
                                                     JSStructuredCloneReader* aReader,
                                                     uint32_t aTag,
                                                     uint32_t aIndex)
 {
   if (aTag == SCTAG_DOM_IMAGEDATA) {
     return ReadStructuredCloneImageData(aCx, aReader);
   }
 
@@ -519,17 +520,17 @@ StructuredCloneHelper::ReadFullySerializ
 #endif
 
   // Don't know what this is. Bail.
   xpc::Throw(aCx, NS_ERROR_DOM_DATA_CLONE_ERR);
   return nullptr;
 }
 
 /* static */ bool
-StructuredCloneHelper::WriteFullySerializableObjects(JSContext* aCx,
+StructuredCloneHolder::WriteFullySerializableObjects(JSContext* aCx,
                                                      JSStructuredCloneWriter* aWriter,
                                                      JS::Handle<JSObject*> aObj)
 {
   // See if this is a ImageData object.
   {
     ImageData* imageData = nullptr;
     if (NS_SUCCEEDED(UNWRAP_OBJECT(ImageData, aObj, imageData))) {
       return WriteStructuredCloneImageData(aCx, aWriter, imageData);
@@ -681,98 +682,98 @@ EnsureBlobForBackgroundManager(BlobImpl*
   }
 
   return blobImpl.forget();
 }
 
 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);
 
   // nsRefPtr<File> needs to go out of scope before toObjectOrNull() is
   // called because the static analysis thinks dereferencing XPCOM objects
   // can GC (because in some cases it can!), and a return statement with a
   // JSObject* type means that JSObject* is on the stack as a raw pointer
   // 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;
     }
   }
 
   return &val.toObject();
 }
 
 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;
   }
 
   return false;
 }
 
 // Read the WriteFileList for the format.
 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
     // for this FileList.
     if (!JS_ReadUint32Pair(aReader, &tag, &offset)) {
       return nullptr;
     }
 
     MOZ_ASSERT(tag == 0);
 
     // |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;
       }
     }
 
     if (!ToJSValue(aCx, fileList, &val)) {
       return nullptr;
     }
@@ -782,81 +783,81 @@ ReadFileList(JSContext* aCx,
 }
 
 // The format of the FileList serialization is:
 // - pair of ints: SCTAG_DOM_FILELIST, Length of the FileList
 // - pair of ints: 0, The offset of the BlobImpl array
 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
   // starting from the offset.
   if (!JS_WriteUint32Pair(aWriter, SCTAG_DOM_FILELIST,
                           aFileList->Length()) ||
       !JS_WriteUint32Pair(aWriter, 0,
-                          aHelper->BlobImpls().Length())) {
+                          aHolder->BlobImpls().Length())) {
     return false;
   }
 
   for (uint32_t i = 0; i < aFileList->Length(); ++i) {
     nsRefPtr<BlobImpl> blobImpl =
       EnsureBlobForBackgroundManager(aFileList->Item(i)->Impl());
     MOZ_ASSERT(blobImpl);
 
-    aHelper->BlobImpls().AppendElement(blobImpl);
+    aHolder->BlobImpls().AppendElement(blobImpl);
   }
 
   return true;
 }
 
 // Read the WriteFormData for the format.
 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) {
       nsAutoString name;
       if (!ReadString(aReader, name)) {
         return nullptr;
       }
 
       uint32_t tag, indexOrLengthOfString;
       if (!JS_ReadUint32Pair(aReader, &tag, &indexOrLengthOfString)) {
         return nullptr;
       }
 
       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);
       } else {
         MOZ_ASSERT(tag == 0);
 
         nsAutoString value;
         value.SetLength(indexOrLengthOfString);
@@ -886,114 +887,114 @@ ReadFormData(JSContext* aCx,
 //     - pair of ints: SCTAG_DOM_BLOB, index of the BlobImpl in the array
 //       mBlobImplArray.
 //   - else:
 //     - pair of ints: 0, string length
 //     - value string
 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())) {
     return false;
   }
 
   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
     Write(const nsString& aName, bool isFile, const nsString& aValue,
           File* aFile, void* aClosure)
     {
       Closure* closure = static_cast<Closure*>(aClosure);
       if (!WriteString(closure->mWriter, aName)) {
         return false;
       }
 
       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;
       }
 
       size_t charSize = sizeof(nsString::char_type);
       if (!JS_WriteUint32Pair(closure->mWriter, 0, aValue.Length()) ||
           !JS_WriteBytes(closure->mWriter, aValue.get(),
                          aValue.Length() * charSize)) {
         return false;
       }
 
       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);
 
   if (aTag == SCTAG_DOM_BLOB) {
     return ReadBlob(aCx, aIndex, this);
   }
 
   if (aTag == SCTAG_DOM_FILELIST) {
     return ReadFileList(aCx, aReader, aIndex, this);
   }
 
   if (aTag == SCTAG_DOM_FORMDATA) {
     return ReadFormData(aCx, aReader, aIndex, this);
   }
 
   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.
     nsCOMPtr<nsIGlobalObject> parent = do_QueryInterface(mParent);
     // aIndex is the index of the cloned image.
     return ImageBitmap::ReadStructuredClone(aCx, aReader,
                                             parent, GetImages(), aIndex);
    }
 
   return ReadFullySerializableObjects(aCx, aReader, aTag, aIndex);
 }
 
 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;
   }
 
   // See if this is a File/Blob object.
   {
     Blob* blob = nullptr;
@@ -1014,36 +1015,36 @@ StructuredCloneHelper::WriteCallback(JSC
   {
     nsFormData* formData = nullptr;
     if (NS_SUCCEEDED(UNWRAP_OBJECT(FormData, aObj, formData))) {
       return WriteFormData(aWriter, formData, this);
     }
   }
 
   // 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,
                                                GetImages(),
                                                imageBitmap);
     }
   }
 
   return WriteFullySerializableObjects(aCx, aWriter, aObj);
 }
 
 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);
 
   if (aTag == SCTAG_DOM_MAP_MESSAGEPORT) {
     // This can be null.
     nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(mParent);
 
     MOZ_ASSERT(aExtraData < mPortIdentifiers.Length());
@@ -1068,22 +1069,22 @@ StructuredCloneHelper::ReadTransferCallb
     aReturnObject.set(&value.toObject());
     return true;
   }
 
   return false;
 }
 
 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;
   }
 
   {
     MessagePort* port = nullptr;
     nsresult rv = UNWRAP_OBJECT(MessagePort, aObj, port);
@@ -1101,20 +1102,20 @@ StructuredCloneHelper::WriteTransferCall
       return true;
     }
   }
 
   return false;
 }
 
 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);
 
   if (aTag == SCTAG_DOM_MAP_MESSAGEPORT) {
     MOZ_ASSERT(!aContent);
     MOZ_ASSERT(aExtraData < mPortIdentifiers.Length());
     MessagePort::ForceClose(mPortIdentifiers[aExtraData]);
   }
rename from dom/base/StructuredCloneHelper.h
rename to dom/base/StructuredCloneHolder.h
--- a/dom/base/StructuredCloneHelper.h
+++ b/dom/base/StructuredCloneHolder.h
@@ -1,15 +1,15 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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"
 #include "nsAutoPtr.h"
 #include "nsISupports.h"
 #include "nsTArray.h"
 
 #ifdef DEBUG
@@ -19,79 +19,84 @@
 namespace mozilla {
 class ErrorResult;
 namespace layers {
 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;
   }
 
   uint64_t* BufferData() const
   {
     MOZ_ASSERT(mBuffer, "Write() has never been called.");
     return mBuffer->data();
@@ -102,25 +107,25 @@ public:
     MOZ_ASSERT(mBuffer, "Write() has never been called.");
     return mBuffer->nbytes();
   }
 
 protected:
   nsAutoPtr<JSAutoStructuredCloneBuffer> mBuffer;
 
 #ifdef DEBUG
-  bool mShutdownCalled;
+  bool mClearCalled;
 #endif
 };
 
 class BlobImpl;
 class MessagePort;
 class MessagePortIdentifier;
 
-class StructuredCloneHelper : public StructuredCloneHelperInternal
+class StructuredCloneHolder : public StructuredCloneHolderBase
 {
 public:
   enum CloningSupport
   {
     CloningSupported,
     CloningNotSupported
   };
 
@@ -140,20 +145,20 @@ public:
   // If cloning is supported, this object will clone objects such as Blobs,
   // FileList, ImageData, etc.
   // If transferring is supported, we will transfer MessagePorts and in the
   // future other transferrable objects.
   // The ContextSupport is useful to know where the cloned/transferred data can
   // 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().
 
   void Write(JSContext* aCx,
              JS::Handle<JS::Value> aValue,
              ErrorResult &aRv);
 
   void Write(JSContext* aCx,
@@ -162,33 +167,36 @@ public:
              ErrorResult &aRv);
 
   void Read(nsISupports* aParent,
             JSContext* aCx,
             JS::MutableHandle<JS::Value> aValue,
             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() ||
            !mClonedImages.IsEmpty();
   }
 
   nsTArray<nsRefPtr<BlobImpl>>& BlobImpls()
   {
     MOZ_ASSERT(mSupportsCloning, "Blobs cannot be taken/set if cloning is not supported.");
     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;
   }
 
   // This must be called if the transferring has ports generated by Read().
   // MessagePorts are not thread-safe and they must be retrieved in the thread
   // where they are created.
@@ -204,45 +212,50 @@ public:
     return mPortIdentifiers;
   }
 
   nsTArray<nsRefPtr<layers::Image>>& GetImages()
   {
     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,
                                                 uint32_t aTag,
                                                 uint32_t aIndex);
 
   static bool  WriteFullySerializableObjects(JSContext* aCx,
                                              JSStructuredCloneWriter* aWriter,
@@ -268,30 +281,28 @@ protected:
                       ErrorResult &aRv);
 
   // Use this method to free a buffer generated by MoveToBuffer().
   void FreeBuffer(uint64_t* aBuffer,
                   size_t aBufferLength);
 
   bool mSupportsCloning;
   bool mSupportsTransferring;
-  ContextSupport mContext;
+  ContextSupport mSupportedContext;
 
-  // Useful for the structured clone algorithm:
-
+  // Used for cloning blobs in the structured cloning algorithm.
   nsTArray<nsRefPtr<BlobImpl>> mBlobImplArray;
 
   // This is used for sharing the backend of ImageBitmaps.
   // The layers::Image object must be thread-safely reference-counted.
   // The layers::Image object will not be written ever via any ImageBitmap
   // 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
   // generated from the mPortIdentifiers array.
   nsTArray<nsRefPtr<MessagePort>> mTransferredPorts;
 
   // This array contains the identifiers of the MessagePorts. Based on these we
   // are able to reconnect the new transferred ports with the other
@@ -301,9 +312,9 @@ protected:
 #ifdef DEBUG
   nsCOMPtr<nsIThread> mCreationThread;
 #endif
 };
 
 } // dom namespace
 } // mozilla namespace
 
-#endif // mozilla_dom_StructuredCloneHelper_h
+#endif // mozilla_dom_StructuredCloneHolder_h
--- a/dom/base/moz.build
+++ b/dom/base/moz.build
@@ -195,17 +195,17 @@ EXPORTS.mozilla.dom += [
     'PerformanceRenderTiming.h',
     'PerformanceResourceTiming.h',
     'ProcessGlobal.h',
     'ResponsiveImageSelector.h',
     'SameProcessMessageQueue.h',
     'ScreenOrientation.h',
     'ScriptSettings.h',
     'ShadowRoot.h',
-    'StructuredCloneHelper.h',
+    'StructuredCloneHolder.h',
     'StructuredCloneTags.h',
     'StyleSheetList.h',
     'SubtleCrypto.h',
     'Text.h',
     'TreeWalker.h',
     'URL.h',
     'URLSearchParams.h',
     'WebSocket.h',
@@ -339,17 +339,17 @@ UNIFIED_SOURCES += [
     'PerformanceResourceTiming.cpp',
     'PostMessageEvent.cpp',
     'ProcessGlobal.cpp',
     'ResponsiveImageSelector.cpp',
     'SameProcessMessageQueue.cpp',
     'ScreenOrientation.cpp',
     'ScriptSettings.cpp',
     'ShadowRoot.cpp',
-    'StructuredCloneHelper.cpp',
+    'StructuredCloneHolder.cpp',
     'StyleSheetList.cpp',
     'SubtleCrypto.cpp',
     'Text.cpp',
     'TextInputProcessor.cpp',
     'ThirdPartyUtil.cpp',
     'TreeWalker.cpp',
     'URL.cpp',
     'URLSearchParams.cpp',
--- a/dom/broadcastchannel/BroadcastChannel.cpp
+++ b/dom/broadcastchannel/BroadcastChannel.cpp
@@ -4,17 +4,17 @@
  * 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 "BroadcastChannel.h"
 #include "BroadcastChannelChild.h"
 #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"
 #include "WorkerPrivate.h"
 #include "WorkerRunnable.h"
 
 #include "nsIDocument.h"
 #include "nsISupportsPrimitives.h"
@@ -26,23 +26,23 @@
 namespace mozilla {
 
 using namespace ipc;
 
 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)
   {}
 
 private:
   ~BroadcastChannelMessage()
   {}
 };
 
--- a/dom/indexedDB/IDBObjectStore.cpp
+++ b/dom/indexedDB/IDBObjectStore.cpp
@@ -29,17 +29,17 @@
 #include "mozilla/dom/BindingUtils.h"
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/dom/DOMStringList.h"
 #include "mozilla/dom/File.h"
 #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"
 #include "mozilla/dom/ipc/BlobParent.h"
 #include "mozilla/dom/ipc/nsIRemoteBlob.h"
 #include "mozilla/ipc/BackgroundChild.h"
 #include "mozilla/ipc/PBackgroundSharedTypes.h"
 #include "nsCOMPtr.h"
@@ -362,17 +362,17 @@ StructuredCloneWriteCallback(JSContext* 
         newBlobOrMutableFile =
           cloneWriteInfo->mBlobOrMutableFiles.AppendElement();
       newBlobOrMutableFile->mBlob = blob;
 
       return true;
     }
   }
 
-  return StructuredCloneHelper::WriteFullySerializableObjects(aCx, aWriter, aObj);
+  return StructuredCloneHolder::WriteFullySerializableObjects(aCx, aWriter, aObj);
 }
 
 nsresult
 GetAddInfoCallback(JSContext* aCx, void* aClosure)
 {
   static const JSStructuredCloneCallbacks kStructuredCloneCallbacks = {
     nullptr /* read */,
     StructuredCloneWriteCallback /* write */,
@@ -888,17 +888,17 @@ CommonStructuredCloneReadCallback(JSCont
                                                     data,
                                                     &result))) {
       return nullptr;
     }
 
     return result;
   }
 
-  return StructuredCloneHelper::ReadFullySerializableObjects(aCx, aReader,
+  return StructuredCloneHolder::ReadFullySerializableObjects(aCx, aReader,
                                                              aTag, aData);
 }
 
 // static
 void
 ClearStructuredCloneBuffer(JSAutoStructuredCloneBuffer& aBuffer)
 {
   if (aBuffer.data()) {
@@ -1104,17 +1104,17 @@ IDBObjectStore::DeserializeValue(JSConte
     CommonStructuredCloneReadCallback<ValueDeserializationHelper>,
     nullptr,
     nullptr,
     nullptr,
     nullptr,
     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)) {
     return false;
   }
 
   return true;
 }
--- a/dom/ipc/StructuredCloneData.cpp
+++ b/dom/ipc/StructuredCloneData.cpp
@@ -65,17 +65,17 @@ StructuredCloneData::Read(JSContext* aCx
 
 void
 StructuredCloneData::Write(JSContext* aCx,
                            JS::Handle<JS::Value> aValue,
                            ErrorResult &aRv)
 {
   MOZ_ASSERT(!mData);
 
-  StructuredCloneHelper::Write(aCx, aValue, aRv);
+  StructuredCloneHolder::Write(aCx, aValue, aRv);
   if (NS_WARN_IF(aRv.Failed())) {
     return;
   }
 
   mBuffer->steal(&mData, &mDataLength);
   mBuffer = nullptr;
   mDataOwned = eJSAllocated;
 }
--- a/dom/ipc/StructuredCloneData.h
+++ b/dom/ipc/StructuredCloneData.h
@@ -2,33 +2,33 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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_ipc_StructuredCloneData_h
 #define mozilla_dom_ipc_StructuredCloneData_h
 
-#include "mozilla/dom/StructuredCloneHelper.h"
+#include "mozilla/dom/StructuredCloneHolder.h"
 
 namespace IPC {
 class Message;
 }
 
 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)
   {}
 
   StructuredCloneData(const StructuredCloneData&) = delete;
 
   ~StructuredCloneData()
--- a/dom/messagechannel/SharedMessagePortMessage.cpp
+++ b/dom/messagechannel/SharedMessagePortMessage.cpp
@@ -41,17 +41,17 @@ SharedMessagePortMessage::Read(nsISuppor
 }
 
 void
 SharedMessagePortMessage::Write(JSContext* aCx,
                                 JS::Handle<JS::Value> aValue,
                                 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;
   }
 
   FallibleTArray<uint8_t> cloneData;
 
   MoveBufferDataToArray(cloneData, aRv);
   if (NS_WARN_IF(aRv.Failed())) {
--- a/dom/messagechannel/SharedMessagePortMessage.h
+++ b/dom/messagechannel/SharedMessagePortMessage.h
@@ -1,34 +1,34 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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_SharedMessagePortMessage_h
 #define mozilla_dom_SharedMessagePortMessage_h
 
-#include "mozilla/dom/StructuredCloneHelper.h"
+#include "mozilla/dom/StructuredCloneHolder.h"
 
 namespace mozilla {
 namespace dom {
 
 class MessagePortChild;
 class MessagePortMessage;
 class MessagePortParent;
 
-class SharedMessagePortMessage final : public StructuredCloneHelper
+class SharedMessagePortMessage final : public StructuredCloneHolder
 {
 public:
   NS_INLINE_DECL_REFCOUNTING(SharedMessagePortMessage)
 
   nsTArray<uint8_t> mData;
 
   SharedMessagePortMessage()
-    : StructuredCloneHelper(CloningSupported, TransferringSupported,
+    : StructuredCloneHolder(CloningSupported, TransferringSupported,
                             DifferentProcess)
   {}
 
   void Read(nsISupports* aParent,
             JSContext* aCx,
             JS::MutableHandle<JS::Value> aValue,
             ErrorResult& aRv);
 
--- a/dom/promise/Promise.cpp
+++ b/dom/promise/Promise.cpp
@@ -1614,18 +1614,18 @@ PromiseWorkerProxy::CleanProperties()
   worker->AssertIsOnWorkerThread();
 #endif
   // Ok to do this unprotected from Create().
   // CleanUp() holds the lock before calling this.
   mCleanedUp = true;
   mWorkerPromise = nullptr;
   mWorkerPrivate = nullptr;
 
-  // Shutdown the StructuredCloneHelperInternal class.
-  Shutdown();
+  // Clear the StructuredCloneHolderBase class.
+  Clear();
 }
 
 bool
 PromiseWorkerProxy::AddRefObject()
 {
   MOZ_ASSERT(mWorkerPrivate);
   mWorkerPrivate->AssertIsOnWorkerThread();
   MOZ_ASSERT(!mFeatureAdded);
@@ -1687,17 +1687,17 @@ PromiseWorkerProxy::RunCallback(JSContex
   MOZ_ASSERT(NS_IsMainThread());
 
   MutexAutoLock lock(Lock());
   // If the worker thread's been cancelled we don't need to resolve the Promise.
   if (CleanedUp()) {
     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!");
   }
 
   nsRefPtr<PromiseWorkerProxyRunnable> runnable =
     new PromiseWorkerProxyRunnable(this, aFunc);
 
@@ -1752,32 +1752,32 @@ PromiseWorkerProxy::CleanUp(JSContext* a
     mWorkerPrivate->RemoveFeature(mWorkerPrivate->GetJSContext(), this);
     mFeatureAdded = false;
     CleanProperties();
   }
   Release();
 }
 
 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;
   }
 
   return mCallbacks->Read(aCx, aReader, this, aTag, aIndex);
 }
 
 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;
   }
 
   return mCallbacks->Write(aCx, aWriter, this, aObj);
 }
 
--- a/dom/promise/PromiseWorkerProxy.h
+++ b/dom/promise/PromiseWorkerProxy.h
@@ -5,17 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_PromiseWorkerProxy_h
 #define mozilla_dom_PromiseWorkerProxy_h
 
 // 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"
 
 #include "WorkerRunnable.h"
 
 namespace mozilla {
 namespace dom {
 
@@ -108,17 +108,17 @@ class WorkerPrivate;
 //
 // Note: If a PromiseWorkerProxy is not cleaned up by a WorkerRunnable - this
 // can happen if the main thread Promise is never fulfilled - it will
 // stay alive till the worker reaches a Canceling state, even if all external
 // references to it are dropped.
 
 class PromiseWorkerProxy : public PromiseNativeHandler
                          , public workers::WorkerFeature
-                         , public StructuredCloneHelperInternal
+                         , public StructuredCloneHolderBase
 {
   friend class PromiseWorkerProxyRunnable;
 
   NS_DECL_THREADSAFE_ISUPPORTS
 
 public:
   typedef JSObject* (*ReadCallbackOp)(JSContext* aCx,
                                       JSStructuredCloneReader* aReader,
@@ -164,26 +164,26 @@ public:
   }
 
   bool CleanedUp() const
   {
     mCleanUpLock.AssertCurrentThreadOwns();
     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,
                                 JS::Handle<JS::Value> aValue) override;
 
   virtual void RejectedCallback(JSContext* aCx,
                                 JS::Handle<JS::Value> aValue) override;
 
--- a/dom/workers/DataStore.cpp
+++ b/dom/workers/DataStore.cpp
@@ -11,17 +11,17 @@
 #include "mozilla/dom/DataStoreCursor.h"
 #include "mozilla/dom/DataStoreChangeEvent.h"
 #include "mozilla/dom/DataStoreBinding.h"
 #include "mozilla/dom/DataStoreImplBinding.h"
 
 #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"
 #include "WorkerRunnable.h"
 #include "WorkerScope.h"
 
 BEGIN_WORKERS_NAMESPACE
 
@@ -203,33 +203,33 @@ protected:
     nsRefPtr<Promise> promise = mBackingStore->Get(mId, mRv);
     promise->AppendNativeHandler(mPromiseWorkerProxy);
     return true;
   }
 };
 
 // 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;
   ErrorResult& mRv;
 
 public:
   DataStorePutRunnable(WorkerPrivate* aWorkerPrivate,
                        const nsMainThreadPtrHandle<DataStore>& aBackingStore,
                        Promise* aWorkerPromise,
                        JSContext* aCx,
                        JS::Handle<JS::Value> aObj,
                        const StringOrUnsignedLong& aId,
                        const nsAString& aRevisionId,
                        ErrorResult& aRv)
     : DataStoreProxyRunnable(aWorkerPrivate, aBackingStore, aWorkerPromise)
-    , StructuredCloneHelper(CloningNotSupported, TransferringNotSupported,
+    , StructuredCloneHolder(CloningNotSupported, TransferringNotSupported,
                             SameProcessDifferentThread)
     , mId(aId)
     , mRevisionId(aRevisionId)
     , mRv(aRv)
   {
     MOZ_ASSERT(aWorkerPrivate);
     aWorkerPrivate->AssertIsOnWorkerThread();
 
@@ -265,33 +265,33 @@ protected:
                                                    mRv);
     promise->AppendNativeHandler(mPromiseWorkerProxy);
     return true;
   }
 };
 
 // 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;
   ErrorResult& mRv;
 
 public:
   DataStoreAddRunnable(WorkerPrivate* aWorkerPrivate,
                        const nsMainThreadPtrHandle<DataStore>& aBackingStore,
                        Promise* aWorkerPromise,
                        JSContext* aCx,
                        JS::Handle<JS::Value> aObj,
                        const Optional<StringOrUnsignedLong>& aId,
                        const nsAString& aRevisionId,
                        ErrorResult& aRv)
     : DataStoreProxyRunnable(aWorkerPrivate, aBackingStore, aWorkerPromise)
-    , StructuredCloneHelper(CloningNotSupported, TransferringNotSupported,
+    , StructuredCloneHolder(CloningNotSupported, TransferringNotSupported,
                             SameProcessDifferentThread)
     , mId(aId)
     , mRevisionId(aRevisionId)
     , mRv(aRv)
   {
     MOZ_ASSERT(aWorkerPrivate);
     aWorkerPrivate->AssertIsOnWorkerThread();
 
--- a/dom/workers/ServiceWorkerClient.cpp
+++ b/dom/workers/ServiceWorkerClient.cpp
@@ -71,23 +71,23 @@ ServiceWorkerClient::WrapObject(JSContex
 {
   return ClientBinding::Wrap(aCx, this, aGivenProto);
 }
 
 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)
   {}
 
   NS_IMETHOD
   Run()
   {
     AssertIsOnMainThread();
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -53,17 +53,17 @@
 #include "mozilla/dom/MessageEventBinding.h"
 #include "mozilla/dom/MessagePort.h"
 #include "mozilla/dom/MessagePortBinding.h"
 #include "mozilla/dom/MessagePortList.h"
 #include "mozilla/dom/PMessagePort.h"
 #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"
 #include "mozilla/dom/WorkerGlobalScopeBinding.h"
 #include "mozilla/dom/indexedDB/IDBFactory.h"
 #include "mozilla/Preferences.h"
 #include "nsAlgorithm.h"
 #include "nsContentUtils.h"
@@ -594,26 +594,26 @@ private:
       JS_ReportPendingException(aCx);
     }
 
     aWorkerPrivate->CloseHandlerFinished();
   }
 };
 
 class MessageEventRunnable final : public WorkerRunnable
-                                 , public StructuredCloneHelper
+                                 , public StructuredCloneHolder
 {
   // This is only used for messages dispatched to a service worker.
   nsAutoPtr<ServiceWorkerClientInfo> mEventSource;
 
 public:
   MessageEventRunnable(WorkerPrivate* aWorkerPrivate,
                        TargetAndBusyBehavior aBehavior)
   : WorkerRunnable(aWorkerPrivate, aBehavior)
-  , StructuredCloneHelper(CloningSupported, TransferringSupported,
+  , StructuredCloneHolder(CloningSupported, TransferringSupported,
                           SameProcessDifferentThread)
   {
   }
 
   void
   SetMessageSource(ServiceWorkerClientInfo* aSource)
   {
     mEventSource = aSource;
--- a/dom/workers/WorkerPrivate.h
+++ b/dom/workers/WorkerPrivate.h
@@ -47,17 +47,17 @@ namespace JS {
 struct RuntimeStats;
 } // namespace JS
 
 namespace mozilla {
 namespace dom {
 class Function;
 class MessagePort;
 class MessagePortIdentifier;
-class StructuredCloneHelper;
+class StructuredCloneHolder;
 } // namespace dom
 namespace ipc {
 class PrincipalInfo;
 } // namespace ipc
 } // namespace mozilla
 
 struct PRThread;
 
--- a/dom/workers/XMLHttpRequest.cpp
+++ b/dom/workers/XMLHttpRequest.cpp
@@ -13,17 +13,17 @@
 #include "nsIXMLHttpRequest.h"
 #include "nsIXPConnect.h"
 
 #include "jsfriendapi.h"
 #include "mozilla/ArrayUtils.h"
 #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"
 #include "nsJSUtils.h"
 #include "nsThreadUtils.h"
 
 #include "RuntimeService.h"
 #include "WorkerPrivate.h"
@@ -246,27 +246,27 @@ protected:
   MainThreadRun() = 0;
 
 private:
   NS_DECL_NSIRUNNABLE
 };
 
 class SendRunnable final
   : public WorkerThreadProxySyncRunnable
-  , public StructuredCloneHelper
+  , public StructuredCloneHolder
 {
   nsString mStringBody;
   nsCOMPtr<nsIEventTarget> mSyncLoopTarget;
   bool mHasUploadListeners;
 
 public:
   SendRunnable(WorkerPrivate* aWorkerPrivate, Proxy* aProxy,
                const nsAString& aStringBody)
   : WorkerThreadProxySyncRunnable(aWorkerPrivate, aProxy)
-  , StructuredCloneHelper(CloningSupported, TransferringNotSupported,
+  , StructuredCloneHolder(CloningSupported, TransferringNotSupported,
                           SameProcessDifferentThread)
   , mStringBody(aStringBody)
   , mHasUploadListeners(false)
   {
   }
 
   void SetHaveUploadListeners(bool aHasUploadListeners)
   {
@@ -516,17 +516,17 @@ public:
 private:
   ~LoadStartDetectionRunnable()
   {
     AssertIsOnMainThread();
     }
 };
 
 class EventRunnable final : public MainThreadProxyRunnable
-                          , public StructuredCloneHelper
+                          , public StructuredCloneHolder
 {
   nsString mType;
   nsString mResponseType;
   JS::Heap<JS::Value> mResponse;
   nsString mResponseText;
   nsString mResponseURL;
   nsCString mStatusText;
   uint64_t mLoaded;
@@ -562,28 +562,28 @@ public:
       JS_CallValueTracer(aTrc, &mStateData->mResponse,
                          "XMLHttpRequest::StateData::mResponse");
     }
   };
 
   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),
     mReadyState(0), mUploadEvent(aUploadEvent), mProgressEvent(true),
     mLengthComputable(aLengthComputable), mUseCachedArrayBufferResponse(false),
     mResponseTextResult(NS_OK), mStatusResult(NS_OK), mResponseResult(NS_OK)
   { }
 
   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),
     mUploadEvent(aUploadEvent), mProgressEvent(false), mLengthComputable(0),
     mUseCachedArrayBufferResponse(false), mResponseTextResult(NS_OK),
     mStatusResult(NS_OK), mResponseResult(NS_OK)
   { }
 
@@ -1328,17 +1328,17 @@ EventRunnable::WorkerRun(JSContext* aCx,
     MOZ_ASSERT(mResponse.isUndefined() || mResponse.isNull());
     state->mResponseResult = mResponseTextResult;
     state->mResponse = mResponse;
   }
   else {
     state->mResponseResult = mResponseResult;
 
     if (NS_SUCCEEDED(mResponseResult)) {
-      if (HasBeenWritten()) {
+      if (HasData()) {
         MOZ_ASSERT(mResponse.isUndefined());
 
         ErrorResult rv;
         JS::Rooted<JS::Value> response(aCx);
         Read(nullptr, aCx, &response, rv);
         if (NS_WARN_IF(rv.Failed())) {
           rv.SuppressException();
           return false;
@@ -1501,17 +1501,17 @@ OpenRunnable::MainThreadRunInternal()
 }
 
 
 nsresult
 SendRunnable::MainThreadRun()
 {
   nsCOMPtr<nsIVariant> variant;
 
-  if (HasBeenWritten()) {
+  if (HasData()) {
     AutoSafeJSContext cx;
     JSAutoRequest ar(cx);
 
     nsIXPConnect* xpc = nsContentUtils::XPConnect();
     MOZ_ASSERT(xpc);
 
     ErrorResult rv;
 
--- a/js/xpconnect/src/ExportHelpers.cpp
+++ b/js/xpconnect/src/ExportHelpers.cpp
@@ -8,17 +8,17 @@
 #include "WrapperFactory.h"
 #include "AccessCheck.h"
 #include "jsfriendapi.h"
 #include "jswrapper.h"
 #include "js/Proxy.h"
 #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
 #include "nsGlobalWindow.h"
 #include "nsJSUtils.h"
 #include "nsIDOMFileList.h"
 
 using namespace mozilla;
@@ -62,34 +62,34 @@ bool IsFileList(JSObject* obj)
         return false;
     nsCOMPtr<nsIDOMFileList> fileList = do_QueryInterface(supports);
     if (fileList)
         return true;
     return false;
 }
 
 class MOZ_STACK_CLASS StackScopedCloneData
-    : public StructuredCloneHelperInternal
+    : public StructuredCloneHolderBase
 {
 public:
     StackScopedCloneData(JSContext* aCx, StackScopedCloneOptions* aOptions)
         : mOptions(aOptions)
         , mReflectors(aCx)
         , mFunctions(aCx)
     {}
 
     ~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);
 
             size_t idx;
             if (!JS_ReadBytes(aReader, &idx, sizeof(size_t)))
                 return nullptr;
 
@@ -165,19 +165,19 @@ public:
           return nullptr;
 #endif
         }
 
         MOZ_ASSERT_UNREACHABLE("Encountered garbage in the clone stream!");
         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;
             if (NS_SUCCEEDED(UNWRAP_OBJECT(Blob, aObj, blob))) {
                 BlobImpl* blobImpl = blob->Impl();
                 MOZ_ASSERT(blobImpl);
 
                 if (!mBlobImpls.AppendElement(blobImpl))