Bug 1249739 - Improve performance in XHR in workers - part 3 - Implement XMLHttpRequestStringSnapshot, r=smaug
authorAndrea Marchesini <amarchesini@mozilla.com>
Mon, 12 Sep 2016 09:06:33 +0200
changeset 354800 2fc46e5f15dc4492d25c516a12cea1f4af89df97
parent 354799 554d3b443640a216b7c8f8d97d0905db3c115511
child 354801 d95f98dcd8a4514d24be5618362e8e4a7b2a49af
push id6570
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:26:13 +0000
treeherdermozilla-beta@f455459b2ae5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1249739
milestone51.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 1249739 - Improve performance in XHR in workers - part 3 - Implement XMLHttpRequestStringSnapshot, r=smaug
dom/xhr/XMLHttpRequestMainThread.cpp
dom/xhr/XMLHttpRequestMainThread.h
dom/xhr/XMLHttpRequestString.cpp
dom/xhr/XMLHttpRequestString.h
dom/xhr/XMLHttpRequestWorker.cpp
dom/xhr/XMLHttpRequestWorker.h
--- a/dom/xhr/XMLHttpRequestMainThread.cpp
+++ b/dom/xhr/XMLHttpRequestMainThread.cpp
@@ -562,51 +562,62 @@ XMLHttpRequestMainThread::AppendToRespon
   helper.AddLength(destlen);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 XMLHttpRequestMainThread::GetResponseText(nsAString& aResponseText)
 {
   ErrorResult rv;
-  nsString responseText;
-  GetResponseText(responseText, rv);
-  aResponseText = responseText;
+  GetResponseText(aResponseText, rv);
   return rv.StealNSResult();
 }
 
 void
 XMLHttpRequestMainThread::GetResponseText(nsAString& aResponseText,
                                           ErrorResult& aRv)
 {
-  aResponseText.Truncate();
+  XMLHttpRequestStringSnapshot snapshot;
+  GetResponseText(snapshot, aRv);
+  if (aRv.Failed()) {
+    return;
+  }
+
+  snapshot.GetAsString(aResponseText);
+}
+
+void
+XMLHttpRequestMainThread::GetResponseText(XMLHttpRequestStringSnapshot& aSnapshot,
+                                          ErrorResult& aRv)
+{
+  aSnapshot.Reset();
 
   if (mResponseType != XMLHttpRequestResponseType::_empty &&
       mResponseType != XMLHttpRequestResponseType::Text &&
       mResponseType != XMLHttpRequestResponseType::Moz_chunked_text) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return;
   }
 
   if (mResponseType == XMLHttpRequestResponseType::Moz_chunked_text &&
       !mInLoadProgressEvent) {
-    aResponseText.SetIsVoid(true);
+    aSnapshot.SetVoid();
     return;
   }
 
   if (mState != State::loading && mState != State::done) {
     return;
   }
 
   // We only decode text lazily if we're also parsing to a doc.
   // Also, if we've decoded all current data already, then no need to decode
   // more.
   if ((!mResponseXML && !mErrorParsingXML) ||
       mResponseBodyDecodedPos == mResponseBody.Length()) {
-    mResponseText.GetAsString(aResponseText);
+    mResponseText.CreateSnapshot(aSnapshot);
     return;
   }
 
   MatchCharsetAndDecoderToResponseDocument();
 
   NS_ASSERTION(mResponseBodyDecodedPos < mResponseBody.Length(),
                "Unexpected mResponseBodyDecodedPos");
   aRv = AppendToResponseText(mResponseBody.get() + mResponseBodyDecodedPos,
@@ -618,17 +629,17 @@ XMLHttpRequestMainThread::GetResponseTex
   mResponseBodyDecodedPos = mResponseBody.Length();
 
   if (mState == State::done) {
     // Free memory buffer which we no longer need
     mResponseBody.Truncate();
     mResponseBodyDecodedPos = 0;
   }
 
-  mResponseText.GetAsString(aResponseText);
+  mResponseText.CreateSnapshot(aSnapshot);
 }
 
 nsresult
 XMLHttpRequestMainThread::CreateResponseParsedJSON(JSContext* aCx)
 {
   if (!aCx) {
     return NS_ERROR_FAILURE;
   }
@@ -741,17 +752,17 @@ XMLHttpRequestMainThread::GetResponse(JS
                                       JS::MutableHandle<JS::Value> aResponse,
                                       ErrorResult& aRv)
 {
   switch (mResponseType) {
   case XMLHttpRequestResponseType::_empty:
   case XMLHttpRequestResponseType::Text:
   case XMLHttpRequestResponseType::Moz_chunked_text:
   {
-    nsString str;
+    nsAutoString str;
     aRv = GetResponseText(str);
     if (aRv.Failed()) {
       return;
     }
     if (!xpc::StringToJsval(aCx, str, aResponse)) {
       aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
     }
     return;
--- a/dom/xhr/XMLHttpRequestMainThread.h
+++ b/dom/xhr/XMLHttpRequestMainThread.h
@@ -465,16 +465,20 @@ public:
 
   virtual void
   GetResponse(JSContext* aCx, JS::MutableHandle<JS::Value> aResponse,
               ErrorResult& aRv) override;
 
   virtual void
   GetResponseText(nsAString& aResponseText, ErrorResult& aRv) override;
 
+  void
+  GetResponseText(XMLHttpRequestStringSnapshot& aSnapshot,
+                  ErrorResult& aRv);
+
   virtual nsIDocument*
   GetResponseXML(ErrorResult& aRv) override;
 
   virtual bool
   MozBackgroundRequest() const override;
 
   virtual void
   SetMozBackgroundRequest(bool aMozBackgroundRequest, ErrorResult& aRv) override;
--- a/dom/xhr/XMLHttpRequestString.cpp
+++ b/dom/xhr/XMLHttpRequestString.cpp
@@ -1,60 +1,97 @@
 /* -*- 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 "XMLHttpRequestString.h"
+#include "mozilla/Mutex.h"
 #include "nsISupportsImpl.h"
 
 namespace mozilla {
 namespace dom {
 
 class XMLHttpRequestStringBuffer final
 {
   friend class XMLHttpRequestStringWriterHelper;
+  friend class XMLHttpRequestStringSnapshotReaderHelper;
 
 public:
-  NS_INLINE_DECL_REFCOUNTING(XMLHttpRequestStringBuffer)
+  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(XMLHttpRequestStringBuffer)
+  NS_DECL_OWNINGTHREAD
+
+  XMLHttpRequestStringBuffer()
+    : mMutex("XMLHttpRequestStringBuffer::mMutex")
+  {
+  }
 
   uint32_t
   Length()
   {
+    MutexAutoLock lock(mMutex);
+    return mData.Length();
+  }
+
+  uint32_t
+  UnsafeLength() const
+  {
     return mData.Length();
   }
 
   void
   Append(const nsAString& aString)
   {
+    NS_ASSERT_OWNINGTHREAD(XMLHttpRequestStringBuffer);
+
+    MutexAutoLock lock(mMutex);
     mData.Append(aString);
   }
 
   void
   GetAsString(nsAString& aString)
   {
+    MutexAutoLock lock(mMutex);
     aString = mData;
   }
 
   size_t
   SizeOfThis(MallocSizeOf aMallocSizeOf) const
   {
     return mData.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
   }
 
+  void
+  GetAsString(nsAString& aString, uint32_t aLength)
+  {
+    MutexAutoLock lock(mMutex);
+    MOZ_ASSERT(aLength <= mData.Length());
+    aString.Assign(mData.BeginReading(), aLength);
+  }
+
+  void
+  CreateSnapshot(XMLHttpRequestStringSnapshot& aSnapshot)
+  {
+    MutexAutoLock lock(mMutex);
+    aSnapshot.Set(this, mData.Length());
+  }
+
 private:
   ~XMLHttpRequestStringBuffer()
   {}
 
-  nsString& Data()
+  nsString& UnsafeData()
   {
     return mData;
   }
 
+  Mutex mMutex;
+
+  // The following member variable is protected by mutex.
   nsString mData;
 };
 
 // ---------------------------------------------------------------------------
 // XMLHttpRequestString
 
 XMLHttpRequestString::XMLHttpRequestString()
   : mBuffer(new XMLHttpRequestStringBuffer())
@@ -96,36 +133,122 @@ XMLHttpRequestString::SizeOfThis(MallocS
 }
 
 bool
 XMLHttpRequestString::IsEmpty() const
 {
   return !mBuffer->Length();
 }
 
+void
+XMLHttpRequestString::CreateSnapshot(XMLHttpRequestStringSnapshot& aSnapshot)
+{
+  mBuffer->CreateSnapshot(aSnapshot);
+}
+
+// ---------------------------------------------------------------------------
+// XMLHttpRequestStringSnapshot
+
+XMLHttpRequestStringSnapshot::XMLHttpRequestStringSnapshot()
+  : mLength(0)
+  , mVoid(false)
+{
+}
+
+XMLHttpRequestStringSnapshot::~XMLHttpRequestStringSnapshot()
+{
+}
+
+XMLHttpRequestStringSnapshot&
+XMLHttpRequestStringSnapshot::operator=(const XMLHttpRequestStringSnapshot& aOther)
+{
+  mBuffer = aOther.mBuffer;
+  mLength = aOther.mLength;
+  mVoid = aOther.mVoid;
+  return *this;
+}
+
+void
+XMLHttpRequestStringSnapshot::ResetInternal(bool aIsVoid)
+{
+  mBuffer = nullptr;
+  mLength = 0;
+  mVoid = aIsVoid;
+}
+
+void
+XMLHttpRequestStringSnapshot::Set(XMLHttpRequestStringBuffer* aBuffer,
+                                  uint32_t aLength)
+{
+  MOZ_ASSERT(aBuffer);
+  MOZ_ASSERT(aLength <= aBuffer->UnsafeLength());
+
+  mBuffer = aBuffer;
+  mLength = aLength;
+  mVoid = false;
+}
+
+void
+XMLHttpRequestStringSnapshot::GetAsString(nsAString& aString) const
+{
+  if (mBuffer) {
+    MOZ_ASSERT(!mVoid);
+    mBuffer->GetAsString(aString, mLength);
+    return;
+  }
+
+  aString.Truncate();
+
+  if (mVoid) {
+    aString.SetIsVoid(true);
+  }
+}
+
 // ---------------------------------------------------------------------------
 // XMLHttpRequestStringWriterHelper
 
 XMLHttpRequestStringWriterHelper::XMLHttpRequestStringWriterHelper(XMLHttpRequestString& aString)
   : mBuffer(aString.mBuffer)
+  , mLock(aString.mBuffer->mMutex)
 {
 }
 
 bool
 XMLHttpRequestStringWriterHelper::AddCapacity(int32_t aCapacity)
 {
-  return mBuffer->Data().SetCapacity(mBuffer->Length() + aCapacity, fallible);
+  return mBuffer->UnsafeData().SetCapacity(mBuffer->UnsafeLength() + aCapacity, fallible);
 }
 
 char16_t*
 XMLHttpRequestStringWriterHelper::EndOfExistingData()
 {
-  return mBuffer->Data().BeginWriting() + mBuffer->Length();
+  return mBuffer->UnsafeData().BeginWriting() + mBuffer->UnsafeLength();
 }
 
 void
 XMLHttpRequestStringWriterHelper::AddLength(int32_t aLength)
 {
-  mBuffer->Data().SetLength(mBuffer->Length() + aLength);
+  mBuffer->UnsafeData().SetLength(mBuffer->UnsafeLength() + aLength);
+}
+
+// ---------------------------------------------------------------------------
+// XMLHttpRequestStringReaderHelper
+
+XMLHttpRequestStringSnapshotReaderHelper::XMLHttpRequestStringSnapshotReaderHelper(XMLHttpRequestStringSnapshot& aSnapshot)
+  : mBuffer(aSnapshot.mBuffer)
+  , mLock(aSnapshot.mBuffer->mMutex)
+{
+}
+
+const char16_t*
+XMLHttpRequestStringSnapshotReaderHelper::Buffer() const
+{
+  return mBuffer->UnsafeData().BeginReading();
+}
+
+uint32_t
+XMLHttpRequestStringSnapshotReaderHelper::Length() const
+{
+  return mBuffer->UnsafeLength();
 }
 
 } // dom namespace
 } // mozilla namespace
--- a/dom/xhr/XMLHttpRequestString.h
+++ b/dom/xhr/XMLHttpRequestString.h
@@ -5,61 +5,156 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_XMLHttpRequestString_h
 #define mozilla_dom_XMLHttpRequestString_h
 
 #include "nsString.h"
 
 namespace mozilla {
+
+class Mutex;
+
 namespace dom {
 
 class XMLHttpRequestStringBuffer;
+class XMLHttpRequestStringSnapshot;
 class XMLHttpRequestStringWriterHelper;
+class XMLHttpRequestStringSnapshotReaderHelper;
 
+// We want to avoid the dup of strings when XHR in workers has access to
+// responseText for events dispatched during the loading state. For this reason
+// we use this class, able to create snapshots of the current size of itself
+// without making extra copies.
 class XMLHttpRequestString final
 {
   friend class XMLHttpRequestStringWriterHelper;
 
 public:
   XMLHttpRequestString();
   ~XMLHttpRequestString();
 
   void Truncate();
 
   uint32_t Length() const;
 
   void Append(const nsAString& aString);
 
+  // This method should be called only when the string is really needed because
+  // it can cause the duplication of the strings in case the loading of the XHR
+  // is not completed yet.
   void GetAsString(nsAString& aString) const;
 
   size_t SizeOfThis(MallocSizeOf aMallocSizeOf) const;
 
   const char16_t* Data() const;
 
   bool IsEmpty() const;
 
+  void CreateSnapshot(XMLHttpRequestStringSnapshot& aSnapshot);
+
 private:
+  XMLHttpRequestString(const XMLHttpRequestString&) = delete;
+  XMLHttpRequestString& operator=(const XMLHttpRequestString&) = delete;
+  XMLHttpRequestString& operator=(const XMLHttpRequestString&&) = delete;
+
   RefPtr<XMLHttpRequestStringBuffer> mBuffer;
 };
 
-class XMLHttpRequestStringWriterHelper final
+// This class locks the buffer and allows the callee to write data into it.
+class MOZ_STACK_CLASS XMLHttpRequestStringWriterHelper final
 {
 public:
   explicit XMLHttpRequestStringWriterHelper(XMLHttpRequestString& aString);
 
   bool
   AddCapacity(int32_t aCapacity);
 
   char16_t*
   EndOfExistingData();
 
   void
   AddLength(int32_t aLength);
 
 private:
+  XMLHttpRequestStringWriterHelper(const XMLHttpRequestStringWriterHelper&) = delete;
+  XMLHttpRequestStringWriterHelper& operator=(const XMLHttpRequestStringWriterHelper&) = delete;
+  XMLHttpRequestStringWriterHelper& operator=(const XMLHttpRequestStringWriterHelper&&) = delete;
+
   RefPtr<XMLHttpRequestStringBuffer> mBuffer;
+  MutexAutoLock mLock;
+};
+
+// This class is the internal XMLHttpRequestStringBuffer of the
+// XMLHttpRequestString plus the current length. GetAsString will return the
+// string with that particular length also if the XMLHttpRequestStringBuffer is
+// grown in the meantime.
+class XMLHttpRequestStringSnapshot final
+{
+  friend class XMLHttpRequestStringBuffer;
+  friend class XMLHttpRequestStringSnapshotReaderHelper;
+
+public:
+  XMLHttpRequestStringSnapshot();
+  ~XMLHttpRequestStringSnapshot();
+
+  XMLHttpRequestStringSnapshot& operator=(const XMLHttpRequestStringSnapshot&);
+
+  void Reset()
+  {
+    ResetInternal(false /* isVoid */);
+  }
+
+  void SetVoid()
+  {
+    ResetInternal(true /* isVoid */);
+  }
+
+  bool IsVoid() const
+  {
+    return mVoid;
+  }
+
+  bool IsEmpty() const
+  {
+    return !mLength;
+  }
+
+  void GetAsString(nsAString& aString) const;
+
+private:
+  XMLHttpRequestStringSnapshot(const XMLHttpRequestStringSnapshot&) = delete;
+  XMLHttpRequestStringSnapshot& operator=(const XMLHttpRequestStringSnapshot&&) = delete;
+
+  void Set(XMLHttpRequestStringBuffer* aBuffer, uint32_t aLength);
+
+  void ResetInternal(bool aIsVoid);
+
+  RefPtr<XMLHttpRequestStringBuffer> mBuffer;
+  uint32_t mLength;
+  bool mVoid;
+};
+
+// This class locks the buffer and allows the callee to read data from it.
+class MOZ_STACK_CLASS XMLHttpRequestStringSnapshotReaderHelper final
+{
+public:
+  explicit XMLHttpRequestStringSnapshotReaderHelper(XMLHttpRequestStringSnapshot& aSnapshot);
+
+  const char16_t*
+  Buffer() const;
+
+  uint32_t
+  Length() const;
+
+private:
+  XMLHttpRequestStringSnapshotReaderHelper(const XMLHttpRequestStringSnapshotReaderHelper&) = delete;
+  XMLHttpRequestStringSnapshotReaderHelper& operator=(const XMLHttpRequestStringSnapshotReaderHelper&) = delete;
+  XMLHttpRequestStringSnapshotReaderHelper& operator=(const XMLHttpRequestStringSnapshotReaderHelper&&) = delete;
+
+  RefPtr<XMLHttpRequestStringBuffer> mBuffer;
+  MutexAutoLock mLock;
 };
 
 } // dom namespace
 } // mozilla namespace
 
 #endif // mozilla_dom_XMLHttpRequestString_h
