Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Unified Diff: remoting/webapp/base/js/base.js

Issue 1065733004: Added partial unit tests for host_controller.js. More to come. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@hdf-unittest
Patch Set: added licenses to satisfy presubmit Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/remoting_webapp_files.gypi ('k') | remoting/webapp/base/js/base_unittest.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/base/js/base.js
diff --git a/remoting/webapp/base/js/base.js b/remoting/webapp/base/js/base.js
index f34b2e24ec651557c427b65413744652acaf42f7..91923357beef26d86024664db9005d86ec618c13 100644
--- a/remoting/webapp/base/js/base.js
+++ b/remoting/webapp/base/js/base.js
@@ -710,6 +710,22 @@ base.generateXsrfToken = function() {
};
/**
+ * @return {string} A random UUID.
+ */
+base.generateUuid = function() {
+ var random = new Uint16Array(8);
+ window.crypto.getRandomValues(random);
+ /** @type {Array<string>} */
+ var e = new Array();
+ for (var i = 0; i < 8; i++) {
+ e[i] = (/** @type {number} */ (random[i]) + 0x10000).
+ toString(16).substring(1);
+ }
+ return e[0] + e[1] + '-' + e[2] + '-' + e[3] + '-' +
+ e[4] + '-' + e[5] + e[6] + e[7];
+};
+
+/**
* @param {string} jsonString A JSON-encoded string.
* @return {Object|undefined} The decoded object, or undefined if the string
* cannot be parsed.
« no previous file with comments | « remoting/remoting_webapp_files.gypi ('k') | remoting/webapp/base/js/base_unittest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698