2 Copyright 2014 The Chromium Authors. All rights reserved.
3 Use of this source code is governed by a BSD-style license that can be
4 found in the LICENSE file.
8 // Schedule a repeated action with requestAnimationFrame to avoid doing work
9 // when the tab is hidden.
10 function CTScheduledUpdater(callback, interval) {
11 this.callback = callback;
12 this._isScheduled = false;
13 this._intervalId = setInterval(this._schedule.bind(this), interval);
16 CTScheduledUpdater.prototype._schedule = function() {
17 if (this._isScheduled)
20 this._isScheduled = true;
21 requestAnimationFrame(this._do.bind(this));
24 CTScheduledUpdater.prototype._do = function() {
25 this._isScheduled = false;