--- a/dom/xhr/XMLHttpRequestWorker.cpp
+++ b/dom/xhr/XMLHttpRequestWorker.cpp
@@ -471,17 +471,17 @@ private:
 };
 
 class EventRunnable final : public MainThreadProxyRunnable
                           , public StructuredCloneHolder
 {
   nsString mType;
   nsString mResponseType;
   JS::Heap<JS::Value> mResponse;
-  nsString mResponseText;
+  XMLHttpRequestStringSnapshot mResponseText;
   nsString mResponseURL;
   nsCString mStatusText;
   uint64_t mLoaded;
   uint64_t mTotal;
   uint32_t mEventStreamId;
   uint32_t mStatus;
   uint16_t mReadyState;
   bool mUploadEvent;
@@ -1124,17 +1124,20 @@ EventRunnable::PreDispatch(WorkerPrivate
 
   RefPtr<XMLHttpRequestMainThread>& xhr = mProxy->mXHR;
   MOZ_ASSERT(xhr);
 
   if (NS_FAILED(xhr->GetResponseType(mResponseType))) {
     MOZ_ASSERT(false, "This should never fail!");
   }
 
-  mResponseTextResult = xhr->GetResponseText(mResponseText);
+  ErrorResult rv;
+  xhr->GetResponseText(mResponseText, rv);
+  mResponseTextResult = rv.StealNSResult();
+
   if (NS_SUCCEEDED(mResponseTextResult)) {
     mResponseResult = mResponseTextResult;
     if (mResponseText.IsVoid()) {
       mResponse.setNull();
     }
   }
   else {
     JS::Rooted<JS::Value> response(cx);
@@ -1167,31 +1170,29 @@ EventRunnable::PreDispatch(WorkerPrivate
             } else {
               mResponseResult = NS_ERROR_OUT_OF_MEMORY;
               doClone = false;
             }
           }
         }
 
         if (doClone) {
-          ErrorResult rv;
           Write(cx, response, transferable, rv);
           if (NS_WARN_IF(rv.Failed())) {
             NS_WARNING("Failed to clone response!");
             mResponseResult = rv.StealNSResult();
             mProxy->mArrayBufferResponseWasTransferred = false;
           }
         }
       }
     }
   }
 
   mStatusResult = xhr->GetStatus(&mStatus);
 
