Changeset 76022 in webkit
- Timestamp:
- Jan 18, 2011 6:25:34 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r76021 r76022 1 2011-01-17 Andrey Kosyakov <caseq@chromium.org> 2 3 Reviewed by Yury Semikhatsky. 4 5 Web Inspector: [refactoring] use events to notify NetworkManager clients 6 https://bugs.webkit.org/show_bug.cgi?id=52588 7 8 * inspector/front-end/AuditLauncherView.js: 9 (WebInspector.AuditLauncherView): Do not expose public interface to resource count. Do not reset resource count upon reset(). 10 (WebInspector.AuditLauncherView.prototype._resetResourceCount): 11 (WebInspector.AuditLauncherView.prototype._onResourceStarted): 12 (WebInspector.AuditLauncherView.prototype._onResourceFinished): 13 * inspector/front-end/AuditsPanel.js: Do not expose public interface to resource start/finish events. 14 * inspector/front-end/ExtensionServer.js: 15 (WebInspector.ExtensionServer): 16 (WebInspector.ExtensionServer.prototype._notifyResourceFinished): 17 (WebInspector.ExtensionServer.prototype.initExtensions): 18 * inspector/front-end/NetworkManager.js: Dispatch events rather than directly call clients. 19 (WebInspector.NetworkManager): 20 (WebInspector.NetworkManager.prototype.willSendRequest): 21 (WebInspector.NetworkManager.prototype.markResourceAsCached): 22 (WebInspector.NetworkManager.prototype.didReceiveResponse): 23 (WebInspector.NetworkManager.prototype.didReceiveContentLength): 24 (WebInspector.NetworkManager.prototype.setInitialContent): 25 (WebInspector.NetworkManager.prototype.didCommitLoadForFrame): 26 (WebInspector.NetworkManager.prototype.willSendWebSocketHandshakeRequest): 27 (WebInspector.NetworkManager.prototype.didReceiveWebSocketHandshakeResponse): 28 (WebInspector.NetworkManager.prototype._startResource): 29 (WebInspector.NetworkManager.prototype._finishResource): 30 * inspector/front-end/NetworkPanel.js: 31 (WebInspector.NetworkPanel): 32 (WebInspector.NetworkPanel.prototype._onResourceStarted): 33 (WebInspector.NetworkPanel.prototype._appendResource): 34 (WebInspector.NetworkPanel.prototype._onResourceUpdated): 35 (WebInspector.NetworkPanel.prototype._refreshResource): 36 (WebInspector.NetworkPanel.prototype._onMainResourceChanged): 37 * inspector/front-end/ResourcesPanel.js: 38 (WebInspector.ResourcesPanel): 39 (WebInspector.ResourcesPanel.prototype._refreshResource): 40 1 41 2011-01-18 Pavel Feldman <pfeldman@chromium.org> 2 42 -
trunk/Source/WebCore/inspector/front-end/AuditLauncherView.js
r75950 r76022 1 1 /* 2 * Copyright (C) 20 09Google Inc. All rights reserved.2 * Copyright (C) 2011 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 51 51 this._headerElement.textContent = WebInspector.UIString("No audits to run"); 52 52 this._contentElement.appendChild(this._headerElement); 53 54 WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceStarted, this._onResourceStarted, this); 55 WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceFinished, this._onResourceFinished, this); 53 56 } 54 57 55 58 WebInspector.AuditLauncherView.prototype = { 56 get totalResources()57 {58 return this._totalResources;59 },60 61 set totalResources(x)62 {63 if (this._totalResources === x)64 return;65 this._totalResources = x;66 this._updateResourceProgress();67 },68 69 get loadedResources()70 {71 return this._loadedResources;72 },73 74 set loadedResources(x)75 {76 if (this._loadedResources === x)77 return;78 this._loadedResources = x;79 this._updateResourceProgress();80 },81 82 59 _resetResourceCount: function() 83 60 { 84 this.loadedResources = 0; 85 this.totalResources = 0; 86 }, 87 88 resourceStarted: function(resource) 89 { 61 this._loadedResources = 0; 62 this._totalResources = 0; 63 }, 64 65 _onResourceStarted: function(event) 66 { 67 var resource = event.data; 90 68 // Ignore long-living WebSockets for the sake of progress indicator, as we won't be waiting them anyway. 91 if (resource.type !== WebInspector.Resource.Type.WebSocket) 92 ++this.totalResources; 93 }, 94 95 resourceFinished: function(resource) 96 { 69 if (resource.type === WebInspector.Resource.Type.WebSocket) 70 return; 71 ++this._totalResources; 72 this._updateResourceProgress(); 73 }, 74 75 _onResourceFinished: function(event) 76 { 77 var resource = event.data; 97 78 // See resorceStarted for details. 98 if (resource.type !== WebInspector.Resource.Type.WebSocket) 99 ++this.loadedResources; 100 }, 101 102 reset: function() 103 { 104 this._resetResourceCount(); 79 if (resource.type === WebInspector.Resource.Type.WebSocket) 80 return; 81 ++this._loadedResources; 82 this._updateResourceProgress(); 105 83 }, 106 84 … … 265 243 } else 266 244 this._resourceProgressContainer.removeStyleClass("hidden"); 267 this._resourceProgressTextElement.textContent = WebInspector.UIString("Loading (%d of %d)", this. loadedResources, this.totalResources);245 this._resourceProgressTextElement.textContent = WebInspector.UIString("Loading (%d of %d)", this._loadedResources, this._totalResources); 268 246 }, 269 247 -
trunk/Source/WebCore/inspector/front-end/AuditsPanel.js
r75786 r76022 97 97 }, 98 98 99 resourceStarted: function(resource)100 {101 this._launcherView.resourceStarted(resource);102 },103 104 resourceFinished: function(resource)105 {106 this._launcherView.resourceFinished(resource);107 },108 109 99 addCategory: function(category) 110 100 { … … 247 237 }, 248 238 249 reset: function()250 {251 this._launcherView.reset();252 },253 254 239 attach: function() 255 240 { -
trunk/Source/WebCore/inspector/front-end/ExtensionServer.js
r75786 r76022 54 54 this._registerHandler("unsubscribe", this._onUnsubscribe.bind(this)); 55 55 56 57 56 window.addEventListener("message", this._onWindowMessage.bind(this), false); 58 57 } … … 69 68 }, 70 69 71 notifyResourceFinished: function(resource)72 {73 this._postNotification("resource-finished", resource.identifier, (new WebInspector.HAREntry(resource)).build());74 },75 76 70 notifySearchAction: function(panelId, action, searchString) 77 71 { … … 113 107 { 114 108 delete this._clientObjects[auditRun.id]; 109 }, 110 111 _notifyResourceFinished: function(event) 112 { 113 var resource = event.data; 114 this._postNotification("resource-finished", resource.identifier, (new WebInspector.HAREntry(resource)).build()); 115 115 }, 116 116 … … 357 357 initExtensions: function() 358 358 { 359 // The networkManager is normally created after the ExtensionServer is constructed, but before initExtensions() is called. 360 WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceFinished, this._notifyResourceFinished, this); 361 359 362 InspectorExtensionRegistry.getExtensionsAsync(); 360 363 }, -
trunk/Source/WebCore/inspector/front-end/NetworkManager.js
r75950 r76022 31 31 WebInspector.NetworkManager = function(resourceTreeModel) 32 32 { 33 WebInspector.Object.call(this); 34 33 35 this._inflightResources = {}; 34 36 this._resourceTreeModel = resourceTreeModel; … … 87 89 } 88 90 91 WebInspector.NetworkManager.EventTypes = { 92 ResourceStarted: "ResourceStarted", 93 ResourceUpdated: "ResourceUpdated", 94 ResourceFinished: "ResourceFinished", 95 MainResourceCommitLoad: "MainResourceCommitLoad" 96 } 97 89 98 WebInspector.NetworkManager.prototype = { 90 99 reset: function() … … 120 129 this._startResource(resource); 121 130 else 122 WebInspector.panels.network.refreshResource(resource);131 this._updateResource(resource); 123 132 }, 124 133 … … 130 139 131 140 resource.cached = true; 132 WebInspector.panels.network.refreshResource(resource);141 this._updateResource(resource); 133 142 }, 134 143 … … 144 153 WebInspector.NetworkManager.updateResourceWithResponse(resource, response); 145 154 146 WebInspector.panels.network.refreshResource(resource);155 this._updateResource(resource); 147 156 this._resourceTreeModel.addResourceToFrame(resource.loader.frameId, resource); 148 157 }, … … 157 166 resource.endTime = time; 158 167 159 WebInspector.panels.network.refreshResource(resource);168 this._updateResource(resource); 160 169 }, 161 170 … … 205 214 resource.type = WebInspector.Resource.Type[type]; 206 215 resource.setInitialContent(sourceString); 207 WebInspector.panels.resources.refreshResource(resource); 208 WebInspector.panels.network.refreshResource(resource); 216 this._updateResource(resource); 209 217 }, 210 218 … … 217 225 WebInspector.mainResource = mainResource; 218 226 mainResource.isMainResource = true; 219 WebInspector.panels.network.mainResourceChanged();227 this.dispatchEventToListeners(WebInspector.NetworkManager.EventTypes.MainResourceCommitLoad, mainResource); 220 228 } 221 229 } … … 240 248 resource.startTime = time; 241 249 242 WebInspector.panels.network.refreshResource(resource);250 this._updateResource(resource); 243 251 }, 244 252 … … 255 263 resource.responseReceivedTime = time; 256 264 257 WebInspector.panels.network.refreshResource(resource);265 this._updateResource(resource); 258 266 }, 259 267 … … 284 292 }, 285 293 286 _startResource: function(resource , skipRefresh)294 _startResource: function(resource) 287 295 { 288 296 this._inflightResources[resource.identifier] = resource; 289 WebInspector.panels.network.appendResource(resource, skipRefresh); 290 WebInspector.panels.audits.resourceStarted(resource); 297 this.dispatchEventToListeners(WebInspector.NetworkManager.EventTypes.ResourceStarted, resource); 298 }, 299 300 _updateResource: function(resource) 301 { 302 this.dispatchEventToListeners(WebInspector.NetworkManager.EventTypes.ResourceUpdated, resource); 291 303 }, 292 304 … … 295 307 resource.endTime = finishTime; 296 308 resource.finished = true; 297 WebInspector.panels.network.refreshResource(resource); 298 WebInspector.panels.audits.resourceFinished(resource); 299 WebInspector.extensionServer.notifyResourceFinished(resource); 309 this.dispatchEventToListeners(WebInspector.NetworkManager.EventTypes.ResourceFinished, resource); 300 310 delete this._inflightResources[resource.identifier]; 301 311 } 302 312 } 313 314 WebInspector.NetworkManager.prototype.__proto__ = WebInspector.Object.prototype; -
trunk/Source/WebCore/inspector/front-end/NetworkPanel.js
r75969 r76022 79 79 80 80 this._toggleGridMode(); 81 82 WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceStarted, this._onResourceStarted, this); 83 WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceUpdated, this._onResourceUpdated, this); 84 WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceFinished, this._onResourceUpdated, this); 85 WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.MainResourceCommitLoad, this._onMainResourceCommitLoad, this); 81 86 } 82 87 … … 773 778 }, 774 779 775 appendResource: function(resource) 780 _onResourceStarted: function(event) 781 { 782 this._appendResource(event.data); 783 }, 784 785 _appendResource: function(resource) 776 786 { 777 787 this._resources.push(resource); … … 782 792 if (resource.redirects) { 783 793 for (var i = 0; i < resource.redirects.length; ++i) 784 this.refreshResource(resource.redirects[i]); 785 } 786 787 this.refreshResource(resource); 788 }, 789 790 refreshResource: function(resource) 794 this._refreshResource(resource.redirects[i]); 795 } 796 797 this._refreshResource(resource); 798 }, 799 800 _onResourceUpdated: function(event) 801 { 802 this._refreshResource(event.data); 803 }, 804 805 _refreshResource: function(resource) 791 806 { 792 807 this._staleResources.push(resource); … … 812 827 }, 813 828 814 mainResourceChanged: function()829 _onMainResourceCommitLoad: function() 815 830 { 816 831 if (this._preserveLogToggle.toggled) … … 820 835 // Now resurrect the main resource along with all redirects that lead to it. 821 836 var resourcesToAppend = (WebInspector.mainResource.redirects || []).concat(WebInspector.mainResource); 822 resourcesToAppend.forEach(this. appendResource, this);837 resourcesToAppend.forEach(this._appendResource, this); 823 838 }, 824 839 -
trunk/Source/WebCore/inspector/front-end/ResourcesPanel.js
r75952 r76022 79 79 this.sidebarElement.addEventListener("mousemove", this._onmousemove.bind(this), false); 80 80 this.sidebarElement.addEventListener("mouseout", this._onmouseout.bind(this), false); 81 82 WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceUpdated, this._refreshResource, this); 81 83 } 82 84 … … 254 256 }, 255 257 256 refreshResource: function(resource) 257 { 258 _refreshResource: function(event) 259 { 260 var resource = event.data; 258 261 // FIXME: do not add XHR in the first place based on the native instrumentation. 259 262 if (resource.type === WebInspector.Resource.Type.XHR) {
Note: See TracChangeset
for help on using the changeset viewer.