Bug 903772: Part 5 - Remove the worker TextDecoder implementation. r=emk
authorKyle Huey <khuey@kylehuey.com>
Thu, 22 Aug 2013 22:17:09 -0700
changeset 156925 94d0b33d4d8a17758ccc556a3560fea674e2ca1a
parent 156924 755b0e538b7a82131923e63d11fdbe4fe1d6e5a2
child 156926 dabbf6275092114f9cbfd1f4b2f6283c5089bbc2
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [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 5 - Remove the worker TextDecoder implementation. r=emk
dom/bindings/Bindings.conf
dom/encoding/TextDecoder.cpp
dom/encoding/TextDecoder.h
dom/workers/DOMBindingInlines.h
dom/workers/TextDecoder.cpp
dom/workers/TextDecoder.h
dom/workers/WorkerScope.cpp
dom/workers/moz.build
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -1164,20 +1164,19 @@ DOMInterfaces = {
 },
 
 'Text': {
     # Total hack to allow binding code to realize that nsTextNode can
     # in fact be cast to Text.
     'headerFile': 'nsTextNode.h',
 },
 
-'TextDecoder': [
-{
-    'workers': True,
-}],
+'TextDecoder': {
+    'nativeOwnership': 'owned',
+},
 
 'TextEncoder': [
 {
     'workers': True,
 }],
 
 'TextMetrics': {
     'wrapperCache': False,
--- a/dom/encoding/TextDecoder.cpp
+++ b/dom/encoding/TextDecoder.cpp
@@ -102,15 +102,10 @@ TextDecoderBase::Decode(const char* aInp
 
 void
 TextDecoderBase::GetEncoding(nsAString& aEncoding)
 {
   CopyASCIItoUTF16(mEncoding, aEncoding);
   nsContentUtils::ASCIIToLower(aEncoding);
 }
 
-NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(TextDecoder, AddRef)
-NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(TextDecoder, Release)
-
-NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(TextDecoder, mGlobal)
-
 } // dom
 } // mozilla
--- a/dom/encoding/TextDecoder.h
+++ b/dom/encoding/TextDecoder.h
@@ -7,58 +7,52 @@
 
 #include "mozilla/dom/TextDecoderBase.h"
 #include "mozilla/dom/TextDecoderBinding.h"
 
 namespace mozilla {
 namespace dom {
 
 class TextDecoder MOZ_FINAL
-  : public nsWrapperCache, public TextDecoderBase
+  : public NonRefcountedDOMObject, public TextDecoderBase
 {
 public:
-  NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(TextDecoder)
-  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(TextDecoder)
-
   // The WebIDL constructor.
-  static already_AddRefed<TextDecoder>
+  static TextDecoder*
   Constructor(const GlobalObject& aGlobal,
               const nsAString& aEncoding,
               const TextDecoderOptions& aOptions,
               ErrorResult& aRv)
   {
-    nsRefPtr<TextDecoder> txtDecoder = new TextDecoder(aGlobalAsSupports.Get());
+    nsAutoPtr<TextDecoder> txtDecoder(new TextDecoder());
     txtDecoder->Init(aEncoding, aOptions.mFatal, aRv);
     if (aRv.Failed()) {
       return nullptr;
     }
     return txtDecoder.forget();
   }
 
-  TextDecoder(nsISupports* aGlobal)
-    : mGlobal(aGlobal)
+  TextDecoder()
   {
-    MOZ_ASSERT(aGlobal);
-    SetIsDOMBinding();
   }
 
   virtual
   ~TextDecoder()
   {}
 
-  virtual JSObject* WrapObject(JSContext* aCx,
-                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
+  JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope,
+                       bool* aTookOwnership)
   {
-    return TextDecoderBinding::Wrap(aCx, aScope, this);
+    return TextDecoderBinding::Wrap(aCx, aScope, this, aTookOwnership);
   }
 
   nsISupports*
   GetParentObject()
   {
-    return mGlobal;
+    return nullptr;
   }
 
   void Decode(nsAString& aOutDecodedString,
               ErrorResult& aRv) {
     TextDecoderBase::Decode(nullptr, 0, false,
                             aOutDecodedString, aRv);
   }
 
@@ -67,15 +61,14 @@ public:
               nsAString& aOutDecodedString,
               ErrorResult& aRv) {
     TextDecoderBase::Decode(reinterpret_cast<char*>(aView.Data()),
                             aView.Length(), aOptions.mStream,
                             aOutDecodedString, aRv);
   }
 
 private:
-  nsCOMPtr<nsISupports> mGlobal;
 };
 
 } // dom
 } // mozilla
 
 #endif // mozilla_dom_textdecoder_h_
