Bug 964061 - Part 2: Remove nsIDOMCRMFObject; r=bzbarsky
authorEhsan Akhgari <ehsan.akhgari@gmail.com>
Mon, 27 Jan 2014 08:27:06 -0800
changeset 165406 e50f0e1b8dcc2c8e6869c0bdf34df7af896f366e
parent 165405 1cea61b9730f5ff54706f46f77ec625a23127f03
child 165407 4a1cd54502fd83f699ece6d6c983b75eea748b44
push id26092
push usercbook@mozilla.com
push dateTue, 28 Jan 2014 12:43:09 +0000
treeherdermozilla-central@ff2a3e1b5faf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky
bugs964061
milestone29.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 964061 - Part 2: Remove nsIDOMCRMFObject; r=bzbarsky
dom/base/Crypto.cpp
dom/base/Crypto.h
dom/bindings/Bindings.conf
dom/interfaces/base/domstubs.idl
dom/interfaces/base/moz.build
dom/interfaces/base/nsIDOMCRMFObject.idl
dom/interfaces/base/nsIDOMCryptoLegacy.idl
security/manager/ssl/src/nsCrypto.cpp
security/manager/ssl/src/nsCrypto.h
--- a/dom/base/Crypto.cpp
+++ b/dom/base/Crypto.cpp
@@ -145,17 +145,17 @@ Crypto::SetEnableSmartCardEvents(bool aE
   aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
 }
 
 void
 Crypto::GetVersion(nsString& aVersion)
 {
 }
 
-already_AddRefed<mozilla::dom::CRMFObject>
+mozilla::dom::CRMFObject*
 Crypto::GenerateCRMFRequest(JSContext* aContext,
                             const nsCString& aReqDN,
                             const nsCString& aRegToken,
                             const nsCString& aAuthenticator,
                             const nsCString& aEaCert,
                             const nsCString& aJsCallback,
                             const Sequence<JS::Value>& aArgs,
                             ErrorResult& aRv)
--- a/dom/base/Crypto.h
+++ b/dom/base/Crypto.h
@@ -45,17 +45,17 @@ public:
 		  ErrorResult& aRv);
 
 #ifndef MOZ_DISABLE_CRYPTOLEGACY
   virtual bool EnableSmartCardEvents();
   virtual void SetEnableSmartCardEvents(bool aEnable, ErrorResult& aRv);
 
   virtual void GetVersion(nsString& aVersion);
 
-  virtual already_AddRefed<mozilla::dom::CRMFObject>
+  virtual mozilla::dom::CRMFObject*
   GenerateCRMFRequest(JSContext* aContext,
                       const nsCString& aReqDN,
                       const nsCString& aRegToken,
                       const nsCString& aAuthenticator,
                       const nsCString& aEaCert,
                       const nsCString& aJsCallback,
                       const Sequence<JS::Value>& aArgs,
                       ErrorResult& aRv);
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -248,16 +248,17 @@ DOMInterfaces = {
 },
 
 'Coordinates': {
     'headerFile': 'nsGeoPosition.h'
 },
 
 'CRMFObject': {
     'headerFile': 'nsCrypto.h',
+    'nativeOwnership': 'owned',
     'wrapperCache': False,
 },
 
 'Crypto' : {
     'implicitJSContext': [ 'generateCRMFRequest', 'signText' ],
     'headerFile': 'Crypto.h'
 },
 
--- a/dom/interfaces/base/domstubs.idl
+++ b/dom/interfaces/base/domstubs.idl
@@ -71,15 +71,14 @@ interface nsIDOMRect;
 interface nsIDOMCSSStyleRule;
 interface nsIDOMCSSStyleRuleCollection;
 interface nsIDOMHTMLTableCaptionElement;
 
 // Range
 interface nsIDOMRange;
 
 // Crypto
-interface nsIDOMCRMFObject;
 interface nsIDOMCrypto;
 interface nsIDOMPkcs11;
 
 // Used font face (for inspector)
 interface nsIDOMFontFace;
 interface nsIDOMFontFaceList;
