15c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu// Copyright 2014 The Chromium Authors. All rights reserved.
25c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu// Use of this source code is governed by a BSD-style license that can be
35c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu// found in the LICENSE file.
45c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu
55c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu/**
66e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) * @fileoverview Provides a countdown-based timer interface.
75c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu */
85c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu'use strict';
95c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu
105c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu/**
115c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * A countdown timer.
125c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * @interface
135c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu */
145c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liufunction Countdown() {}
155c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu
165c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu/**
175c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * Sets a new timeout for this timer.
185c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * @param {number} timeoutMillis how long, in milliseconds, the countdown lasts.
195c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * @param {Function=} cb called back when the countdown expires.
205c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * @return {boolean} whether the timeout could be set.
215c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu */
225c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo LiuCountdown.prototype.setTimeout = function(timeoutMillis, cb) {};
235c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu
24116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch/** Clears this timer's timeout. Timers that are cleared become expired. */
255c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo LiuCountdown.prototype.clearTimeout = function() {};
265c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu
275c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu/**
285c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * @return {number} how many milliseconds are remaining until the timer expires.
295c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu */
305c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo LiuCountdown.prototype.millisecondsUntilExpired = function() {};
315c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu
325c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu/** @return {boolean} whether the timer has expired. */
335c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo LiuCountdown.prototype.expired = function() {};
345c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu
355c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu/**
365c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * Constructs a new clone of this timer, while overriding its callback.
375c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * @param {Function=} cb callback for new timer.
385c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * @return {!Countdown} new clone.
395c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu */
405c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo LiuCountdown.prototype.clone = function(cb) {};
415c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu
425c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu/**
43116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch * A factory to create countdown timers.
44116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch * @interface
45116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch */
46116680a4aac90f2aa7413d9095a592090648e557Ben Murdochfunction CountdownFactory() {}
47116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
48116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch/**
49116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch * Creates a new timer.
50116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch * @param {number} timeoutMillis How long, in milliseconds, the countdown lasts.
51116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch * @param {function()=} opt_cb Called back when the countdown expires.
526e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) * @return {!Countdown} The timer.
53116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch */
54116680a4aac90f2aa7413d9095a592090648e557Ben MurdochCountdownFactory.prototype.createTimer = function(timeoutMillis, opt_cb) {};
55