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

Side by Side Diff: Source/devtools/front_end/resources/ResourcesPanel.js

Issue 1044203004: [Storage] Cache storage inspection on all the frames! (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 8 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2009 Joseph Pecoraro 3 * Copyright (C) 2009 Joseph Pecoraro
4 * Copyright (C) 2013 Samsung Electronics. All rights reserved. 4 * Copyright (C) 2013 Samsung Electronics. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 this.sessionStorageListTreeElement = new WebInspector.StorageCategoryTreeEle ment(this, WebInspector.UIString("Session Storage"), "SessionStorage", ["domstor age-storage-tree-item", "session-storage"]); 60 this.sessionStorageListTreeElement = new WebInspector.StorageCategoryTreeEle ment(this, WebInspector.UIString("Session Storage"), "SessionStorage", ["domstor age-storage-tree-item", "session-storage"]);
61 this._sidebarTree.appendChild(this.sessionStorageListTreeElement); 61 this._sidebarTree.appendChild(this.sessionStorageListTreeElement);
62 62
63 this.cookieListTreeElement = new WebInspector.StorageCategoryTreeElement(thi s, WebInspector.UIString("Cookies"), "Cookies", ["cookie-storage-tree-item"]); 63 this.cookieListTreeElement = new WebInspector.StorageCategoryTreeElement(thi s, WebInspector.UIString("Cookies"), "Cookies", ["cookie-storage-tree-item"]);
64 this._sidebarTree.appendChild(this.cookieListTreeElement); 64 this._sidebarTree.appendChild(this.cookieListTreeElement);
65 65
66 this.applicationCacheListTreeElement = new WebInspector.StorageCategoryTreeE lement(this, WebInspector.UIString("Application Cache"), "ApplicationCache", ["a pplication-cache-storage-tree-item"]); 66 this.applicationCacheListTreeElement = new WebInspector.StorageCategoryTreeE lement(this, WebInspector.UIString("Application Cache"), "ApplicationCache", ["a pplication-cache-storage-tree-item"]);
67 this._sidebarTree.appendChild(this.applicationCacheListTreeElement); 67 this._sidebarTree.appendChild(this.applicationCacheListTreeElement);
68 68
69 this.serviceWorkerCacheListTreeElement = new WebInspector.ServiceWorkerCache TreeElement(this);
70 this._sidebarTree.appendChild(this.serviceWorkerCacheListTreeElement);
71
69 if (Runtime.experiments.isEnabled("fileSystemInspection")) { 72 if (Runtime.experiments.isEnabled("fileSystemInspection")) {
70 this.fileSystemListTreeElement = new WebInspector.FileSystemListTreeElem ent(this); 73 this.fileSystemListTreeElement = new WebInspector.FileSystemListTreeElem ent(this);
71 this._sidebarTree.appendChild(this.fileSystemListTreeElement); 74 this._sidebarTree.appendChild(this.fileSystemListTreeElement);
72 } 75 }
73 76
74 var mainView = new WebInspector.VBox(); 77 var mainView = new WebInspector.VBox();
75 this.storageViews = mainView.element.createChild("div", "vbox flex-auto"); 78 this.storageViews = mainView.element.createChild("div", "vbox flex-auto");
76 this._storageViewStatusBar = new WebInspector.StatusBar(mainView.element); 79 this._storageViewStatusBar = new WebInspector.StatusBar(mainView.element);
77 this._storageViewStatusBar.element.classList.add("resources-status-bar"); 80 this._storageViewStatusBar.element.classList.add("resources-status-bar");
78 this.splitView().setMainView(mainView); 81 this.splitView().setMainView(mainView);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 /** 118 /**
116 * @override 119 * @override
117 * @param {!WebInspector.Target} target 120 * @param {!WebInspector.Target} target
118 */ 121 */
119 targetAdded: function(target) 122 targetAdded: function(target)
120 { 123 {
121 if (this._target) 124 if (this._target)
122 return; 125 return;
123 this._target = target; 126 this._target = target;
124 127
125 if (target.isServiceWorker()) {
126 this.serviceWorkerCacheListTreeElement = new WebInspector.ServiceWor kerCacheTreeElement(this);
127 this._sidebarTree.appendChild(this.serviceWorkerCacheListTreeElement );
128 }
129
130 if (target.serviceWorkerManager && Runtime.experiments.isEnabled("servic eWorkersInResources")) { 128 if (target.serviceWorkerManager && Runtime.experiments.isEnabled("servic eWorkersInResources")) {
131 this.serviceWorkersTreeElement = new WebInspector.ServiceWorkersTree Element(this); 129 this.serviceWorkersTreeElement = new WebInspector.ServiceWorkersTree Element(this);
132 this._sidebarTree.appendChild(this.serviceWorkersTreeElement); 130 this._sidebarTree.appendChild(this.serviceWorkersTreeElement);
133 } 131 }
134 132
135 this._databaseModel = WebInspector.DatabaseModel.fromTarget(target); 133 this._databaseModel = WebInspector.DatabaseModel.fromTarget(target);
136 this._domStorageModel = WebInspector.DOMStorageModel.fromTarget(target); 134 this._domStorageModel = WebInspector.DOMStorageModel.fromTarget(target);
137 135
138 if (target.resourceTreeModel.cachedResourcesLoaded()) 136 if (target.resourceTreeModel.cachedResourcesLoaded())
139 this._initialize(); 137 this._initialize();
(...skipping 20 matching lines...) Expand all
160 this._databaseModel.removeEventListener(WebInspector.DatabaseModel.Event s.DatabaseAdded, this._databaseAdded, this); 158 this._databaseModel.removeEventListener(WebInspector.DatabaseModel.Event s.DatabaseAdded, this._databaseAdded, this);
161 159
162 this._resetWithFrames(); 160 this._resetWithFrames();
163 }, 161 },
164 162
165 _initialize: function() 163 _initialize: function()
166 { 164 {
167 this._databaseModel.enable(); 165 this._databaseModel.enable();
168 this._domStorageModel.enable(); 166 this._domStorageModel.enable();
169 WebInspector.IndexedDBModel.fromTarget(this._target).enable(); 167 WebInspector.IndexedDBModel.fromTarget(this._target).enable();
168 WebInspector.ServiceWorkerCacheModel.fromTarget(this._target).enable();
170 169
171 if (this._target.isPage()) 170 if (this._target.isPage())
172 this._populateResourceTree(); 171 this._populateResourceTree();
173 this._populateDOMStorageTree(); 172 this._populateDOMStorageTree();
174 this._populateApplicationCacheTree(); 173 this._populateApplicationCacheTree();
175 this.indexedDBListTreeElement._initialize(); 174 this.indexedDBListTreeElement._initialize();
176 if (this.serviceWorkerCacheListTreeElement) 175 if (this.serviceWorkerCacheListTreeElement)
177 this.serviceWorkerCacheListTreeElement._initialize(); 176 this.serviceWorkerCacheListTreeElement._initialize();
178 if (Runtime.experiments.isEnabled("fileSystemInspection")) 177 if (Runtime.experiments.isEnabled("fileSystemInspection"))
179 this.fileSystemListTreeElement._initialize(); 178 this.fileSystemListTreeElement._initialize();
(...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after
1415 }, 1414 },
1416 1415
1417 __proto__: WebInspector.BaseStorageTreeElement.prototype 1416 __proto__: WebInspector.BaseStorageTreeElement.prototype
1418 } 1417 }
1419 1418
1420 1419
1421 /** 1420 /**
1422 * @constructor 1421 * @constructor
1423 * @extends {WebInspector.StorageCategoryTreeElement} 1422 * @extends {WebInspector.StorageCategoryTreeElement}
1424 * @param {!WebInspector.ResourcesPanel} storagePanel 1423 * @param {!WebInspector.ResourcesPanel} storagePanel
1425 * @implements {WebInspector.TargetManager.Observer}
1426 */ 1424 */
1427 WebInspector.ServiceWorkerCacheTreeElement = function(storagePanel) 1425 WebInspector.ServiceWorkerCacheTreeElement = function(storagePanel)
1428 { 1426 {
1429 WebInspector.StorageCategoryTreeElement.call(this, storagePanel, WebInspecto r.UIString("Service Worker Cache"), "ServiceWorkerCache", ["service-worker-cache -storage-tree-item"]); 1427 WebInspector.StorageCategoryTreeElement.call(this, storagePanel, WebInspecto r.UIString("Cache Storage"), "Cache Storage", ["service-worker-cache-storage-tre e-item"]);
pfeldman 2015/04/01 07:01:09 "Cache Storage" -> "CacheStorage"
dmurph 2015/04/02 20:59:02 Done.
1430 } 1428 }
1431 1429
1432 WebInspector.ServiceWorkerCacheTreeElement.prototype = { 1430 WebInspector.ServiceWorkerCacheTreeElement.prototype = {
1433 _initialize: function() 1431 _initialize: function()
1434 { 1432 {
1435 /** @type {!Array.<!WebInspector.SWCacheTreeElement>} */ 1433 /** @type {!Array.<!WebInspector.SWCacheTreeElement>} */
1436 this._swCacheTreeElements = []; 1434 this._swCacheTreeElements = [];
1437 var targets = WebInspector.targetManager.targets(); 1435 var targets = WebInspector.targetManager.targets();
1438 for (var i = 0; i < targets.length; ++i) { 1436 for (var target of targets) {
pfeldman 2015/04/01 07:01:09 Targets can be added later, you should keep the ta
dmurph 2015/04/02 20:59:02 I don't need to because we listen for securityOrig
1439 if (!targets[i].serviceWorkerCacheModel) 1437 var model = WebInspector.ServiceWorkerCacheModel.fromTarget(target);
1440 continue; 1438 var caches = model.caches();
1441 var caches = targets[i].serviceWorkerCacheModel.caches(); 1439 for (var cache of caches)
1442 for (var j = 0; j < caches.length; ++j) 1440 this._addCache(model, cache);
1443 this._addCache(targets[i].serviceWorkerCacheModel, caches[j]);
1444 } 1441 }
1445 WebInspector.targetManager.addModelListener(WebInspector.ServiceWorkerCa cheModel, WebInspector.ServiceWorkerCacheModel.EventTypes.CacheAdded, this._cach eAdded, this); 1442 WebInspector.targetManager.addModelListener(WebInspector.ServiceWorkerCa cheModel, WebInspector.ServiceWorkerCacheModel.EventTypes.CacheAdded, this._cach eAdded, this);
1446 WebInspector.targetManager.addModelListener(WebInspector.ServiceWorkerCa cheModel, WebInspector.ServiceWorkerCacheModel.EventTypes.CacheRemoved, this._ca cheRemoved, this); 1443 WebInspector.targetManager.addModelListener(WebInspector.ServiceWorkerCa cheModel, WebInspector.ServiceWorkerCacheModel.EventTypes.CacheRemoved, this._ca cheRemoved, this);
1447 this._refreshCaches();
1448 WebInspector.targetManager.observeTargets(this);
1449 }, 1444 },
1450 1445
1451 onattach: function() 1446 onattach: function()
1452 { 1447 {
1453 WebInspector.StorageCategoryTreeElement.prototype.onattach.call(this); 1448 WebInspector.StorageCategoryTreeElement.prototype.onattach.call(this);
1454 this.listItemElement.addEventListener("contextmenu", this._handleContext MenuEvent.bind(this), true); 1449 this.listItemElement.addEventListener("contextmenu", this._handleContext MenuEvent.bind(this), true);
1455 }, 1450 },
1456 1451
1457 /**
1458 * @override
1459 * @param {!WebInspector.Target} target
1460 */
1461 targetAdded: function(target)
1462 {
1463 if (target.isServiceWorker() && target.serviceWorkerCacheModel)
1464 this._refreshCaches();
1465 },
1466
1467 /**
1468 * @override
1469 * @param {!WebInspector.Target} target
1470 */
1471 targetRemoved: function(target) {},
1472
1473 _handleContextMenuEvent: function(event) 1452 _handleContextMenuEvent: function(event)
1474 { 1453 {
1475 var contextMenu = new WebInspector.ContextMenu(event); 1454 var contextMenu = new WebInspector.ContextMenu(event);
1476 contextMenu.appendItem(WebInspector.UIString("Refresh Caches"), this._re freshCaches.bind(this)); 1455 contextMenu.appendItem(WebInspector.UIString("Refresh Caches"), this._re freshCaches.bind(this));
1477 contextMenu.show(); 1456 contextMenu.show();
1478 }, 1457 },
1479 1458
1480 _refreshCaches: function() 1459 _refreshCaches: function()
1481 { 1460 {
1482 var targets = WebInspector.targetManager.targets(); 1461 var targets = WebInspector.targetManager.targets();
1483 for (var i = 0; i < targets.length; ++i) { 1462 for (var target of targets)
1484 if (targets[i].serviceWorkerCacheModel) 1463 WebInspector.ServiceWorkerCacheModel.fromTarget(target).refreshCache Names();
1485 targets[i].serviceWorkerCacheModel.refreshCacheNames();
1486 }
1487 }, 1464 },
1488 1465
1489 /** 1466 /**
1490 * @param {!WebInspector.Event} event 1467 * @param {!WebInspector.Event} event
1491 */ 1468 */
1492 _cacheAdded: function(event) 1469 _cacheAdded: function(event)
1493 { 1470 {
1494 var cacheId = /** @type {!WebInspector.ServiceWorkerCacheModel.CacheId} */ (event.data); 1471 var cacheId = /** @type {!WebInspector.ServiceWorkerCacheModel.CacheId} */ (event.data);
1495 var model = /** @type {!WebInspector.ServiceWorkerCacheModel} */ (event. target); 1472 var model = /** @type {!WebInspector.ServiceWorkerCacheModel} */ (event. target);
1496 this._addCache(model, cacheId); 1473 this._addCache(model, cacheId);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1548 1525
1549 /** 1526 /**
1550 * @constructor 1527 * @constructor
1551 * @extends {WebInspector.BaseStorageTreeElement} 1528 * @extends {WebInspector.BaseStorageTreeElement}
1552 * @param {!WebInspector.ResourcesPanel} storagePanel 1529 * @param {!WebInspector.ResourcesPanel} storagePanel
1553 * @param {!WebInspector.ServiceWorkerCacheModel} model 1530 * @param {!WebInspector.ServiceWorkerCacheModel} model
1554 * @param {!WebInspector.ServiceWorkerCacheModel.CacheId} cacheId 1531 * @param {!WebInspector.ServiceWorkerCacheModel.CacheId} cacheId
1555 */ 1532 */
1556 WebInspector.SWCacheTreeElement = function(storagePanel, model, cacheId) 1533 WebInspector.SWCacheTreeElement = function(storagePanel, model, cacheId)
1557 { 1534 {
1558 WebInspector.BaseStorageTreeElement.call(this, storagePanel, cacheId.name, [ "service-worker-cache-tree-item"]); 1535 WebInspector.BaseStorageTreeElement.call(this, storagePanel, cacheId.name + " - " + cacheId.securityOrigin, ["service-worker-cache-tree-item"]);
1559 this._model = model; 1536 this._model = model;
1560 this._cacheId = cacheId; 1537 this._cacheId = cacheId;
1561 } 1538 }
1562 1539
1563 WebInspector.SWCacheTreeElement.prototype = { 1540 WebInspector.SWCacheTreeElement.prototype = {
1564 get itemURL() 1541 get itemURL()
1565 { 1542 {
1566 // I don't think this will work at all. 1543 // I don't think this will work at all.
1567 return "swcache://" + this._cacheId.name; 1544 return "swcache://" + this._cacheId.name;
1568 }, 1545 },
(...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after
2432 WebInspector.ResourcesPanelFactory.prototype = { 2409 WebInspector.ResourcesPanelFactory.prototype = {
2433 /** 2410 /**
2434 * @override 2411 * @override
2435 * @return {!WebInspector.Panel} 2412 * @return {!WebInspector.Panel}
2436 */ 2413 */
2437 createPanel: function() 2414 createPanel: function()
2438 { 2415 {
2439 return WebInspector.ResourcesPanel._instance(); 2416 return WebInspector.ResourcesPanel._instance();
2440 } 2417 }
2441 } 2418 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698