Bug 1485275 - Port bug 1484118: replace XPCOM use of nsTransactionManager in calendar/. r=philipp,jorgk
authorGeoff Lankow <geoff@darktrojan.net>
Thu, 23 Aug 2018 11:29:51 +1200
changeset 24544 a8bd1c32fd2d217f660bd11216e8e59ad37739a6
parent 24543 fd4696b16ee2860e4a27608b84609523978c2c10
child 24545 877d74ddb691fcf68c5de1d8b9af018b6af38eba
push id14776
push usermozilla@jorgk.com
push dateThu, 23 Aug 2018 07:17:56 +0000
treeherdercomm-central@877d74ddb691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersphilipp, jorgk
bugs1485275, 1484118
Bug 1485275 - Port bug 1484118: replace XPCOM use of nsTransactionManager in calendar/. r=philipp,jorgk
calendar/base/src/calTransactionManager.js
common/public/moz.build
common/public/nsCommonBaseCID.h
common/public/nsITransactionManagerExtra.idl
common/src/moz.build
common/src/nsCommonModule.cpp
common/src/nsTransactionManagerExtra.cpp
common/src/nsTransactionManagerExtra.h
--- a/calendar/base/src/calTransactionManager.js
+++ b/calendar/base/src/calTransactionManager.js
@@ -3,18 +3,19 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 var { cal } = ChromeUtils.import("resource://calendar/modules/calUtils.jsm", null);
 
 function calTransactionManager() {
     this.wrappedJSObject = this;
     if (!this.transactionManager) {
         this.transactionManager =
-            Components.classes["@mozilla.org/transactionmanager;1"]
-                      .createInstance(Components.interfaces.nsITransactionManager);
+            Cc["@mozilla.org/transaction-manager-extra;1"]
+                .getService(Ci.nsITransactionManagerExtra)
+                .createTransactionManager();
     }
 }
 
 calTransactionManager.prototype = {
     QueryInterface: ChromeUtils.generateQI([Ci.calITransactionManager]),
     classID: Components.ID("{1d529847-d292-4222-b066-b8b17a794d62}"),
 
     transactionManager: null,
--- a/common/public/moz.build
+++ b/common/public/moz.build
@@ -1,14 +1,15 @@
 # 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/.
 
 XPIDL_SOURCES += [
-    'nsIComponentManagerExtra.idl'
+    'nsIComponentManagerExtra.idl',
+    'nsITransactionManagerExtra.idl',
 ]
 
 XPIDL_MODULE = 'msgcommonbase'
 
 EXPORTS += [
     'nsCommonBaseCID.h'
 ]
--- a/common/public/nsCommonBaseCID.h
+++ b/common/public/nsCommonBaseCID.h
@@ -13,9 +13,18 @@
 #define NS_COMPONENTMANAGEREXTRA_CONTRACTID \
   "@mozilla.org/component-manager-extra;1"
 
 #define NS_COMPONENTMANAGEREXTRA_CID \
 { /* b4359b53-3060-46ff-ad42-e67eea6ccf59 */ \
  0xb4359b53, 0x3060, 0x46ff, \
  {0xad, 0x42, 0xe6, 0x7e, 0xea, 0x6c, 0xcf, 0x59}}
 
+// nsTransactionManagerExtra
+#define NS_TRANSACTIONMANAGEREXTRA_CONTRACTID \
+  "@mozilla.org/transaction-manager-extra;1"
+
+#define NS_TRANSACTIONMANAGEREXTRA_CID \
+{ /* 837d20c4-7cbd-4c42-9ff9-86466d4ed5fd */ \
+ 0x837d20c4, 0x7cbd, 0x4c42, \
+ {0x9f, 0xf9, 0x86, 0x46, 0x6d, 0x4e, 0xd5, 0xfd}}
+
 #endif // nsCommonBaseCID_h__
new file mode 100644
--- /dev/null
+++ b/common/public/nsITransactionManagerExtra.idl
@@ -0,0 +1,12 @@
+/* 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 "nsITransactionManager.idl"
+
+[scriptable, uuid(d1265f8e-e8ea-482e-9b58-0949cd1d83c0)]
+interface nsITransactionManagerExtra : nsISupports
+{
+  nsITransactionManager createTransactionManager();
+};
--- a/common/src/moz.build
+++ b/common/src/moz.build
@@ -6,12 +6,13 @@
 EXTRA_JS_MODULES += [
     'ChromeManifest.jsm',
     'extensionSupport.jsm',
     'Overlays.jsm'
 ]
 
 SOURCES += [
     'nsCommonModule.cpp',
-    'nsComponentManagerExtra.cpp'
+    'nsComponentManagerExtra.cpp',
+    'nsTransactionManagerExtra.cpp',
 ]
 
 FINAL_LIBRARY = 'xul'
--- a/common/src/nsCommonModule.cpp
+++ b/common/src/nsCommonModule.cpp
@@ -1,22 +1,28 @@
 #include "mozilla/ModuleUtils.h"
 #include "nsCommonBaseCID.h"
 #include "nsComponentManagerExtra.h"
+#include "nsTransactionManagerExtra.h"
 
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsComponentManagerExtra)
 NS_DEFINE_NAMED_CID(NS_COMPONENTMANAGEREXTRA_CID);
 
+NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransactionManagerExtra)
+NS_DEFINE_NAMED_CID(NS_TRANSACTIONMANAGEREXTRA_CID);
+
 const mozilla::Module::CIDEntry kCommonCIDs[] = {
   { &kNS_COMPONENTMANAGEREXTRA_CID, false, nullptr, nsComponentManagerExtraConstructor },
+  { &kNS_TRANSACTIONMANAGEREXTRA_CID, false, nullptr, nsTransactionManagerExtraConstructor },
   { nullptr }
 };
 
 const mozilla::Module::ContractIDEntry kCommonContracts[] = {
   { NS_COMPONENTMANAGEREXTRA_CONTRACTID, &kNS_COMPONENTMANAGEREXTRA_CID },
+  { NS_TRANSACTIONMANAGEREXTRA_CONTRACTID, &kNS_TRANSACTIONMANAGEREXTRA_CID },
   { nullptr }
 };
 
 static const mozilla::Module kCommonModule = {
   mozilla::Module::kVersion,
   kCommonCIDs,
   kCommonContracts,
   nullptr,
new file mode 100644
--- /dev/null
+++ b/common/src/nsTransactionManagerExtra.cpp
@@ -0,0 +1,23 @@
+/* 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 "nsCommonBaseCID.h"
+#include "nsTransactionManagerExtra.h"
+#include "mozilla/TransactionManager.h"
+
+NS_IMPL_ISUPPORTS(nsTransactionManagerExtra,
+                  nsITransactionManagerExtra)
+
+NS_IMETHODIMP
+nsTransactionManagerExtra::CreateTransactionManager(nsITransactionManager** aManager)
+{
+  NS_ENSURE_ARG_POINTER(aManager);
+  nsCOMPtr<nsITransactionManager> manager = new mozilla::TransactionManager();
+  manager.forget(aManager);
+  return NS_OK;
+}
+
+nsTransactionManagerExtra::~nsTransactionManagerExtra()
+{
+}
new file mode 100644
--- /dev/null
+++ b/common/src/nsTransactionManagerExtra.h
@@ -0,0 +1,20 @@
+/* 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 nsTransactionManagerExtra_h__
+#define nsTransactionManagerExtra_h__
+
+#include "nsITransactionManagerExtra.h"
+
+class nsTransactionManagerExtra : public nsITransactionManagerExtra
+{
+public:
+
+  NS_DECL_THREADSAFE_ISUPPORTS
+  NS_DECL_NSITRANSACTIONMANAGEREXTRA
+
+private:
+  virtual ~nsTransactionManagerExtra();
+};
+
+#endif // nsTransactionManagerExtra_h__