Bug 1435483 part 3. Remove nsIXPCException. r=qdot
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 05 Feb 2018 16:34:04 -0500
changeset 402466 432d38e262305e84cbb05ca1db5758d40e63202d
parent 402465 4798fb33e87f06c87703fd3a7533e3343e33d603
child 402467 c916ed1fb22e9df7597685e27a02c211902d265b
push id33390
push usernbeleuzu@mozilla.com
push dateTue, 06 Feb 2018 09:55:26 +0000
treeherdermozilla-central@f1a4b64f19b0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersqdot
bugs1435483
milestone60.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 1435483 part 3. Remove nsIXPCException. r=qdot This interface is not usable from JS, because we don't expose initialize() in the WebIDL bindings for Exception. And C++ doesn't use it. MozReview-Commit-ID: LsIm4YA0YZE
caps/nsScriptSecurityManager.cpp
dom/base/DOMException.cpp
dom/base/DOMException.h
js/xpconnect/idl/moz.build
js/xpconnect/idl/xpcexception.idl
js/xpconnect/src/XPCComponents.cpp
js/xpconnect/src/xpcprivate.h
--- a/caps/nsScriptSecurityManager.cpp
+++ b/caps/nsScriptSecurityManager.cpp
@@ -1204,17 +1204,17 @@ nsScriptSecurityManager::doGetObjectPrin
 }
 
 NS_IMETHODIMP
 nsScriptSecurityManager::CanCreateWrapper(JSContext *cx,
                                           const nsIID &aIID,
                                           nsISupports *aObj,
                                           nsIClassInfo *aClassInfo)
 {
-// XXX Special case for nsIXPCException ?
+// XXX Special case for Exception ?
 
     uint32_t flags;
     if (aClassInfo && NS_SUCCEEDED(aClassInfo->GetFlags(&flags)) &&
         (flags & nsIClassInfo::DOM_OBJECT)) {
         return NS_OK;
     }
 
     // We give remote-XUL whitelisted domains a free pass here. See bug 932906.
--- a/dom/base/DOMException.cpp
+++ b/dom/base/DOMException.cpp
@@ -138,18 +138,17 @@ NS_GetNameAndMessageForDOMNSResult(nsres
 
 namespace mozilla {
 namespace dom {
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Exception)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_MAP_ENTRY(Exception)
   NS_INTERFACE_MAP_ENTRY(nsIException)
-  NS_INTERFACE_MAP_ENTRY(nsIXPCException)
-  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIException)
+  NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(Exception)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(Exception)
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(Exception)
 
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Exception)
@@ -164,28 +163,37 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_END
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(Exception)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mLocation)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mData)
   NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
   tmp->mThrownJSVal.setNull();
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
-NS_IMPL_CI_INTERFACE_GETTER(Exception, nsIXPCException)
-
 Exception::Exception(const nsACString& aMessage,
                      nsresult aResult,
                      const nsACString& aName,
                      nsIStackFrame *aLocation,
                      nsISupports *aData)
