Bug 903772: Part 7 - Remove the worker thread TextEncoder implementation. r=emk
authorKyle Huey <khuey@kylehuey.com>
Thu, 22 Aug 2013 22:17:10 -0700
changeset 144010 3d866e6ca83a609ac1e1435a4fcdecb4899c97d3
parent 144009 dabbf6275092114f9cbfd1f4b2f6283c5089bbc2
child 144011 27ba8b41c4586bb0ea66d5293c4934b090a0387e
push id32843
push userkhuey@mozilla.com
push dateFri, 23 Aug 2013 05:18:28 +0000
treeherdermozilla-inbound@3ab03b70a92c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemk
bugs903772
milestone26.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 903772: Part 7 - Remove the worker thread TextEncoder implementation. r=emk
dom/bindings/Bindings.conf
dom/encoding/TextEncoder.cpp
dom/encoding/TextEncoder.h
dom/workers/DOMBindingInlines.h
dom/workers/TextEncoder.cpp
dom/workers/TextEncoder.h
dom/workers/WorkerScope.cpp
dom/workers/moz.build
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -1168,20 +1168,19 @@ DOMInterfaces = {
     # in fact be cast to Text.
     'headerFile': 'nsTextNode.h',
 },
 
 'TextDecoder': {
     'nativeOwnership': 'owned',
 },
 
-'TextEncoder': [
-{
-    'workers': True,
-}],
+'TextEncoder': {
+    'nativeOwnership': 'owned',
+},
 
 'TextMetrics': {
     'wrapperCache': False,
     'nativeOwnership': 'owned',
 },
 
 'TimeEvent': {
     'nativeType': 'nsDOMTimeEvent',
--- a/dom/encoding/TextEncoder.cpp
+++ b/dom/encoding/TextEncoder.cpp
@@ -103,15 +103,10 @@ TextEncoderBase::Encode(JSContext* aCx,
 
 void
 TextEncoderBase::GetEncoding(nsAString& aEncoding)
 {
   CopyASCIItoUTF16(mEncoding, aEncoding);
   nsContentUtils::ASCIIToLower(aEncoding);
 }
 
-NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(TextEncoder, AddRef)
-NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(TextEncoder, Release)
-
-NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(TextEncoder, mGlobal)
-
 } // dom
 } // mozilla
