Commit 2981bc9f authored by kristipark's avatar kristipark Committed by Commit Bot

[DevTools] Throttle cache storage list live updates

Creating/deleting a large number of caches at once causes
noticeable slowdowns due to the large number of cache tree
nodes added. Added a time delay between list refreshes to
soften the performance hit.

Also switched to _loadCacheNames since refreshCacheNames
visually removes all caches in the list before re-adding
them.

Bug: 729795
Change-Id: I28edf17671627f90f6d4bb4962cd91028c37f38e
Reviewed-on: https://chromium-review.googlesource.com/625160Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Commit-Queue: Kristi Park <kristipark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#496568}
parent 32af1a03
......@@ -770,8 +770,6 @@ Resources.ServiceWorkerCacheTreeElement = class extends Resources.StorageCategor
SDK.ServiceWorkerCacheModel, SDK.ServiceWorkerCacheModel.Events.CacheAdded, this._cacheAdded, this);
SDK.targetManager.addModelListener(
SDK.ServiceWorkerCacheModel, SDK.ServiceWorkerCacheModel.Events.CacheRemoved, this._cacheRemoved, this);
this._swCacheModel.addEventListener(
SDK.ServiceWorkerCacheModel.Events.CacheStorageListUpdated, this._refreshCaches, this);
this._swCacheModel.addEventListener(
SDK.ServiceWorkerCacheModel.Events.CacheStorageContentUpdated, this._cacheContentUpdated, this);
}
......
......@@ -22,6 +22,9 @@ SDK.ServiceWorkerCacheModel = class extends SDK.SDKModel {
this._securityOriginManager = target.model(SDK.SecurityOriginManager);
this._originsUpdated = new Set();
this._throttler = new Common.Throttler(2000);
/** @type {boolean} */
this._enabled = false;
}
......@@ -238,7 +241,15 @@ SDK.ServiceWorkerCacheModel = class extends SDK.SDKModel {
* @override
*/
cacheStorageListUpdated(origin) {
this.dispatchEventToListeners(SDK.ServiceWorkerCacheModel.Events.CacheStorageListUpdated, {origin: origin});
if (origin.endsWith('/'))
origin = origin.slice(0, -1);
this._originsUpdated.add(origin);
this._throttler.schedule(() => {
var promises = Array.from(this._originsUpdated, origin => this._loadCacheNames(origin));
this._originsUpdated.clear();
return Promise.all(promises);
});
}
/**
......@@ -258,7 +269,6 @@ SDK.SDKModel.register(SDK.ServiceWorkerCacheModel, SDK.Target.Capability.Browser
SDK.ServiceWorkerCacheModel.Events = {
CacheAdded: Symbol('CacheAdded'),
CacheRemoved: Symbol('CacheRemoved'),
CacheStorageListUpdated: Symbol('CacheStorageListUpdated'),
CacheStorageContentUpdated: Symbol('CacheStorageContentUpdated')
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment