Bug 929701 - Part 2: Implement DOMMMIError by C++. r=smaug
authorEdgar Chen <echen@mozilla.com>
Wed, 23 Apr 2014 13:59:47 +0800
changeset 181392 9bff5184e8b692dc46fdfb92231514936673555f
parent 181391 f8d0998c7ec7494ccaa87a4eb3466dff9288d0dc
child 181393 1c1e3bae34ba98351691fbb9de119a7dd11098d6
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewerssmaug
bugs929701
milestone32.0a1
Bug 929701 - Part 2: Implement DOMMMIError by C++. r=smaug
dom/mobileconnection/src/DOMMMIError.cpp
dom/mobileconnection/src/DOMMMIError.h
dom/mobileconnection/src/moz.build
dom/tests/mochitest/general/test_interfaces.html
new file mode 100644
--- /dev/null
+++ b/dom/mobileconnection/src/DOMMMIError.cpp
@@ -0,0 +1,55 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=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 "DOMMMIError.h"
+#include "mozilla/dom/DOMMMIErrorBinding.h"
+
+using namespace mozilla::dom;
+
+NS_IMPL_CYCLE_COLLECTION_CLASS(DOMMMIError)
+
+NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(DOMMMIError, DOMError)
+NS_IMPL_CYCLE_COLLECTION_UNLINK_END
+
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(DOMMMIError, DOMError)
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
+
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(DOMMMIError)
+NS_INTERFACE_MAP_END_INHERITING(DOMError)
+
+NS_IMPL_ADDREF_INHERITED(DOMMMIError, DOMError)
+NS_IMPL_RELEASE_INHERITED(DOMMMIError, DOMError)
+
+DOMMMIError::DOMMMIError(nsPIDOMWindow* aWindow, const nsAString& aName,
+                         const nsAString& aMessage, const nsAString& aServiceCode,
+                         const Nullable<int16_t>& aInfo)
+  : DOMError(aWindow, aName, aMessage)
+  , mServiceCode(aServiceCode)
+  , mInfo(aInfo)
+{
+}
+
+JSObject*
+DOMMMIError::WrapObject(JSContext* aCx)
+{
+  return DOMMMIErrorBinding::Wrap(aCx, this);
+}
+
+// WebIDL interface
+
+/* static */ already_AddRefed<DOMMMIError>
+DOMMMIError::Constructor(const GlobalObject& aGlobal,
+                         const nsAString& aServiceCode,
+                         const nsAString& aName,
+                         const nsAString& aMessage,
+                         const Nullable<int16_t>& aInfo,
+                         ErrorResult& aRv) {
+  nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports());
+  nsRefPtr<DOMMMIError> error = new DOMMMIError(window, aName, aMessage,
+                                                aServiceCode, aInfo);
+
+  return error.forget();
+}
new file mode 100644
--- /dev/null
+++ b/dom/mobileconnection/src/DOMMMIError.h
@@ -0,0 +1,54 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=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_MmiError_h
+#define mozilla_dom_MmiError_h
+
+#include "mozilla/dom/DOMError.h"
+
+namespace mozilla {
+namespace dom {
+
+class DOMMMIError MOZ_FINAL : public DOMError
+{
+public:
+  NS_DECL_ISUPPORTS_INHERITED
+  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DOMMMIError, DOMError)
+
+  DOMMMIError(nsPIDOMWindow* aWindow, const nsAString& aName,
+              const nsAString& aMessage, const nsAString& aServiceCode,
+              const Nullable<int16_t>& aInfo);
+
+  virtual JSObject*
+  WrapObject(JSContext* aCx) MOZ_OVERRIDE;
+
+  // WebIDL interface
+  static already_AddRefed<DOMMMIError>
+  Constructor(const GlobalObject& aGlobal, const nsAString& aServiceCode,
+              const nsAString& aName, const nsAString& aMessage,
+              const Nullable<int16_t>& aInfo, ErrorResult& aRv);
+
+  void
+  GetServiceCode(nsString& aServiceCode) const
+  {
+    aServiceCode = mServiceCode;
+  }
+
+  Nullable<int16_t>
+  GetAdditionalInformation() const
+  {
+    return mInfo;
+  }
+
+private:
+  nsString mServiceCode;
+  Nullable<int16_t> mInfo;
+};
+
+} // namespace dom
+} // namespace mozilla
+
+#endif // mozilla_dom_MmiError_h
--- a/dom/mobileconnection/src/moz.build
+++ b/dom/mobileconnection/src/moz.build
@@ -1,20 +1,22 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # 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/.
 
 EXPORTS.mozilla.dom += [
+    'DOMMMIError.h',
     'MobileConnection.h',
     'MobileConnectionArray.h',
 ]
 
 SOURCES += [
+    'DOMMMIError.cpp',
     'MobileConnection.cpp',
     'MobileConnectionArray.cpp',
 ]
 
 FAIL_ON_WARNINGS = True
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
--- a/dom/tests/mochitest/general/test_interfaces.html
+++ b/dom/tests/mochitest/general/test_interfaces.html
@@ -299,17 +299,17 @@ var interfaceNamesInGlobalScope =
     "DOMCursor",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "DOMError",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "DOMException",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "DOMImplementation",
 // IMPORTANT: Do not change this list without review from a DOM peer!
-    "DOMMMIError",
+    {name: "DOMMMIError", b2g: true, pref: "dom.mobileconnection.enabled"},
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "DOMParser",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "DOMPoint",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "DOMPointReadOnly",
 // IMPORTANT: Do not change this list without review from a DOM peer!
     "DOMQuad",