--- a/dom/encoding/TextEncoder.h
+++ b/dom/encoding/TextEncoder.h
@@ -1,73 +1,68 @@
 /* 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_textencoder_h_
 #define mozilla_dom_textencoder_h_
 
+#include "mozilla/dom/NonRefcountedDOMObject.h"
 #include "mozilla/dom/TextEncoderBase.h"
 #include "mozilla/dom/TextEncoderBinding.h"
 
 namespace mozilla {
 namespace dom {
 
 class TextEncoder MOZ_FINAL
-  : public nsWrapperCache, public TextEncoderBase
+  : public NonRefcountedDOMObject, public TextEncoderBase
 {
 public:
-  NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(TextEncoder)
-  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(TextEncoder)
+  // The WebIDL constructor.
 
-  // The WebIDL constructor.
-  static already_AddRefed<TextEncoder>
+  static TextEncoder*
   Constructor(const GlobalObject& aGlobal,
               const nsAString& aEncoding,
               ErrorResult& aRv)
   {
-    nsRefPtr<TextEncoder> txtEncoder = new TextEncoder(aGlobal.GetAsSupports());
+    nsAutoPtr<TextEncoder> txtEncoder(new TextEncoder());
     txtEncoder->Init(aEncoding, aRv);
     if (aRv.Failed()) {
       return nullptr;
     }
     return txtEncoder.forget();
   }
 
-  TextEncoder(nsISupports* aGlobal)
-    : mGlobal(aGlobal)
+  TextEncoder()
   {
-    MOZ_ASSERT(aGlobal);
-    SetIsDOMBinding();
   }
 
   virtual
   ~TextEncoder()
   {}
 
-  virtual JSObject* WrapObject(JSContext* aCx,
-                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
+  JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope,
+                       bool* aTookOwnership)
   {
-    return TextEncoderBinding::Wrap(aCx, aScope, this);
+    return TextEncoderBinding::Wrap(aCx, aScope, this, aTookOwnership);
   }
 
   nsISupports*
   GetParentObject()
   {
-    return mGlobal;
+    return nullptr;
   }
 
   JSObject* Encode(JSContext* aCx,
                    JS::Handle<JSObject*> aObj,
                    const nsAString& aString,
                    const TextEncodeOptions& aOptions,
                    ErrorResult& aRv) {
     return TextEncoderBase::Encode(aCx, aObj, aString, aOptions.mStream, aRv);
   }
 
 private:
-  nsCOMPtr<nsISupports> mGlobal;
 };
 
 } // dom
 } // mozilla
 
 #endif // mozilla_dom_textencoder_h_
--- a/dom/workers/DOMBindingInlines.h
+++ b/dom/workers/DOMBindingInlines.h
@@ -2,26 +2,24 @@
 /* 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_workers_dombindinginlines_h__
 #define mozilla_dom_workers_dombindinginlines_h__
 
 #include "mozilla/dom/FileReaderSyncBinding.h"
-#include "mozilla/dom/TextEncoderBinding.h"
 #include "mozilla/dom/XMLHttpRequestBinding.h"
 #include "mozilla/dom/XMLHttpRequestUploadBinding.h"
 #include "mozilla/dom/WorkerLocationBinding.h"
 #include "mozilla/dom/WorkerNavigatorBinding.h"
 
 BEGIN_WORKERS_NAMESPACE
 
 class FileReaderSync;
-class TextEncoder;
 class XMLHttpRequest;
 class XMLHttpRequestUpload;
 class WorkerLocation;
 class WorkerNavigator;
 
 namespace {
 
 template <class T>
@@ -45,17 +43,16 @@ struct WrapPrototypeTraits
     GetProtoObject(JSContext* aCx, JS::Handle<JSObject*> aGlobal)              \
     {                                                                          \
       using namespace mozilla::dom;                                            \
       return _class##Binding_workers::GetProtoObject(aCx, aGlobal);            \
     }                                                                          \
   };
 
 SPECIALIZE_PROTO_TRAITS(FileReaderSync)
-SPECIALIZE_PROTO_TRAITS(TextEncoder)
 SPECIALIZE_PROTO_TRAITS(XMLHttpRequest)
 SPECIALIZE_PROTO_TRAITS(XMLHttpRequestUpload)
 SPECIALIZE_PROTO_TRAITS(WorkerLocation)
 SPECIALIZE_PROTO_TRAITS(WorkerNavigator)
 
 #undef SPECIALIZE_PROTO_TRAITS
 
 } // anonymous namespace
deleted file mode 100644
--- a/dom/workers/TextEncoder.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/* -*- 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/. */
-
-#include "TextEncoder.h"
-#include "DOMBindingInlines.h"
-
-USING_WORKERS_NAMESPACE
-using mozilla::ErrorResult;
-using mozilla::dom::GlobalObject;
-
-void
-TextEncoder::_trace(JSTracer* aTrc)
-{
-  DOMBindingBase::_trace(aTrc);
-}
-
-void
-TextEncoder::_finalize(JSFreeOp* aFop)
-{
-  DOMBindingBase::_finalize(aFop);
-}
-
-// static
-TextEncoder*
-TextEncoder::Constructor(const GlobalObject& aGlobal,
-                         const nsAString& aEncoding,
-                         ErrorResult& aRv)
-{
-  nsRefPtr<TextEncoder> txtEncoder = new TextEncoder(aGlobal.GetContext());
-  txtEncoder->Init(aEncoding, aRv);
-  if (aRv.Failed()) {
-    return nullptr;
-  }
-
-  if (!Wrap(aGlobal.GetContext(), aGlobal.Get(), txtEncoder)) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return nullptr;
-  }
-
-  return txtEncoder;
-}
deleted file mode 100644
--- a/dom/workers/TextEncoder.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
-/* 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_workers_textencoder_h_
-#define mozilla_dom_workers_textencoder_h_
-
-#include "mozilla/dom/TextEncoderBase.h"
-#include "mozilla/dom/workers/bindings/DOMBindingBase.h"
-#include "mozilla/dom/TextEncoderBinding.h"
-
-BEGIN_WORKERS_NAMESPACE
-
-class TextEncoder MOZ_FINAL : public DOMBindingBase,
-                              public TextEncoderBase
-{
-protected:
-  TextEncoder(JSContext* aCx)
-  : DOMBindingBase(aCx)
-  {}
-
-  virtual
-  ~TextEncoder()
-  {}
-
-public:
-  virtual void
-  _trace(JSTracer* aTrc) MOZ_OVERRIDE;
-
-  virtual void
-  _finalize(JSFreeOp* aFop) MOZ_OVERRIDE;
-
-  static TextEncoder*
-  Constructor(const GlobalObject& aGlobal,
-              const nsAString& aEncoding,
-              ErrorResult& aRv);
-
-  JSObject*
-  Encode(JSContext* aCx,
-         JS::Handle<JSObject*> aObj,
-         const nsAString& aString,
-         const TextEncodeOptions& aOptions,
-         ErrorResult& aRv) {
-    return TextEncoderBase::Encode(aCx, aObj, aString, aOptions.mStream, aRv);
-  }
-};
-
-END_WORKERS_NAMESPACE
-
-#endif // mozilla_dom_workers_textencoder_h_
--- a/dom/workers/WorkerScope.cpp
+++ b/dom/workers/WorkerScope.cpp
@@ -1016,17 +1016,17 @@ CreateDedicatedWorkerGlobalScope(JSConte
       !exceptions::InitClasses(aCx, global)) {
     return NULL;
   }
 
   // Init other paris-bindings.
   if (!FileReaderSyncBinding_workers::GetConstructorObject(aCx, global) ||
       !ImageDataBinding::GetConstructorObject(aCx, global) ||
       !TextDecoderBinding::GetConstructorObject(aCx, global) ||
-      !TextEncoderBinding_workers::GetConstructorObject(aCx, global) ||
+      !TextEncoderBinding::GetConstructorObject(aCx, global) ||
       !XMLHttpRequestBinding_workers::GetConstructorObject(aCx, global) ||
       !XMLHttpRequestUploadBinding_workers::GetConstructorObject(aCx, global) ||
       !URLBinding_workers::GetConstructorObject(aCx, global) ||
       !WorkerLocationBinding_workers::GetConstructorObject(aCx, global) ||
       !WorkerNavigatorBinding_workers::GetConstructorObject(aCx, global)) {
     return NULL;
   }
 
--- a/dom/workers/moz.build
+++ b/dom/workers/moz.build
@@ -16,17 +16,16 @@ EXPORTS.mozilla.dom.workers += [
 # Stuff needed for the bindings, not really public though.
 EXPORTS.mozilla.dom.workers.bindings += [
     'DOMBindingBase.h',
     'EventListenerManager.h',
     'EventTarget.h',
     'FileReaderSync.h',
     'Location.h',
     'Navigator.h',
-    'TextEncoder.h',
     'URL.h',
     'WorkerFeature.h',
     'XMLHttpRequest.h',
     'XMLHttpRequestEventTarget.h',
     'XMLHttpRequestUpload.h',
 ]
 
 CPP_SOURCES += [
@@ -38,17 +37,16 @@ CPP_SOURCES += [
     'Exceptions.cpp',
     'File.cpp',
     'FileReaderSync.cpp',
     'Location.cpp',
     'Navigator.cpp',
     'Principal.cpp',
     'RuntimeService.cpp',
     'ScriptLoader.cpp',
-    'TextEncoder.cpp',
     'URL.cpp',
     'Worker.cpp',
     'WorkerPrivate.cpp',
     'WorkerScope.cpp',
     'XMLHttpRequest.cpp',
     'XMLHttpRequestEventTarget.cpp',
     'XMLHttpRequestUpload.cpp',
 ]