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

Unified Diff: content/browser/resources/service_worker/serviceworker_internals.js

Issue 298993003: Show ServiceWorkers in chrome://inspect. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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: content/browser/resources/service_worker/serviceworker_internals.js
diff --git a/content/browser/resources/service_worker/serviceworker_internals.js b/content/browser/resources/service_worker/serviceworker_internals.js
index 1be184cf6fcc7e33dde303d9a0b560bda16e7719..67c55f9a2d75b9b98480c28ce8a7b091a4648f98 100644
--- a/content/browser/resources/service_worker/serviceworker_internals.js
+++ b/content/browser/resources/service_worker/serviceworker_internals.js
@@ -5,6 +5,22 @@
cr.define('serviceworker', function() {
'use strict';
+ function initialize() {
+ if (window.location.hash == "#iframe") {
+ // This page is loaded from chrome://inspect.
+ window.addEventListener('message', onMessage.bind(this), false);
+ }
+ update();
+ }
+
+ function onMessage(event) {
+ if (event.origin != 'chrome://inspect') {
+ return;
yurys 2014/05/23 09:22:41 style: wrong alignment
horo 2014/05/23 10:49:02 Done.
+ }
+ chrome.send(event.data.action,
+ [event.data.partition_path, event.data.scope]);
+ }
+
function update() {
chrome.send('getAllRegistrations');
}
@@ -48,8 +64,34 @@ cr.define('serviceworker', function() {
var allLogMessages = {};
+ // Send the active ServiceWorker information to chrome://inspect.
+ function sendToInspectPage(registrations, partition_id, partition_path) {
+ var workers = [];
+ for (var i = 0; i < registrations.length; i++) {
+ var registration = registrations[i];
yurys 2014/05/23 09:22:41 style: wrong alignment here and below.
horo 2014/05/23 10:49:02 Done.
+ if (!registration.active ||
+ registration.active.running_status != 'RUNNING') {
+ continue;
+ }
+ workers.push({
+ 'partition_path': partition_path,
+ 'scope': registration['scope'],
+ 'url': registration['script_url']
+ })
+ }
+ window.parent.postMessage({
+ 'partition_id': partition_id,
+ 'workers': workers,
+ }, 'chrome://inspect')
+ }
+
// Fired once per partition from the backend.
function onPartitionData(registrations, partition_id, partition_path) {
+ if (window.location.hash == "#iframe") {
+ // This page is loaded from chrome://inspect.
+ sendToInspectPage(registrations, partition_id, partition_path);
+ return;
+ }
var template;
var container = $('serviceworker-list');
@@ -164,6 +206,7 @@ cr.define('serviceworker', function() {
}
return {
+ initialize: initialize,
update: update,
onOperationComplete: onOperationComplete,
onPartitionData: onPartitionData,
@@ -177,4 +220,4 @@ cr.define('serviceworker', function() {
};
});
-document.addEventListener('DOMContentLoaded', serviceworker.update);
+document.addEventListener('DOMContentLoaded', serviceworker.initialize);
« no previous file with comments | « chrome/browser/ui/webui/inspect_ui.cc ('k') | content/browser/service_worker/service_worker_internals_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698