Index: chrome/browser/resources/options/chromeos/storage_manager.js |
diff --git a/chrome/browser/resources/options/chromeos/storage_manager.js b/chrome/browser/resources/options/chromeos/storage_manager.js |
index a2f75cb2f0fd4d13134c370dc3c4b5b8c54f8340..8c1a2f2e91a29fa9f0c0a604caa3fee6254b6723 100644 |
--- a/chrome/browser/resources/options/chromeos/storage_manager.js |
+++ b/chrome/browser/resources/options/chromeos/storage_manager.js |
@@ -41,6 +41,13 @@ cr.define('options', function() { |
StorageManager.prototype = { |
__proto__: Page.prototype, |
+ /** |
+ * Timer ID for periodical update. |
+ * @type {number} |
+ * @private |
Dan Beam
2016/07/09 00:18:26
nit: @private {number}
fukino
2016/07/11 03:33:24
Done.
|
+ */ |
+ updateTimerId_: -1, |
+ |
/** @override */ |
initializePage: function() { |
Page.prototype.initializePage.call(this); |
@@ -68,6 +75,13 @@ cr.define('options', function() { |
// Updating storage information can be expensive (e.g. computing directory |
// sizes recursively), so we delay this operation until the page is shown. |
chrome.send('updateStorageInfo'); |
+ // We periodically update the storage usage while the overlay is visible. |
+ this.startPeriodicalUpdate_(); |
+ }, |
+ |
+ /** @override */ |
+ didClosePage: function() { |
+ this.stopPeriodicalUpdate_(); |
}, |
/** |
@@ -144,6 +158,30 @@ cr.define('options', function() { |
showArcItem_: function() { |
$('storage-manager-item-arc').hidden = false; |
}, |
+ |
+ /** |
+ * Starts periodical update for storage usage. |
+ * @private |
+ */ |
+ startPeriodicalUpdate_: function() { |
+ // We update the storage usage every 5 seconds. |
+ if (this.updateTimerId_ === -1) { |
Dan Beam
2016/07/09 00:18:26
nit: arguably, you should use == unless there's a
fukino
2016/07/11 03:33:24
Done for all '===' and '!=='.
|
+ this.updateTimerId_ = window.setInterval(function() { |
+ chrome.send('updateStorageInfo'); |
+ }, 5000); |
+ } |
+ }, |
+ |
+ /** |
+ * Stops periodical update for storage usage. |
+ * @private |
+ */ |
+ stopPeriodicalUpdate_: function() { |
+ if (this.updateTimerId_ !== -1) { |
+ window.clearInterval(this.updateTimerId_); |
+ this.updateTimerId_ = -1; |
+ } |
+ }, |
}; |
// Forward public APIs to private implementations. |