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

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: Fixed comment. 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
« no previous file with comments | « 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. If the device is suspended,
8 * for example, a laptop's lid is closed, any subsequent errors detected by
9 * the active ClientSession should not be logged, as they arise from explicit
10 * user action.
11 */
12
garykac 2012/08/04 00:43:46 Shouldn't there be 'use strict'; var remotin
Jamie 2012/08/04 00:51:39 Done.
13 /**
14 * @param {function():void} callback Callback function to invoke when a
15 * suspend+resume operation has been detected.
16 *
17 * @constructor
18 */
19 remoting.SuspendMonitor = function (callback) {
20 /** @type {function():void} @private */
21 this.callback_ = callback;
22 /** @type {number} @private */
23 this.timerIntervalMs_ = 60 * 1000;
24 /** @type {number} @private */
25 this.lateToleranceMs_ = 60 * 1000;
26 /** @type {number} @private */
27 this.callbackExpectedTime_ = 0;
28 this.start_();
29 };
30
31 /** @private */
32 remoting.SuspendMonitor.prototype.start_ = function() {
33 window.setTimeout(this.checkSuspend_.bind(this), this.timerIntervalMs_);
34 this.callbackExpectedTime_ = new Date().getTime() + this.timerIntervalMs_;
35 };
36
37 /** @private */
38 remoting.SuspendMonitor.prototype.checkSuspend_ = function() {
39 var lateByMs = new Date().getTime() - this.callbackExpectedTime_;
40 if (lateByMs > this.lateToleranceMs_) {
41 this.callback_();
42 }
43 this.start_();
44 };
45
46 /** @type {remoting.SuspendMonitor?} */
47 remoting.suspendMonitor = null;
OLDNEW
« no previous file with comments | « remoting/webapp/remoting.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698