-  ErrorResult rv;
   xhr->GetStatusText(mStatusText, rv);
   MOZ_ASSERT(!rv.Failed());
 
   mReadyState = xhr->ReadyState();
 
   xhr->GetResponseURL(mResponseURL);
 
   return true;
@@ -2386,20 +2387,21 @@ XMLHttpRequestWorker::GetResponse(JSCont
   if (NS_SUCCEEDED(mStateData.mResponseTextResult) &&
       mStateData.mResponse.isUndefined()) {
     MOZ_ASSERT(NS_SUCCEEDED(mStateData.mResponseResult));
 
     if (mStateData.mResponseText.IsEmpty()) {
       mStateData.mResponse =
         JS_GetEmptyStringValue(mWorkerPrivate->GetJSContext());
     } else {
+      XMLHttpRequestStringSnapshotReaderHelper helper(mStateData.mResponseText);
+
       JSString* str =
         JS_NewUCStringCopyN(mWorkerPrivate->GetJSContext(),
-                            mStateData.mResponseText.get(),
-                            mStateData.mResponseText.Length());
+                            helper.Buffer(), helper.Length());
 
       if (!str) {
         aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
         return;
       }
 
       mStateData.mResponse.setString(str);
     }
@@ -2409,17 +2411,23 @@ XMLHttpRequestWorker::GetResponse(JSCont
   aRv = mStateData.mResponseResult;
   aResponse.set(mStateData.mResponse);
 }
 
 void
 XMLHttpRequestWorker::GetResponseText(nsAString& aResponseText, ErrorResult& aRv)
 {
   aRv = mStateData.mResponseTextResult;
-  aResponseText = mStateData.mResponseText;
+  if (aRv.Failed()) {
+    return;
+  }
+
+  nsAutoString foo;
+  mStateData.mResponseText.GetAsString(foo);
+  aResponseText.Assign(foo.BeginReading(), foo.Length());
 }
 
 void
 XMLHttpRequestWorker::UpdateState(const StateData& aStateData,
                                   bool aUseCachedArrayBufferResponse)
 {
   if (aUseCachedArrayBufferResponse) {
     MOZ_ASSERT(mStateData.mResponse.isObject() &&
--- a/dom/xhr/XMLHttpRequestWorker.h
+++ b/dom/xhr/XMLHttpRequestWorker.h
@@ -4,16 +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/. */
 
 #ifndef mozilla_dom_XMLHttpRequestWorker_h
 #define mozilla_dom_XMLHttpRequestWorker_h
 
 #include "WorkerHolder.h"
 #include "XMLHttpRequest.h"
+#include "XMLHttpRequestString.h"
 #include "mozilla/dom/TypedArray.h"
 
 namespace mozilla {
 namespace dom {
 
 class Proxy;
 class SendRunnable;
 
@@ -22,17 +23,17 @@ class WorkerPrivate;
 }
 
 class XMLHttpRequestWorker final : public XMLHttpRequest,
                                    public workers::WorkerHolder
 {
 public:
   struct StateData
   {
-    nsString mResponseText;
+    XMLHttpRequestStringSnapshot mResponseText;
     nsString mResponseURL;
     uint32_t mStatus;
     nsCString mStatusText;
     uint16_t mReadyState;
     JS::Heap<JS::Value> mResponse;
     nsresult mResponseTextResult;
     nsresult mStatusResult;
     nsresult mResponseResult;
@@ -261,17 +262,17 @@ public:
   }
 
   void
   UpdateState(const StateData& aStateData, bool aUseCachedArrayBufferResponse);
 
   void
   NullResponseText()
   {
-    mStateData.mResponseText.SetIsVoid(true);
+    mStateData.mResponseText.SetVoid();
     mStateData.mResponse.setNull();
   }
 
   virtual bool MozAnon() const override
   {
     return mMozAnon;
   }