--- a/dom/workers/DOMBindingInlines.h
+++ b/dom/workers/DOMBindingInlines.h
@@ -2,27 +2,25 @@
 /* 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/TextDecoderBinding.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 TextDecoder;
 class TextEncoder;
 class XMLHttpRequest;
 class XMLHttpRequestUpload;
 class WorkerLocation;
 class WorkerNavigator;
 
 namespace {
 
@@ -47,17 +45,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(TextDecoder)
 SPECIALIZE_PROTO_TRAITS(TextEncoder)
 SPECIALIZE_PROTO_TRAITS(XMLHttpRequest)
 SPECIALIZE_PROTO_TRAITS(XMLHttpRequestUpload)
 SPECIALIZE_PROTO_TRAITS(WorkerLocation)
 SPECIALIZE_PROTO_TRAITS(WorkerNavigator)
 
 #undef SPECIALIZE_PROTO_TRAITS
 
deleted file mode 100644
--- a/dom/workers/TextDecoder.cpp
+++ /dev/null
@@ -1,45 +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 "TextDecoder.h"
-#include "DOMBindingInlines.h"
-
-USING_WORKERS_NAMESPACE
-using mozilla::ErrorResult;
-using mozilla::dom::TextDecoderOptionsWorkers;
-using mozilla::dom::WorkerGlobalObject;
-
-void
-TextDecoder::_trace(JSTracer* aTrc)
-{
-  DOMBindingBase::_trace(aTrc);
-}
-
-void
-TextDecoder::_finalize(JSFreeOp* aFop)
-{
-  DOMBindingBase::_finalize(aFop);
-}
-
-// static
-TextDecoder*
-TextDecoder::Constructor(const WorkerGlobalObject& aGlobal,
-                         const nsAString& aEncoding,
-                         const TextDecoderOptionsWorkers& aOptions,
-                         ErrorResult& aRv)
-{
-  nsRefPtr<TextDecoder> txtDecoder = new TextDecoder(aGlobal.GetContext());
-  txtDecoder->Init(aEncoding, aOptions.mFatal, aRv);
-  if (aRv.Failed()) {
-    return nullptr;
-  }
-
-  if (!Wrap(aGlobal.GetContext(), aGlobal.Get(), txtDecoder)) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return nullptr;
-  }
-
-  return txtDecoder;
-}
deleted file mode 100644
--- a/dom/workers/TextDecoder.h
+++ /dev/null
@@ -1,60 +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_textdecoder_h_
-#define mozilla_dom_workers_textdecoder_h_
-
-#include "mozilla/dom/TextDecoderBase.h"
-#include "mozilla/dom/workers/bindings/DOMBindingBase.h"
-#include "mozilla/dom/TextDecoderBinding.h"
-
-BEGIN_WORKERS_NAMESPACE
-
-class TextDecoder MOZ_FINAL : public DOMBindingBase,
-                              public TextDecoderBase
-{
-protected:
-  TextDecoder(JSContext* aCx)
-  : DOMBindingBase(aCx)
-  {}
-
-  virtual
-  ~TextDecoder()
-  {}
-
-public:
-  virtual void
-  _trace(JSTracer* aTrc) MOZ_OVERRIDE;
-
-  virtual void
-  _finalize(JSFreeOp* aFop) MOZ_OVERRIDE;
-
-  static TextDecoder*
-  Constructor(const WorkerGlobalObject& aGlobal,
-              const nsAString& aEncoding,
-              const TextDecoderOptionsWorkers& aOptions,
-              ErrorResult& aRv);
-
-  void
-  Decode(nsAString& aOutDecodedString,
-         ErrorResult& aRv) {
-    TextDecoderBase::Decode(nullptr, 0, false,
-                            aOutDecodedString, aRv);
-  }
-
-  void
-  Decode(const ArrayBufferView& aView,
-         const TextDecodeOptionsWorkers& aOptions,
-         nsAString& aOutDecodedString,
-         ErrorResult& aRv) {
-    TextDecoderBase::Decode(reinterpret_cast<char*>(aView.Data()),
-                            aView.Length(), aOptions.mStream,
-                            aOutDecodedString, aRv);
-  }
-};
-
-END_WORKERS_NAMESPACE
-
-#endif // mozilla_dom_workers_textdecoder_h_
--- a/dom/workers/WorkerScope.cpp
+++ b/dom/workers/WorkerScope.cpp
@@ -1015,17 +1015,17 @@ CreateDedicatedWorkerGlobalScope(JSConte
       !file::InitClasses(aCx, global) ||
       !exceptions::InitClasses(aCx, global)) {
     return NULL;
   }
 
   // Init other paris-bindings.
   if (!FileReaderSyncBinding_workers::GetConstructorObject(aCx, global) ||
       !ImageDataBinding::GetConstructorObject(aCx, global) ||
-      !TextDecoderBinding_workers::GetConstructorObject(aCx, global) ||
+      !TextDecoderBinding::GetConstructorObject(aCx, global) ||
       !TextEncoderBinding_workers::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',
-    'TextDecoder.h',
     'TextEncoder.h',
     'URL.h',
     'WorkerFeature.h',
     'XMLHttpRequest.h',
     'XMLHttpRequestEventTarget.h',
     'XMLHttpRequestUpload.h',
 ]
 
@@ -39,17 +38,16 @@ CPP_SOURCES += [
     'Exceptions.cpp',
     'File.cpp',
     'FileReaderSync.cpp',
     'Location.cpp',
     'Navigator.cpp',
     'Principal.cpp',
     'RuntimeService.cpp',
     'ScriptLoader.cpp',
-    'TextDecoder.cpp',
     'TextEncoder.cpp',
     'URL.cpp',
     'Worker.cpp',
     'WorkerPrivate.cpp',
     'WorkerScope.cpp',
     'XMLHttpRequest.cpp',
     'XMLHttpRequestEventTarget.cpp',
     'XMLHttpRequestUpload.cpp',