OLD | NEW |
---|---|
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 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
670 */ | 670 */ |
671 base.RepeatingTimer = function(callback, interval, opt_invokeNow) { | 671 base.RepeatingTimer = function(callback, interval, opt_invokeNow) { |
672 /** @private */ | 672 /** @private */ |
673 this.intervalId_ = window.setInterval(callback, interval); | 673 this.intervalId_ = window.setInterval(callback, interval); |
674 if (opt_invokeNow) { | 674 if (opt_invokeNow) { |
675 callback(); | 675 callback(); |
676 } | 676 } |
677 }; | 677 }; |
678 | 678 |
679 base.RepeatingTimer.prototype.dispose = function() { | 679 base.RepeatingTimer.prototype.dispose = function() { |
680 window.clearInterval(this.intervalId_); | 680 window.clearInterval(this.intervalId_); |
Jamie
2015/04/16 20:05:49
I think you need to route the callback via a membe
kelvinp
2015/04/16 20:57:58
Added for the OneShotTimer.
For repeating timer, t
Jamie
2015/04/17 00:02:47
Yes, my mistake. I meant to attach this to OneShot
| |
681 this.intervalId_ = null; | 681 this.intervalId_ = null; |
682 }; | 682 }; |
683 | 683 |
684 /** | 684 /** |
685 * A disposable one shot timer. | |
686 * | |
687 * @constructor | |
688 * @implements {base.Disposable} | |
689 */ | |
690 base.OneShotTimer = function(/** Function */ callback, /** number */ timeout) { | |
Jamie
2015/04/16 20:05:48
We have used the longer form of jsdoc annotation f
kelvinp
2015/04/16 20:57:58
Done.
| |
691 /** @private */ | |
692 this.timerId_ = window.setTimeout(callback, timeout); | |
693 }; | |
694 | |
695 base.OneShotTimer.prototype.dispose = function() { | |
696 window.clearTimeout(this.timerId_); | |
697 this.timerId_ = null; | |
698 }; | |
699 | |
700 /** | |
685 * Converts UTF-8 string to ArrayBuffer. | 701 * Converts UTF-8 string to ArrayBuffer. |
686 * | 702 * |
687 * @param {string} string | 703 * @param {string} string |
688 * @return {ArrayBuffer} | 704 * @return {ArrayBuffer} |
689 */ | 705 */ |
690 base.encodeUtf8 = function(string) { | 706 base.encodeUtf8 = function(string) { |
691 var utf8String = unescape(encodeURIComponent(string)); | 707 var utf8String = unescape(encodeURIComponent(string)); |
692 var result = new Uint8Array(utf8String.length); | 708 var result = new Uint8Array(utf8String.length); |
693 for (var i = 0; i < utf8String.length; i++) | 709 for (var i = 0; i < utf8String.length; i++) |
694 result[i] = utf8String.charCodeAt(i); | 710 result[i] = utf8String.charCodeAt(i); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
751 */ | 767 */ |
752 base.resizeWindowToContent = function() { | 768 base.resizeWindowToContent = function() { |
753 var appWindow = chrome.app.window.current(); | 769 var appWindow = chrome.app.window.current(); |
754 var outerBounds = appWindow.outerBounds; | 770 var outerBounds = appWindow.outerBounds; |
755 var borderY = outerBounds.height - appWindow.innerBounds.height; | 771 var borderY = outerBounds.height - appWindow.innerBounds.height; |
756 appWindow.resizeTo(outerBounds.width, document.body.clientHeight + borderY); | 772 appWindow.resizeTo(outerBounds.width, document.body.clientHeight + borderY); |
757 // Sometimes, resizing the window causes its position to be reset to (0, 0), | 773 // Sometimes, resizing the window causes its position to be reset to (0, 0), |
758 // so restore it explicitly. | 774 // so restore it explicitly. |
759 appWindow.moveTo(outerBounds.left, outerBounds.top); | 775 appWindow.moveTo(outerBounds.left, outerBounds.top); |
760 }; | 776 }; |
OLD | NEW |