Bug 1378824 - Stop using sdk/util/uuid in DevTools. r=jdescottes draft
authorsole <sole@mozilla.com>
Mon, 24 Jul 2017 12:53:35 +0100
changeset 614264 60d701deb836db7a427228fdcbf69ebf3c2481a7
parent 612941 0187e03ab8ef0e0b93f166b866a2656956a5d999
child 638831 e0c523ac650560d535b41512215b58ec6beb910e
push id69975
push userbmo:sole@mozilla.com
push dateMon, 24 Jul 2017 12:24:32 +0000
reviewersjdescottes
bugs1378824
milestone56.0a1
Bug 1378824 - Stop using sdk/util/uuid in DevTools. r=jdescottes MozReview-Commit-ID: 94sYYCNXIhc
devtools/client/inspector/webpack.config.js
devtools/client/shared/redux/middleware/promise.js
devtools/shared/moz.build
devtools/shared/uuid.js
--- a/devtools/client/inspector/webpack.config.js
+++ b/devtools/client/inspector/webpack.config.js
@@ -100,17 +100,17 @@ module.exports = envConfig => {
           path.join(__dirname, "./webpack/devtools-utils-sham.js"),
         "devtools/shared/locales": path.join(__dirname, "../../shared/locales/en-US"),
         "devtools/shared/platform": path.join(__dirname, "../../shared/platform/content"),
         "devtools": path.join(__dirname, "../../"),
         "gcli": path.join(__dirname, "../../shared/gcli/source/lib/gcli"),
         "method": path.join(__dirname, "../../../addon-sdk/source/lib/method"),
         "modules/libpref/init/all":
           path.join(__dirname, "../../../modules/libpref/init/all.js"),
-        "sdk/util/uuid":
+        "devtools/shared/uuid":
           path.join(__dirname, "./webpack/uuid-sham.js"),
         "sdk": path.join(__dirname, "../../../addon-sdk/source/lib/sdk"),
         "Services": path.join(__dirname, "../shared/shim/Services.js"),
         "toolkit/locales":
           path.join(__dirname, "../../../toolkit/locales/en-US/chrome/global"),
       },
     },
 
--- a/devtools/client/shared/redux/middleware/promise.js
+++ b/devtools/client/shared/redux/middleware/promise.js
@@ -1,14 +1,14 @@
 /* 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/. */
 "use strict";
 
-const uuidgen = require("sdk/util/uuid").uuid;
+const uuidgen = require("devtools/shared/uuid");
 const defer = require("devtools/shared/defer");
 const {
   entries, toObject, executeSoon
 } = require("devtools/shared/DevToolsUtils");
 const PROMISE = exports.PROMISE = "@@dispatch/promise";
 
 function promiseMiddleware({ dispatch, getState }) {
   return next => action => {
--- a/devtools/shared/moz.build
+++ b/devtools/shared/moz.build
@@ -61,13 +61,14 @@ DevToolsModules(
     'Loader.jsm',
     'Parser.jsm',
     'path.js',
     'plural-form.js',
     'protocol.js',
     'system.js',
     'task.js',
     'ThreadSafeDevToolsUtils.js',
+    'uuid.js',
     'wasm-source-map.js',
 )
 
 with Files('**'):
     BUG_COMPONENT = ('Firefox', 'Developer Tools')
new file mode 100644
--- /dev/null
+++ b/devtools/shared/uuid.js
@@ -0,0 +1,19 @@
+/* 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/. */
+
+"use strict";
+
+const { Cc, Ci, components: { ID: parseUUID } } = require("chrome");
+const { generateUUID } =
+  Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerator);
+
+/**
+ * Returns `uuid`. If `id` is passed then it's parsed to `uuid` and returned
+ * if not then new one is generated.
+ *
+ * Replacement for `uuid` API from "sdk/util/uuid".
+ */
+module.exports = function uuid(id) {
+  return id ? parseUUID(id) : generateUUID();
+};