-: mResult(NS_OK),
-  mInitialized(false),
-  mHoldingJSVal(false)
+  : mMessage(aMessage)
+  , mResult(aResult)
+  , mName(aName)
+  , mData(aData)
+  , mInitialized(true)
+  , mHoldingJSVal(false)
 {
-  Initialize(aMessage, aResult, aName, aLocation, aData);
+  if (aLocation) {
+    mLocation = aLocation;
+  } else {
+    mLocation = GetCurrentJSStack();
+    // it is legal for there to be no active JS stack, if C++ code
+    // is operating on a JS-implemented interface pointer without
+    // having been called in turn by JS.  This happens in the JS
+    // component loader.
+  }
 }
 
 Exception::~Exception()
 {
   if (mHoldingJSVal) {
     MOZ_ASSERT(NS_IsMainThread());
 
     mozilla::DropJSObjects(this);
@@ -359,43 +367,16 @@ Exception::ToString(JSContext* aCx, nsAC
   const char* data = mData ? "yes" : "no";
 
   _retval.Truncate();
   _retval.AppendPrintf(format, msg, static_cast<uint32_t>(mResult), resultName,
                        location.get(), data);
   return NS_OK;
 }
 
-NS_IMETHODIMP
-Exception::Initialize(const nsACString& aMessage, nsresult aResult,
-                      const nsACString& aName, nsIStackFrame *aLocation,
-                      nsISupports *aData)
-{
-  NS_ENSURE_FALSE(mInitialized, NS_ERROR_ALREADY_INITIALIZED);
-
-  mMessage = aMessage;
-  mName = aName;
-  mResult = aResult;
-
-  if (aLocation) {
-    mLocation = aLocation;
-  } else {
-    mLocation = GetCurrentJSStack();
-    // it is legal for there to be no active JS stack, if C++ code
-    // is operating on a JS-implemented interface pointer without
-    // having been called in turn by JS.  This happens in the JS
-    // component loader.
-  }
-
-  mData = aData;
-
-  mInitialized = true;
-  return NS_OK;
-}
-
 JSObject*
 Exception::WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto)
 {
   return ExceptionBinding::Wrap(cx, this, aGivenProto);
 }
 
 void
 Exception::GetMessageMoz(nsString& retval)
--- a/dom/base/DOMException.h
+++ b/dom/base/DOMException.h
@@ -15,17 +15,17 @@
 
 #include <stdint.h>
 #include "jspubtd.h"
 #include "nsCOMPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsID.h"
 #include "nsIDOMDOMException.h"
 #include "nsWrapperCache.h"
-#include "xpcexception.h"
+#include "nsIException.h"
 #include "nsString.h"
 #include "mozilla/dom/BindingDeclarations.h"
 
 class nsIStackFrame;
 
 nsresult
 NS_GetNameAndMessageForDOMNSResult(nsresult aNSResult, nsACString& aName,
                                    nsACString& aMessage,
@@ -37,27 +37,26 @@ class ErrorResult;
 namespace dom {
 
 class GlobalObject;
 
 #define MOZILLA_EXCEPTION_IID \
 { 0x55eda557, 0xeba0, 0x4fe3, \
   { 0xae, 0x2e, 0xf3, 0x94, 0x49, 0x23, 0x62, 0xd6 } }
 
-class Exception : public nsIXPCException,
+class Exception : public nsIException,
                   public nsWrapperCache
 {
 public:
   NS_DECLARE_STATIC_IID_ACCESSOR(MOZILLA_EXCEPTION_IID)
 
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Exception)
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_NSIEXCEPTION
-  NS_DECL_NSIXPCEXCEPTION
 
   // Cruft used by XPConnect for exceptions originating in JS implemented
   // components.
   bool StealJSVal(JS::Value* aVp);
   void StowJSVal(JS::Value& aVp);
 
   // WebIDL API
   virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto)
--- a/js/xpconnect/idl/moz.build
+++ b/js/xpconnect/idl/moz.build
@@ -5,17 +5,16 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 XPIDL_SOURCES += [
     'mozIJSSubScriptLoader.idl',
     'nsIAddonInterposition.idl',
     'nsIXPConnect.idl',
     'nsIXPCScriptable.idl',
     'xpccomponents.idl',
-    'xpcexception.idl',
     'xpcIJSGetFactory.idl',
     'xpcIJSModuleLoader.idl',
     'xpcIJSWeakReference.idl',
     'xpcjsid.idl',
 ]
 
 XPIDL_MODULE = 'xpconnect'
 
deleted file mode 100644
--- a/js/xpconnect/idl/xpcexception.idl
+++ /dev/null
@@ -1,30 +0,0 @@
- /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- *
- * 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 "nsISupports.idl"
-#include "nsIException.idl"
-
-[scriptable, builtinclass, uuid(875e6645-e762-4da6-9ec8-bf19ab0050df)]
-interface nsIXPCException : nsIException
-{
-    // inherits methods from nsIException
-
-    void initialize(in AUTF8String      aMessage,
-                    in nsresult         aResult,
-                    in AUTF8String      aName,
-                    in nsIStackFrame    aLocation,
-                    in nsISupports      aData);
-};
-
-/* this goes into the C++ header verbatim. */
-%{ C++
-/********************************************************/
-// {5632BF70-51EC-11d3-9896-006008962422}
-#define NS_XPCEXCEPTION_CID  \
-{ 0x5632bf70, 0x51ec, 0x11d3, \
-    { 0x98, 0x96, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } }
-%}
-
--- a/js/xpconnect/src/XPCComponents.cpp
+++ b/js/xpconnect/src/XPCComponents.cpp
@@ -1249,17 +1249,17 @@ nsXPCComponents_ID::HasInstance(nsIXPCon
                                 HandleValue val, bool* bp, bool* _retval)
 {
     if (bp)
         *bp = JSValIsInterfaceOfType(cx, val, NS_GET_IID(nsIJSID));
     return NS_OK;
 }
 
 /***************************************************************************/
-// JavaScript Constructor for nsIXPCException objects (Components.Exception)
+// JavaScript Constructor for Exception objects (Components.Exception)
 
 class nsXPCComponents_Exception final :
   public nsIXPCComponents_Exception,
   public nsIXPCScriptable,
   public nsIClassInfo
 {
 public:
     // all the interface method declarations...
@@ -1537,24 +1537,24 @@ nsXPCComponents_Exception::CallOrConstru
 
     MOZ_DIAGNOSTIC_ASSERT(nsContentUtils::IsCallerChrome());
 
     // Parse the arguments to the Exception constructor.
     ExceptionArgParser parser(cx, xpc);
     if (!parser.parse(args))
         return ThrowAndFail(NS_ERROR_XPC_BAD_CONVERT_JS, cx, _retval);
 
-    nsCOMPtr<nsIException> e = new Exception(nsCString(parser.eMsg),
-                                             parser.eResult,
-                                             EmptyCString(),
-                                             parser.eStack,
-                                             parser.eData);
+    RefPtr<Exception> e = new Exception(nsCString(parser.eMsg),
+                                        parser.eResult,
+                                        EmptyCString(),
+                                        parser.eStack,
+                                        parser.eData);
 
     RootedObject newObj(cx);
-    if (NS_FAILED(xpc->WrapNative(cx, obj, e, NS_GET_IID(nsIXPCException), newObj.address())) || !newObj) {
+    if (NS_FAILED(xpc->WrapNative(cx, obj, e, NS_GET_IID(nsIException), newObj.address())) || !newObj) {
         return ThrowAndFail(NS_ERROR_XPC_CANT_CREATE_WN, cx, _retval);
     }
 
     args.rval().setObject(*newObj);
     return NS_OK;
 }
 
 NS_IMETHODIMP
--- a/js/xpconnect/src/xpcprivate.h
+++ b/js/xpconnect/src/xpcprivate.h
@@ -113,17 +113,16 @@
 #include "nsIObserver.h"
 #include "nsWeakReference.h"
 #include "nsCOMPtr.h"
 #include "nsXPTCUtils.h"
 #include "xptinfo.h"
 #include "XPCForwards.h"
 #include "XPCLog.h"
 #include "xpccomponents.h"
-#include "xpcexception.h"
 #include "xpcjsid.h"
 #include "prenv.h"
 #include "prcvar.h"
 #include "nsString.h"
 #include "nsReadableUtils.h"
 
 #include "MainThreadUtils.h"