| OLD | NEW |
| (Empty) |
| 1 <!-- | |
| 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. | |
| 5 --> | |
| 6 | |
| 7 <script> | |
| 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); | |
| 14 } | |
| 15 | |
| 16 CTScheduledUpdater.prototype._schedule = function() { | |
| 17 if (this._isScheduled) | |
| 18 return; | |
| 19 | |
| 20 this._isScheduled = true; | |
| 21 requestAnimationFrame(this._do.bind(this)); | |
| 22 } | |
| 23 | |
| 24 CTScheduledUpdater.prototype._do = function() { | |
| 25 this._isScheduled = false; | |
| 26 this.callback(); | |
| 27 } | |
| 28 </script> | |
| OLD | NEW |