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
3 // found in the LICENSE file.
5 cr.define('hotword', function() {
9 * Class used to keep this extension alive. When started, this calls an
10 * extension API on a regular basis which resets the event page keep-alive
14 function KeepAlive() {
15 this.timeoutId_ = null;
18 KeepAlive.prototype = {
20 * Start the keep alive process. Safe to call multiple times.
23 if (this.timeoutId_ == null)
24 this.timeoutId_ = setTimeout(this.handleTimeout_.bind(this), 1000);
28 * Stops the keep alive process. Safe to call multiple times.
31 if (this.timeoutId_ != null) {
32 clearTimeout(this.timeoutId_);
33 this.timeoutId_ = null;
38 * Handle the timer timeout. Calls an extension API and schedules the next
42 handleTimeout_: function() {
43 // Dummy extensions API call used to keep this event page alive by
44 // resetting the shutdown timer.
45 chrome.runtime.getPlatformInfo(function(info) {});
47 this.timeoutId_ = setTimeout(this.handleTimeout_.bind(this), 1000);