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

Unified Diff: third_party/WebKit/Source/devtools/front_end/sdk/ServiceWorkerManager.js

Issue 1940993002: DevTools: simplify Service Workers panel UI, remove non-actionable data. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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: third_party/WebKit/Source/devtools/front_end/sdk/ServiceWorkerManager.js
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/ServiceWorkerManager.js b/third_party/WebKit/Source/devtools/front_end/sdk/ServiceWorkerManager.js
index 057127dceee55a1d9f95637fcf1ecd2cafdc0fc5..2995cc02718b7be2d9a0697fd41ad10c2c0af696 100644
--- a/third_party/WebKit/Source/devtools/front_end/sdk/ServiceWorkerManager.js
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/ServiceWorkerManager.js
@@ -54,6 +54,7 @@ WebInspector.ServiceWorkerManager = function(target)
WebInspector.ServiceWorkerManager.Events = {
WorkersUpdated: "WorkersUpdated",
RegistrationUpdated: "RegistrationUpdated",
+ RegistrationErrorAdded: "RegistrationErrorAdded",
RegistrationDeleted: "RegistrationDeleted"
}
@@ -92,15 +93,15 @@ WebInspector.ServiceWorkerManager.prototype = {
/**
* @param {string} versionId
- * @return {boolean}
+ * @return {?WebInspector.Target}
*/
- hasWorkerWithVersionId: function(versionId)
+ targetForVersionId: function(versionId)
{
for (var pair of this._workers) {
if (pair[1]._versionId === versionId)
- return true;
+ return pair[1]._target;
}
- return false;
+ return null;
},
/**
@@ -201,6 +202,14 @@ WebInspector.ServiceWorkerManager.prototype = {
},
/**
+ * @param {string} scope
+ */
+ skipWaiting: function(scope)
+ {
+ this._agent.skipWaiting(scope);
+ },
+
+ /**
* @param {string} versionId
*/
stopWorker: function(versionId)
@@ -345,13 +354,13 @@ WebInspector.ServiceWorkerManager.prototype = {
/**
* @param {!ServiceWorkerAgent.ServiceWorkerErrorMessage} payload
*/
- _workerErrorReported: function(payload)
+ _workerErrorReported: function(payload)
{
var registration = this._registrations.get(payload.registrationId);
if (!registration)
return;
- registration._addError(payload);
- this.dispatchEventToListeners(WebInspector.ServiceWorkerManager.Events.RegistrationUpdated, registration);
+ registration.errors.push(payload);
+ this.dispatchEventToListeners(WebInspector.ServiceWorkerManager.Events.RegistrationErrorAdded, { registration: registration, error: payload });
},
/**
@@ -483,7 +492,7 @@ WebInspector.ServiceWorker.prototype = {
var parsedUrl = context.origin.asParsedURL();
var label = parsedUrl ? parsedUrl.lastPathComponentWithFragment() : context.name;
if (this._status)
- context.setLabel(label + " (" + this._status + ")");
+ context.setLabel(label + " #" + this._versionId + " (" + this._status + ")");
caseq 2016/05/05 01:09:22 Looks like WebInspector.UIString().. Wait.. A UISt
pfeldman 2016/05/05 02:21:42 Nope
else
context.setLabel(label);
},
@@ -628,18 +637,6 @@ WebInspector.TargetInfo.prototype = {
/**
* @constructor
- * @param {!ServiceWorkerAgent.ServiceWorkerErrorMessage} payload
- */
-WebInspector.ServiceWorkerErrorMessage = function(payload)
-{
- this.errorMessage = payload.errorMessage;
- this.sourceURL = payload.sourceURL;
- this.lineNumber = payload.lineNumber;
- this.columnNumber = payload.columnNumber;
-}
-
-/**
- * @constructor
* @param {!WebInspector.ServiceWorkerRegistration} registration
* @param {!ServiceWorkerAgent.ServiceWorkerVersion} payload
*/
@@ -647,8 +644,6 @@ WebInspector.ServiceWorkerVersion = function(registration, payload)
{
this.registration = registration;
this._update(payload);
- /** @type {!Array<!WebInspector.ServiceWorkerErrorMessage>} */
- this.errorMessages = [];
}
/**
@@ -669,14 +664,25 @@ WebInspector.ServiceWorkerVersion.prototype = {
{
this.id = payload.versionId;
this.scriptURL = payload.scriptURL;
+ this.securityOrigin = payload.scriptURL.asParsedURL().securityOrigin();
this.runningStatus = payload.runningStatus;
this.status = payload.status;
this.scriptLastModified = payload.scriptLastModified;
this.scriptResponseTime = payload.scriptResponseTime;
this.controlledClients = []
caseq 2016/05/05 01:09:22 ; while you're here
pfeldman 2016/05/05 02:21:42 Done.
- for (var i = 0; i < payload.controlledClients.length; ++i) {
+ for (var i = 0; i < payload.controlledClients.length; ++i)
this.controlledClients.push(payload.controlledClients[i]);
- }
+ delete this._fingerprint;
+ },
+
+ /**
+ * @return {string}
+ */
+ fingerprint: function()
+ {
+ if (!this._fingerprint)
+ this._fingerprint = JSON.stringify(this);
caseq 2016/05/05 01:09:22 Please don't. Perhaps, keep payload around and str
pfeldman 2016/05/05 02:21:41 Done.
+ return this._fingerprint;
},
/**
@@ -787,20 +793,13 @@ WebInspector.ServiceWorkerVersion.prototype = {
else if (this.isActivating() || this.isActivated())
return WebInspector.ServiceWorkerVersion.Modes.Active;
return WebInspector.ServiceWorkerVersion.Modes.Redundant;
- },
-
- /**
- * @param {!ServiceWorkerAgent.ServiceWorkerErrorMessage} payload
- */
- _addError: function(payload)
- {
- this.errorMessages.push(new WebInspector.ServiceWorkerErrorMessage(payload));
}
}
/**
* @constructor
* @param {!ServiceWorkerAgent.ServiceWorkerRegistration} payload
+* @extends {WebInspector.Object}
caseq 2016/05/05 01:09:22 Why?
pfeldman 2016/05/05 02:21:42 Done.
*/
WebInspector.ServiceWorkerRegistration = function(payload)
{
@@ -808,6 +807,8 @@ WebInspector.ServiceWorkerRegistration = function(payload)
/** @type {!Map.<string, !WebInspector.ServiceWorkerVersion>} */
this.versions = new Map();
this._deleting = false;
+ /** @type {!Array<!ServiceWorkerAgent.ServiceWorkerErrorMessage>} */
+ this.errors = [];
}
WebInspector.ServiceWorkerRegistration.prototype = {
@@ -816,18 +817,49 @@ WebInspector.ServiceWorkerRegistration.prototype = {
*/
_update: function(payload)
{
+ delete this._fingerprint;
this.id = payload.registrationId;
this.scopeURL = payload.scopeURL;
+ this.securityOrigin = payload.scopeURL.asParsedURL().securityOrigin();
this.isDeleted = payload.isDeleted;
this.forceUpdateOnPageLoad = payload.forceUpdateOnPageLoad;
},
/**
+ * @return {string}
+ */
+ fingerprint: function()
+ {
+ if (this._fingerprint)
+ return this._fingerprint;
+
+ var result = [this.errors.length];
+ var ids = this.versions.keysArray().sort();
+ for (var id of ids)
+ result.push(this.versions.get(id).fingerprint());
+ this._fingerprint = result.join(",");
+ return this._fingerprint;
+ },
+
+ /**
+ * @return {!Map<string, !WebInspector.ServiceWorkerVersion>}
+ */
+ versionsByMode: function()
+ {
+ /** @type {!Map<string, !WebInspector.ServiceWorkerVersion>} */
+ var result = new Map();
+ for (var version of this.versions.values())
+ result.set(version.mode(), version);
+ return result;
caseq 2016/05/05 01:09:22 return new Map(this.versions.values().map(version
pfeldman 2016/05/05 02:21:42 this.versions.values(...).map is not a function
+ },
+
+ /**
* @param {!ServiceWorkerAgent.ServiceWorkerVersion} payload
* @return {!WebInspector.ServiceWorkerVersion}
*/
_updateVersion: function(payload)
{
+ delete this._fingerprint;
var version = this.versions.get(payload.versionId);
if (!version) {
version = new WebInspector.ServiceWorkerVersion(this, payload);
@@ -839,16 +871,6 @@ WebInspector.ServiceWorkerRegistration.prototype = {
},
/**
- * @param {!ServiceWorkerAgent.ServiceWorkerErrorMessage} payload
- */
- _addError: function(payload)
- {
- var version = this.versions.get(payload.versionId);
- if (version)
- version._addError(payload);
- },
-
- /**
* @return {boolean}
*/
_isRedundant: function()
@@ -863,20 +885,16 @@ WebInspector.ServiceWorkerRegistration.prototype = {
/**
* @return {boolean}
*/
- _hasErrorLog: function()
+ _shouldBeRemoved: function()
{
- for (var version of this.versions.values()) {
- if (version.errorMessages.length)
- return true;
- }
- return false;
+ return this._isRedundant() && (!this.errors.length || this._deleting);
},
- /**
- * @return {boolean}
- */
- _shouldBeRemoved: function()
+ clearErrors: function()
{
- return this._isRedundant() && (!this._hasErrorLog() || this._deleting);
- }
+ delete this._fingerprint;
+ this.errors = [];
+ },
+
+ __proto__: WebInspector.Object.prototype
}

Powered by Google App Engine
This is Rietveld 408576698