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. 4 5 /** 6 * @fileoverview Provides a countdown-based timer interface. 7 */ 8 'use strict'; 9 10 /** 11 * A countdown timer. 12 * @interface 13 */ 14 function Countdown() {} 15 16 /** 17 * Sets a new timeout for this timer. 18 * @param {number} timeoutMillis how long, in milliseconds, the countdown lasts. 19 * @param {Function=} cb called back when the countdown expires. 20 * @return {boolean} whether the timeout could be set. 21 */ 22 Countdown.prototype.setTimeout = function(timeoutMillis, cb) {}; 23 24 /** Clears this timer's timeout. Timers that are cleared become expired. */ 25 Countdown.prototype.clearTimeout = function() {}; 26 27 /** 28 * @return {number} how many milliseconds are remaining until the timer expires. 29 */ 30 Countdown.prototype.millisecondsUntilExpired = function() {}; 31 32 /** @return {boolean} whether the timer has expired. */ 33 Countdown.prototype.expired = function() {}; 34 35 /** 36 * Constructs a new clone of this timer, while overriding its callback. 37 * @param {Function=} cb callback for new timer. 38 * @return {!Countdown} new clone. 39 */ 40 Countdown.prototype.clone = function(cb) {}; 41 42 /** 43 * A factory to create countdown timers. 44 * @interface 45 */ 46 function CountdownFactory() {} 47 48 /** 49 * Creates a new timer. 50 * @param {number} timeoutMillis How long, in milliseconds, the countdown lasts. 51 * @param {function()=} opt_cb Called back when the countdown expires. 52 * @return {!Countdown} The timer. 53 */ 54 CountdownFactory.prototype.createTimer = function(timeoutMillis, opt_cb) {}; 55