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

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: Comments 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.cacheStorageListTreeElement = new WebInspector.ServiceWorkerCacheTreeEl ement(this);
70 this._sidebarTree.appendChild(this.cacheStorageListTreeElement);
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 this.cacheStorageListTreeElement._initialize();
177 this.serviceWorkerCacheListTreeElement._initialize();
178 if (Runtime.experiments.isEnabled("fileSystemInspection")) 176 if (Runtime.experiments.isEnabled("fileSystemInspection"))
179 this.fileSystemListTreeElement._initialize(); 177 this.fileSystemListTreeElement._initialize();
180 this._initDefaultSelection(); 178 this._initDefaultSelection();
181 this._initialized = true; 179 this._initialized = true;
182 }, 180 },
183 181
184 _loadEventFired: function() 182 _loadEventFired: function()
185 { 183 {
186 this._initDefaultSelection(); 184 this._initDefaultSelection();
187 }, 185 },
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 this._databaseQueryViews.clear(); 224 this._databaseQueryViews.clear();
227 this._databaseTreeElements.clear(); 225 this._databaseTreeElements.clear();
228 this._domStorageViews.clear(); 226 this._domStorageViews.clear();
229 this._domStorageTreeElements.clear(); 227 this._domStorageTreeElements.clear();
230 this._cookieViews = {}; 228 this._cookieViews = {};
231 229
232 this.databasesListTreeElement.removeChildren(); 230 this.databasesListTreeElement.removeChildren();
233 this.localStorageListTreeElement.removeChildren(); 231 this.localStorageListTreeElement.removeChildren();
234 this.sessionStorageListTreeElement.removeChildren(); 232 this.sessionStorageListTreeElement.removeChildren();
235 this.cookieListTreeElement.removeChildren(); 233 this.cookieListTreeElement.removeChildren();
236 if (this.serviceWorkerCacheListTreeElement) 234 this.cacheStorageListTreeElement.removeChildren();
237 this.serviceWorkerCacheListTreeElement.removeChildren();
238 235
239 if (this.visibleView && !(this.visibleView instanceof WebInspector.Stora geCategoryView)) 236 if (this.visibleView && !(this.visibleView instanceof WebInspector.Stora geCategoryView))
240 this.visibleView.detach(); 237 this.visibleView.detach();
241 238
242 this._storageViewStatusBar.removeStatusBarItems(); 239 this._storageViewStatusBar.removeStatusBarItems();
243 240
244 if (this._sidebarTree.selectedTreeElement) 241 if (this._sidebarTree.selectedTreeElement)
245 this._sidebarTree.selectedTreeElement.deselect(); 242 this._sidebarTree.selectedTreeElement.deselect();
246 }, 243 },
247 244
(...skipping 1167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1415 }, 1412 },
1416 1413
1417 __proto__: WebInspector.BaseStorageTreeElement.prototype 1414 __proto__: WebInspector.BaseStorageTreeElement.prototype
1418 } 1415 }
1419 1416
1420 1417
1421 /** 1418 /**
1422 * @constructor 1419 * @constructor
1423 * @extends {WebInspector.StorageCategoryTreeElement} 1420 * @extends {WebInspector.StorageCategoryTreeElement}
1424 * @param {!WebInspector.ResourcesPanel} storagePanel 1421 * @param {!WebInspector.ResourcesPanel} storagePanel
1425 * @implements {WebInspector.TargetManager.Observer}
1426 */ 1422 */
1427 WebInspector.ServiceWorkerCacheTreeElement = function(storagePanel) 1423 WebInspector.ServiceWorkerCacheTreeElement = function(storagePanel)
1428 { 1424 {
1429 WebInspector.StorageCategoryTreeElement.call(this, storagePanel, WebInspecto r.UIString("Service Worker Cache"), "ServiceWorkerCache", ["service-worker-cache -storage-tree-item"]); 1425 WebInspector.StorageCategoryTreeElement.call(this, storagePanel, WebInspecto r.UIString("Cache Storage"), "CacheStorage", ["service-worker-cache-storage-tree -item"]);
1430 } 1426 }
1431 1427
1432 WebInspector.ServiceWorkerCacheTreeElement.prototype = { 1428 WebInspector.ServiceWorkerCacheTreeElement.prototype = {
1433 _initialize: function() 1429 _initialize: function()
1434 { 1430 {
1435 /** @type {!Array.<!WebInspector.SWCacheTreeElement>} */ 1431 /** @type {!Array.<!WebInspector.SWCacheTreeElement>} */
1436 this._swCacheTreeElements = []; 1432 this._swCacheTreeElements = [];
1437 var targets = WebInspector.targetManager.targets(); 1433 var target = WebInspector.targetManager.mainTarget();
1438 for (var i = 0; i < targets.length; ++i) { 1434 if (target) {
1439 if (!targets[i].serviceWorkerCacheModel) 1435 var model = WebInspector.ServiceWorkerCacheModel.fromTarget(target);
1440 continue; 1436 var caches = model.caches();
1441 var caches = targets[i].serviceWorkerCacheModel.caches(); 1437 for (var cache of caches)
1442 for (var j = 0; j < caches.length; ++j) 1438 this._addCache(model, cache);
1443 this._addCache(targets[i].serviceWorkerCacheModel, caches[j]);
1444 } 1439 }
1445 WebInspector.targetManager.addModelListener(WebInspector.ServiceWorkerCa cheModel, WebInspector.ServiceWorkerCacheModel.EventTypes.CacheAdded, this._cach eAdded, this); 1440 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); 1441 WebInspector.targetManager.addModelListener(WebInspector.ServiceWorkerCa cheModel, WebInspector.ServiceWorkerCacheModel.EventTypes.CacheRemoved, this._ca cheRemoved, this);
1447 this._refreshCaches();
1448 WebInspector.targetManager.observeTargets(this);
1449 }, 1442 },
1450 1443
1451 onattach: function() 1444 onattach: function()
1452 { 1445 {
1453 WebInspector.StorageCategoryTreeElement.prototype.onattach.call(this); 1446 WebInspector.StorageCategoryTreeElement.prototype.onattach.call(this);
1454 this.listItemElement.addEventListener("contextmenu", this._handleContext MenuEvent.bind(this), true); 1447 this.listItemElement.addEventListener("contextmenu", this._handleContext MenuEvent.bind(this), true);
1455 }, 1448 },
1456 1449
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) 1450 _handleContextMenuEvent: function(event)
1474 { 1451 {
1475 var contextMenu = new WebInspector.ContextMenu(event); 1452 var contextMenu = new WebInspector.ContextMenu(event);
1476 contextMenu.appendItem(WebInspector.UIString("Refresh Caches"), this._re freshCaches.bind(this)); 1453 contextMenu.appendItem(WebInspector.UIString("Refresh Caches"), this._re freshCaches.bind(this));
1477 contextMenu.show(); 1454 contextMenu.show();
1478 }, 1455 },
1479 1456
1480 _refreshCaches: function() 1457 _refreshCaches: function()
1481 { 1458 {
1482 var targets = WebInspector.targetManager.targets(); 1459 var target = WebInspector.targetManager.mainTarget();
1483 for (var i = 0; i < targets.length; ++i) { 1460 if (target) {
1484 if (targets[i].serviceWorkerCacheModel) 1461 var model = WebInspector.ServiceWorkerCacheModel.fromTarget(target);
1485 targets[i].serviceWorkerCacheModel.refreshCacheNames(); 1462 model.refreshCacheNames();
1486 } 1463 }
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);
(...skipping 52 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