| 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 <link rel="import" href="../lib/net.html"> | |
| 8 | |
| 9 <script> | |
| 10 function JSONGraphData(url) { | |
| 11 this.rowItemsAvailable = false; | |
| 12 this._url = url; | |
| 13 this._formattedDataCache = null; | |
| 14 } | |
| 15 | |
| 16 JSONGraphData.prototype.get = function() { | |
| 17 if (this._formattedDataCache) { | |
| 18 return Promise.resolve(this._formattedDataCache); | |
| 19 } | |
| 20 var self = this; | |
| 21 return net.json({url: this._url}).then(function(data) { | |
| 22 // Convert timestamps to Date objects. | |
| 23 data.rows.forEach(function(row) { | |
| 24 row[0] = new Date(row[0] * 1000); | |
| 25 }); | |
| 26 self._formattedDataCache = data; | |
| 27 return data; | |
| 28 }); | |
| 29 }; | |
| 30 </script> | |
| OLD | NEW |