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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * A module that contains basic utility components and methods for the 7 * A module that contains basic utility components and methods for the
8 * chromoting project 8 * chromoting project
9 * 9 *
10 */ 10 */
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 } catch (/** @type {Error} */ error) { 49 } catch (/** @type {Error} */ error) {
50 var callstack = error.stack 50 var callstack = error.stack
51 .replace(/^\s+(at eval )?at\s+/gm, '') // Remove 'at' and indentation. 51 .replace(/^\s+(at eval )?at\s+/gm, '') // Remove 'at' and indentation.
52 .split('\n'); 52 .split('\n');
53 callstack.splice(0,2); // Remove the stack of the current function. 53 callstack.splice(0,2); // Remove the stack of the current function.
54 } 54 }
55 return callstack.join('\n'); 55 return callstack.join('\n');
56 }; 56 };
57 57
58 /** 58 /**
59 * @param {*} value
60 * @return T
61 * @template T
62 */
63 base.reinterpret_cast = function(value) {
Jamie 2015/04/07 01:13:11 You don't seem to be using this.
John Williams 2015/04/07 20:10:25 Yeah, I thought this would make certain casts less
64 return value;
65 };
66
67 /**
59 * @interface 68 * @interface
60 */ 69 */
61 base.Disposable = function() {}; 70 base.Disposable = function() {};
62 base.Disposable.prototype.dispose = function() {}; 71 base.Disposable.prototype.dispose = function() {};
63 72
64 /** 73 /**
65 * @constructor 74 * @constructor
66 * @param {...base.Disposable} var_args 75 * @param {...base.Disposable} var_args
67 * @implements {base.Disposable} 76 * @implements {base.Disposable}
68 */ 77 */
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 */ 736 */
728 base.resizeWindowToContent = function() { 737 base.resizeWindowToContent = function() {
729 var appWindow = chrome.app.window.current(); 738 var appWindow = chrome.app.window.current();
730 var outerBounds = appWindow.outerBounds; 739 var outerBounds = appWindow.outerBounds;
731 var borderY = outerBounds.height - appWindow.innerBounds.height; 740 var borderY = outerBounds.height - appWindow.innerBounds.height;
732 appWindow.resizeTo(outerBounds.width, document.body.clientHeight + borderY); 741 appWindow.resizeTo(outerBounds.width, document.body.clientHeight + borderY);
733 // Sometimes, resizing the window causes its position to be reset to (0, 0), 742 // Sometimes, resizing the window causes its position to be reset to (0, 0),
734 // so restore it explicitly. 743 // so restore it explicitly.
735 appWindow.moveTo(outerBounds.left, outerBounds.top); 744 appWindow.moveTo(outerBounds.left, outerBounds.top);
736 }; 745 };
746
747 /**
748 * @return {string} A random UUID.
749 */
750 base.generateUuid = function() {
Jamie 2015/04/07 01:13:12 Move this up below generateXsrfToken, since it's c
John Williams 2015/04/07 20:10:25 Done.
751 var random = new Uint16Array(8);
752 window.crypto.getRandomValues(random);
753 /** @type {Array<string>} */
754 var e = new Array();
755 for (var i = 0; i < 8; i++) {
756 e[i] = (/** @type {number} */ (random[i]) + 0x10000).
757 toString(16).substring(1);
758 }
759 return e[0] + e[1] + '-' + e[2] + '-' + e[3] + '-' +
760 e[4] + '-' + e[5] + e[6] + e[7];
761 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698