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

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: Use == and != 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
« no previous file with comments | « no previous file | chrome/browser/ui/webui/options/chromeos/storage_manager_handler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..52256ff7f9f5bb2729746beb761192e60cad020c 100644
--- a/chrome/browser/resources/options/chromeos/storage_manager.js
+++ b/chrome/browser/resources/options/chromeos/storage_manager.js
@@ -41,6 +41,12 @@ cr.define('options', function() {
StorageManager.prototype = {
__proto__: Page.prototype,
+ /**
+ * Timer ID for periodical update.
+ * @private {number}
+ */
+ updateTimerId_: -1,
+
/** @override */
initializePage: function() {
Page.prototype.initializePage.call(this);
@@ -68,6 +74,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_();
},
/**
@@ -82,10 +95,10 @@ cr.define('options', function() {
$('storage-manager-size-available').textContent = sizeStat.availableSize;
$('storage-bar-progress').setAttribute('value', sizeStat.usedRatio);
$('storageManagerPage').classList.toggle('low-space',
- sizeStat.spaceState ===
+ sizeStat.spaceState ==
options.StorageSpaceState.STORAGE_SPACE_LOW);
$('storageManagerPage').classList.toggle('critically-low-space',
- sizeStat.spaceState ===
+ sizeStat.spaceState ==
options.StorageSpaceState.STORAGE_SPACE_CRITICALLY_LOW);
},
@@ -144,6 +157,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) {
+ 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.
« no previous file with comments | « no previous file | chrome/browser/ui/webui/options/chromeos/storage_manager_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698