Bug 1378824 - Stop using sdk/util/uuid in DevTools. r=jdescottes
authorsole <sole@mozilla.com>
Fri, 28 Jul 2017 14:36:33 +0100
changeset 422754 b39c8141158d07eaea845e1f8681a5e891863390
parent 422753 3e94306b5b97dce94423a3d3be2b574b53f7ecf3
child 422755 e9bb73e285c4d711066a11cd5b2cbf99d40435af
push id1517
push userjlorenzo@mozilla.com
push dateThu, 14 Sep 2017 16:50:54 +0000
treeherdermozilla-release@3b41fd564418 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdescottes
bugs1378824
milestone56.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 1378824 - Stop using sdk/util/uuid in DevTools. r=jdescottes MozReview-Commit-ID: KdIK4Vlrp4s
devtools/client/inspector/webpack.config.js
devtools/client/inspector/webpack/uuid-sham.js
devtools/client/shared/redux/middleware/promise.js
devtools/shared/generate-uuid.js
devtools/shared/moz.build
--- 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/generate-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/inspector/webpack/uuid-sham.js
+++ b/devtools/client/inspector/webpack/uuid-sham.js
@@ -5,15 +5,15 @@
 "use strict";
 
 const s4 = function () {
   return Math.floor((1 + Math.random()) * 0x10000)
              .toString(16)
              .substring(1);
 };
 
-let uuid = function () {
+let generateUUID = function () {
   return "ss-s-s-s-sss".replace(/s/g, function () {
     return s4();
   });
 };
 
-module.exports = { uuid };
+module.exports = { generateUUID };
--- a/devtools/client/shared/redux/middleware/promise.js
+++ b/devtools/client/shared/redux/middleware/promise.js
@@ -1,28 +1,28 @@
 /* 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 { generateUUID } = require("devtools/shared/generate-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 => {
     if (!(PROMISE in action)) {
       return next(action);
     }
 
     const promiseInst = action[PROMISE];
-    const seqId = uuidgen().toString();
+    const seqId = generateUUID().toString();
 
     // Create a new action that doesn't have the promise field and has
     // the `seqId` field that represents the sequence id
     action = Object.assign(
       toObject(entries(action).filter(pair => pair[0] !== PROMISE)), { seqId }
     );
 
     dispatch(Object.assign({}, action, { status: "start" }));
new file mode 100644
--- /dev/null
+++ b/devtools/shared/generate-uuid.js
@@ -0,0 +1,16 @@
+/* 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 } = require("chrome");
+const { generateUUID } =
+  Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerator);
+
+/**
+ * Returns a new `uuid`.
+ *
+ */
+
+module.exports = { generateUUID };
--- a/devtools/shared/moz.build
+++ b/devtools/shared/moz.build
@@ -50,16 +50,17 @@ DevToolsModules(
     'defer.js',
     'deprecated-sync-thenables.js',
     'DevToolsUtils.js',
     'dom-node-constants.js',
     'dom-node-filter-constants.js',
     'event-emitter.js',
     'extend.js',
     'flags.js',
+    'generate-uuid.js',
     'indentation.js',
     'l10n.js',
     'loader-plugin-raw.jsm',
     'Loader.jsm',
     'Parser.jsm',
     'path.js',
     'plural-form.js',
     'protocol.js',