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

Side by Side Diff: remoting/webapp/suspend_monitor.js

Issue 10825187: Suppress "errors" that aren't really errors. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added JSCompiler hints. Created 8 years, 4 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 | Annotate | Revision Log
« remoting/webapp/remoting.js ('K') | « remoting/webapp/remoting.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 /**
6 * @fileoverview
7 * Class to detect when the device is suspended, for example when a laptop's
8 * lid is closed.
9 */
10
11
12 'use strict';
13
14 /** @suppress {duplicate} */
15 var remoting = remoting || {};
16
17 /**
18 * @param {function():void} callback Callback function to invoke when a
19 * suspend+resume operation has been detected.
20 *
21 * @constructor
22 */
23 remoting.SuspendMonitor = function (callback) {
24 /** @type {function():void} @private */
25 this.callback_ = callback;
26 /** @type {number} @private */
27 this.timerIntervalMs_ = 60 * 1000;
28 /** @type {number} @private */
29 this.lateToleranceMs_ = 60 * 1000;
30 /** @type {number} @private */
31 this.callbackExpectedTime_ = 0;
32 this.start_();
33 };
34
35 /** @private */
36 remoting.SuspendMonitor.prototype.start_ = function() {
37 window.setTimeout(this.checkSuspend_.bind(this), this.timerIntervalMs_);
38 this.callbackExpectedTime_ = new Date().getTime() + this.timerIntervalMs_;
39 };
40
41 /** @private */
42 remoting.SuspendMonitor.prototype.checkSuspend_ = function() {
43 var lateByMs = new Date().getTime() - this.callbackExpectedTime_;
44 if (lateByMs > this.lateToleranceMs_) {
45 this.callback_();
46 }
47 this.start_();
48 };
49
50 /** @type {remoting.SuspendMonitor?} */
51 remoting.suspendMonitor = null;
OLDNEW
« remoting/webapp/remoting.js ('K') | « remoting/webapp/remoting.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698