--- a/dom/interfaces/base/moz.build
+++ b/dom/interfaces/base/moz.build
@@ -11,17 +11,16 @@ XPIDL_SOURCES += [
     'nsIContentPermissionPrompt.idl',
     'nsIContentPrefService.idl',
     'nsIContentPrefService2.idl',
     'nsIContentURIGrouper.idl',
     'nsIDOMChromeWindow.idl',
     'nsIDOMClientRect.idl',
     'nsIDOMClientRectList.idl',
     'nsIDOMConstructor.idl',
-    'nsIDOMCRMFObject.idl',
     'nsIDOMGlobalObjectConstructor.idl',
     'nsIDOMGlobalPropertyInitializer.idl',
     'nsIDOMHistory.idl',
     'nsIDOMJSWindow.idl',
     'nsIDOMLocation.idl',
     'nsIDOMModalContentWindow.idl',
     'nsIDOMNavigator.idl',
     'nsIDOMPkcs11.idl',
deleted file mode 100644
--- a/dom/interfaces/base/nsIDOMCRMFObject.idl
+++ /dev/null
@@ -1,12 +0,0 @@
-/* -*- Mode: IDL; 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 "domstubs.idl"
-
-[scriptable, uuid(16da46c0-208d-11d4-8a7c-006008c844c3)]
-interface nsIDOMCRMFObject : nsISupports
-{
-  readonly attribute DOMString        request;
-};
--- a/dom/interfaces/base/nsIDOMCryptoLegacy.idl
+++ b/dom/interfaces/base/nsIDOMCryptoLegacy.idl
@@ -1,16 +1,15 @@
 /* -*- Mode: IDL; 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 "domstubs.idl"
 
-interface nsIDOMCRMFObject;
 interface nsIDOMWindow;
 
 [uuid(c25ecf08-3f46-4420-bee4-8505792fd63a)]
 interface nsIDOMCrypto : nsISupports
 {
   [notxpcom] void init(in nsIDOMWindow window);
   attribute boolean         enableSmartCardEvents;
 };
--- a/security/manager/ssl/src/nsCrypto.cpp
+++ b/security/manager/ssl/src/nsCrypto.cpp
@@ -211,25 +211,16 @@ private:
 
 // QueryInterface implementation for nsCrypto
 NS_INTERFACE_MAP_BEGIN(nsCrypto)
   NS_INTERFACE_MAP_ENTRY(nsIDOMCrypto)
 NS_INTERFACE_MAP_END_INHERITING(mozilla::dom::Crypto)
 
 NS_IMPL_ADDREF_INHERITED(nsCrypto, mozilla::dom::Crypto)
 NS_IMPL_RELEASE_INHERITED(nsCrypto, mozilla::dom::Crypto)
- 
-// QueryInterface implementation for CRMFObject
-NS_INTERFACE_MAP_BEGIN(CRMFObject)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMCRMFObject)
-  NS_INTERFACE_MAP_ENTRY(nsISupports)
-NS_INTERFACE_MAP_END
-
-NS_IMPL_ADDREF(CRMFObject)
-NS_IMPL_RELEASE(CRMFObject)
 
 // QueryInterface implementation for nsPkcs11
 #endif // MOZ_DISABLE_CRYPTOLEGACY
 
 NS_INTERFACE_MAP_BEGIN(nsPkcs11)
   NS_INTERFACE_MAP_ENTRY(nsIPKCS11)
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
@@ -1855,17 +1846,17 @@ GetISupportsFromContext(JSContext *cx)
     if (JS::ContextOptionsRef(cx).privateIsNSISupports())
         return static_cast<nsISupports *>(JS_GetContextPrivate(cx));
 
     return nullptr;
 }
 
 //The top level method which is a member of nsIDOMCrypto
 //for generate a base64 encoded CRMF request.
-already_AddRefed<CRMFObject>
+CRMFObject*
 nsCrypto::GenerateCRMFRequest(JSContext* aContext,
                               const nsCString& aReqDN,
                               const nsCString& aRegToken,
                               const nsCString& aAuthenticator,
                               const nsCString& aEaCert,
                               const nsCString& aJsCallback,
                               const Sequence<JS::Value>& aArgs,
                               ErrorResult& aRv)
@@ -2025,17 +2016,17 @@ nsCrypto::GenerateCRMFRequest(JSContext*
 #ifdef DEBUG_javi
   printf ("Created the folloing CRMF request:\n%s\n", encodedRequest);
 #endif
   if (!encodedRequest) {
     nsFreeKeyPairInfo(keyids, numRequests);
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
-  nsRefPtr<CRMFObject> newObject = new CRMFObject();
+  CRMFObject* newObject = new CRMFObject();
   newObject->SetCRMFRequest(encodedRequest);
   nsFreeKeyPairInfo(keyids, numRequests);
 
   // Post an event on the UI queue so that the JS gets called after
   // we return control to the JS layer.  Why do we have to this?
   // Because when this API was implemented for PSM 1.x w/ Communicator,
   // the only way to make this method work was to have a callback
   // in the JS layer that got called after key generation had happened.
@@ -2075,17 +2066,17 @@ nsCrypto::GenerateCRMFRequest(JSContext*
   nsCryptoRunnable *cryptoRunnable = new nsCryptoRunnable(args);
 
   rv = NS_DispatchToMainThread(cryptoRunnable);
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
     delete cryptoRunnable;
   }
 
-  return newObject.forget();
+  return newObject;
 }
 
 // Reminder that we inherit the memory passed into us here.
 // An implementation to let us back up certs as an event.
 nsP12Runnable::nsP12Runnable(nsIX509Cert **certArr, int32_t numCerts,
                              nsIPK11Token *token)
 {
   mCertArr  = certArr;
@@ -2852,33 +2843,35 @@ nsCrypto::Logout(ErrorResult& aRv)
 void
 nsCrypto::DisableRightClick(ErrorResult& aRv)
 {
   aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
 }
 
 CRMFObject::CRMFObject()
 {
+  MOZ_COUNT_CTOR(CRMFObject);
 }
 
 CRMFObject::~CRMFObject()
 {
+  MOZ_COUNT_DTOR(CRMFObject);
 }
 
 JSObject*
-CRMFObject::WrapObject(JSContext *aCx, JS::Handle<JSObject*> aScope)
+CRMFObject::WrapObject(JSContext *aCx, JS::Handle<JSObject*> aScope,
+                       bool* aTookOwnership)
 {
-  return CRMFObjectBinding::Wrap(aCx, aScope, this);
+  return CRMFObjectBinding::Wrap(aCx, aScope, this, aTookOwnership);
 }
 
-NS_IMETHODIMP
+void
 CRMFObject::GetRequest(nsAString& aRequest)
 {
   aRequest.Assign(mBase64Request);
-  return NS_OK;
 }
 
 nsresult
 CRMFObject::SetCRMFRequest(char *inRequest)
 {
   mBase64Request.AssignWithConversion(inRequest);  
   return NS_OK;
 }
--- a/security/manager/ssl/src/nsCrypto.h
+++ b/security/manager/ssl/src/nsCrypto.h
@@ -4,48 +4,48 @@
  * 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 _nsCrypto_h_
 #define _nsCrypto_h_
 
 #include "mozilla/dom/BindingDeclarations.h"
 #include "mozilla/ErrorResult.h"
 #ifndef MOZ_DISABLE_CRYPTOLEGACY
+#include "mozilla/dom/NonRefcountedDOMObject.h"
 #include "Crypto.h"
 #include "nsCOMPtr.h"
-#include "nsIDOMCRMFObject.h"
 #include "nsIDOMCryptoLegacy.h"
 #include "nsIRunnable.h"
 #include "nsString.h"
 #include "nsIPrincipal.h"
 
 #define NS_CRYPTO_CID \
   {0x929d9320, 0x251e, 0x11d4, { 0x8a, 0x7c, 0x00, 0x60, 0x08, 0xc8, 0x44, 0xc3} }
 #define PSM_VERSION_STRING "2.4"
 
 class nsIPSMComponent;
 class nsIDOMScriptObjectFactory;
 
 namespace mozilla {
 namespace dom {
 
-class CRMFObject : public nsIDOMCRMFObject
+class CRMFObject : public NonRefcountedDOMObject
 {
 public:
   CRMFObject();
   virtual ~CRMFObject();
 
-  NS_DECL_NSIDOMCRMFOBJECT
-  NS_DECL_ISUPPORTS
-
   nsresult SetCRMFRequest(char *inRequest);
 
-  JSObject* WrapObject(JSContext *aCx, JS::Handle<JSObject*> aScope);
+  JSObject* WrapObject(JSContext *aCx, JS::Handle<JSObject*> aScope,
+                       bool* aTookOwnership);
+
+  void GetRequest(nsAString& aRequest);
+
 private:
-
   nsString mBase64Request;
 };
 
 }
 }
 
 class nsCrypto: public mozilla::dom::Crypto
 {
@@ -60,17 +60,17 @@ public:
   NS_DECL_NSIDOMCRYPTO
 
   virtual bool EnableSmartCardEvents() MOZ_OVERRIDE;
   virtual void SetEnableSmartCardEvents(bool aEnable,
                                         mozilla::ErrorResult& aRv) MOZ_OVERRIDE;
 
   virtual void GetVersion(nsString& aVersion) MOZ_OVERRIDE;
 
-  virtual already_AddRefed<mozilla::dom::CRMFObject>
+  virtual mozilla::dom::CRMFObject*
   GenerateCRMFRequest(JSContext* aContext,
                       const nsCString& aReqDN,
                       const nsCString& aRegToken,
                       const nsCString& aAuthenticator,
                       const nsCString& aEaCert,
                       const nsCString& aJsCallback,
                       const mozilla::dom::Sequence<JS::Value>& aArgs,
                       mozilla::ErrorResult& aRv) MOZ_OVERRIDE;