Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(605)

Unified Diff: chrome/browser/resources/options/chromeos/storage_manager.js

Issue 2137463002: Storage manager: Update storage usage periodically. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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.

Powered by Google App Engine
This is Rietveld 408576698