[sql] Remove _HAS_EXCEPTIONS=0 from build info.
[chromium-blink-merge.git] / chrome / browser / resources / hotword / keep_alive.js
blob06ddf237df394aeaad49ed5f06e8e8cd7215dfdb
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() {
6 'use strict';
8 /**
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
11 * timer.
12 * @constructor
14 function KeepAlive() {
15 this.timeoutId_ = null;
18 KeepAlive.prototype = {
19 /**
20 * Start the keep alive process. Safe to call multiple times.
22 start: function() {
23 if (this.timeoutId_ == null)
24 this.timeoutId_ = setTimeout(this.handleTimeout_.bind(this), 1000);
27 /**
28 * Stops the keep alive process. Safe to call multiple times.
30 stop: function() {
31 if (this.timeoutId_ != null) {
32 clearTimeout(this.timeoutId_);
33 this.timeoutId_ = null;
37 /**
38 * Handle the timer timeout. Calls an extension API and schedules the next
39 * timeout.
40 * @private
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);
51 return {
52 KeepAlive: KeepAlive
54 });