2010-12-21 Ilya Tikhonovsky <loislo@chromium.org>
authorloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Dec 2010 15:11:26 +0000 (15:11 +0000)
committerloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Dec 2010 15:11:26 +0000 (15:11 +0000)
        Reviewed by Pavel Feldman.

        Web Inspector: Protocol cleanup task. Introduce Network, DOMStorage and Database domains.

        Domain was changed for Resources, FileSystem etc. related methods.
        ResourcesManager was renamed to NetworkManager.
        ResourceTreeModel was extracted as separate file.
        FileSystem, Database, DOMStorage and ApplicationCache methods were
        removed from NetworkManager and added to corresponding classes.

        https://bugs.webkit.org/show_bug.cgi?id=51334

        * WebCore.gypi:
        * WebCore.vcproj/WebCore.vcproj:
        * inspector/CodeGeneratorInspector.pm:
        * inspector/Inspector.idl:
        * inspector/front-end/AuditRules.js:
        (WebInspector.AuditRules.UnusedCssRule.prototype.doRun.evalCallback.selectorsCallback):
        * inspector/front-end/CSSStyleModel.js:
        (WebInspector.CSSStyleModel.prototype._styleSheetChanged.callback):
        (WebInspector.CSSStyleModel.prototype._styleSheetChanged):
        * inspector/front-end/ConsoleView.js:
        (WebInspector.ConsoleView.prototype.addMessage):
        (WebInspector.ConsoleView.prototype.clearMessages):
        * inspector/front-end/DOMAgent.js:
        (WebInspector.ApplicationCache.updateApplicationCacheStatus):
        (WebInspector.ApplicationCache.updateNetworkState):
        * inspector/front-end/DOMStorage.js:
        (WebInspector.DOMStorage.addDOMStorage):
        (WebInspector.DOMStorage.selectDOMStorage):
        (WebInspector.DOMStorage.updateDOMStorage):
        * inspector/front-end/Database.js:
        (WebInspector.Database.prototype.executeSql):
        (WebInspector.Database.addDatabase):
        (WebInspector.Database.selectDatabase):
        (WebInspector.Database.sqlTransactionSucceeded):
        (WebInspector.Database.sqlTransactionFailed):
        * inspector/front-end/FileSystemView.js:
        (WebInspector.FileSystem.didGetFileSystemPath):
        (WebInspector.FileSystem.didGetFileSystemError):
        (WebInspector.FileSystem.didGetFileSystemDisabled):
        * inspector/front-end/NetworkItemView.js:
        (WebInspector.NetworkItemView):
        * inspector/front-end/NetworkManager.js: Added.
        (WebInspector.NetworkManager):
        (WebInspector.NetworkManager.prototype._createResource):
        (WebInspector.NetworkManager.prototype.identifierForInitialRequest):
        (WebInspector.NetworkManager.prototype.willSendRequest):
        (WebInspector.NetworkManager.prototype._updateResourceWithRequest):
        (WebInspector.NetworkManager.prototype._appendRedirect):
        (WebInspector.NetworkManager.prototype.markResourceAsCached):
        (WebInspector.NetworkManager.prototype.didReceiveResponse):
        (WebInspector.NetworkManager.prototype._updateResourceWithResponse):
        (WebInspector.NetworkManager.prototype.didReceiveContentLength):
        (WebInspector.NetworkManager.prototype.didFinishLoading):
        (WebInspector.NetworkManager.prototype.didFailLoading):
        (WebInspector.NetworkManager.prototype.didLoadResourceFromMemoryCache):
        (WebInspector.NetworkManager.prototype._updateResourceWithCachedResource):
        (WebInspector.NetworkManager.prototype.setInitialContent):
        (WebInspector.NetworkManager.prototype.didCommitLoadForFrame):
        (WebInspector.NetworkManager.prototype.frameDetachedFromParent):
        (WebInspector.NetworkManager.prototype.didCreateWebSocket):
        (WebInspector.NetworkManager.prototype.willSendWebSocketHandshakeRequest):
        (WebInspector.NetworkManager.prototype.didReceiveWebSocketHandshakeResponse):
        (WebInspector.NetworkManager.prototype.didCloseWebSocket):
        (WebInspector.NetworkManager.prototype._processCachedResources):
        (WebInspector.NetworkManager.prototype._addFramesRecursively):
        (WebInspector.NetworkManager.requestContent):
        * inspector/front-end/NetworkPanel.js:
        (WebInspector.NetworkPanel.prototype.refreshResource):
        * inspector/front-end/Resource.js:
        (WebInspector.Resource.prototype._innerRequestContent):
        * inspector/front-end/ResourceManager.js: Removed.
        * inspector/front-end/ResourceTreeModel.js: Added.
        (WebInspector.ResourceTreeModel):
        (WebInspector.ResourceTreeModel.prototype.addOrUpdateFrame):
        (WebInspector.ResourceTreeModel.prototype.didCommitLoadForFrame):
        (WebInspector.ResourceTreeModel.prototype.frameDetachedFromParent):
        (WebInspector.ResourceTreeModel.prototype._clearChildFramesAndResources):
        (WebInspector.ResourceTreeModel.prototype.addResourceToFrame):
        (WebInspector.ResourceTreeModel.prototype._clearResources):
        (WebInspector.ResourceTreeModel.prototype.forAllResources):
        (WebInspector.ResourceTreeModel.prototype.addConsoleMessage):
        (WebInspector.ResourceTreeModel.prototype.clearConsoleMessages):
        (WebInspector.ResourceTreeModel.prototype._callForFrameResources):
        (WebInspector.ResourceTreeModel.prototype.resourceForURL):
        (WebInspector.ResourceTreeModel.prototype.bindResourceURL):
        (WebInspector.ResourceTreeModel.prototype._unbindResourceURL):
        (WebInspector.ResourceTreeModel.createResource):
        * inspector/front-end/ResourceView.js:
        (WebInspector.ResourceView.createResourceView):
        (WebInspector.ResourceView.resourceViewTypeMatchesResource):
        (WebInspector.ResourceView.resourceViewForResource):
        (WebInspector.ResourceView.recreateResourceView):
        (WebInspector.ResourceView.existingResourceViewForResource):
        * inspector/front-end/ResourcesPanel.js:
        (WebInspector.ResourcesPanel.prototype.canShowSourceLine):
        (WebInspector.ResourcesPanel.prototype.showSourceLine):
        (WebInspector.ResourcesPanel.prototype.showResource):
        (WebInspector.ResourcesPanel.prototype.get searchableViews.callback):
        (WebInspector.ResourcesPanel.prototype.get searchableViews):
        (WebInspector.FrameResourceTreeElement.prototype._errorsWarningsUpdated):
        (WebInspector.FrameResourceTreeElement.prototype._contentChanged):
        * inspector/front-end/ScriptsPanel.js:
        (WebInspector.ScriptsPanel.prototype._addScript):
        (WebInspector.ScriptsPanel.prototype.reset):
        (WebInspector.ScriptsPanel.prototype._sourceFrameForResource):
        (WebInspector.ScriptsPanel.prototype._showScriptOrResource):
        * inspector/front-end/WebKit.qrc:
        * inspector/front-end/inspector.html:
        * inspector/front-end/inspector.js:
        (WebInspector.forAllResources):
        (WebInspector.resourceForURL):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@74709 268f45cc-cd09-0410-ab3c-d52691b4dbfc

24 files changed:
WebCore/ChangeLog
WebCore/WebCore.gypi
WebCore/WebCore.vcproj/WebCore.vcproj
WebCore/inspector/CodeGeneratorInspector.pm
WebCore/inspector/Inspector.idl
WebCore/inspector/front-end/AuditRules.js
WebCore/inspector/front-end/CSSStyleModel.js
WebCore/inspector/front-end/ConsoleView.js
WebCore/inspector/front-end/DOMAgent.js
WebCore/inspector/front-end/DOMStorage.js
WebCore/inspector/front-end/Database.js
WebCore/inspector/front-end/FileSystemView.js
WebCore/inspector/front-end/NetworkItemView.js
WebCore/inspector/front-end/NetworkManager.js [new file with mode: 0644]
WebCore/inspector/front-end/NetworkPanel.js
WebCore/inspector/front-end/Resource.js
WebCore/inspector/front-end/ResourceManager.js [deleted file]
WebCore/inspector/front-end/ResourceTreeModel.js [new file with mode: 0644]
WebCore/inspector/front-end/ResourceView.js
WebCore/inspector/front-end/ResourcesPanel.js
WebCore/inspector/front-end/ScriptsPanel.js
WebCore/inspector/front-end/WebKit.qrc
WebCore/inspector/front-end/inspector.html
WebCore/inspector/front-end/inspector.js

index a38cca4..b72422d 100644 (file)
@@ -1,3 +1,119 @@
+2010-12-21  Ilya Tikhonovsky  <loislo@chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: Protocol cleanup task. Introduce Network, DOMStorage and Database domains.
+
+        Domain was changed for Resources, FileSystem etc. related methods.
+        ResourcesManager was renamed to NetworkManager.
+        ResourceTreeModel was extracted as separate file.
+        FileSystem, Database, DOMStorage and ApplicationCache methods were
+        removed from NetworkManager and added to corresponding classes.
+
+        https://bugs.webkit.org/show_bug.cgi?id=51334
+
+        * WebCore.gypi:
+        * WebCore.vcproj/WebCore.vcproj:
+        * inspector/CodeGeneratorInspector.pm:
+        * inspector/Inspector.idl:
+        * inspector/front-end/AuditRules.js:
+        (WebInspector.AuditRules.UnusedCssRule.prototype.doRun.evalCallback.selectorsCallback):
+        * inspector/front-end/CSSStyleModel.js:
+        (WebInspector.CSSStyleModel.prototype._styleSheetChanged.callback):
+        (WebInspector.CSSStyleModel.prototype._styleSheetChanged):
+        * inspector/front-end/ConsoleView.js:
+        (WebInspector.ConsoleView.prototype.addMessage):
+        (WebInspector.ConsoleView.prototype.clearMessages):
+        * inspector/front-end/DOMAgent.js:
+        (WebInspector.ApplicationCache.updateApplicationCacheStatus):
+        (WebInspector.ApplicationCache.updateNetworkState):
+        * inspector/front-end/DOMStorage.js:
+        (WebInspector.DOMStorage.addDOMStorage):
+        (WebInspector.DOMStorage.selectDOMStorage):
+        (WebInspector.DOMStorage.updateDOMStorage):
+        * inspector/front-end/Database.js:
+        (WebInspector.Database.prototype.executeSql):
+        (WebInspector.Database.addDatabase):
+        (WebInspector.Database.selectDatabase):
+        (WebInspector.Database.sqlTransactionSucceeded):
+        (WebInspector.Database.sqlTransactionFailed):
+        * inspector/front-end/FileSystemView.js:
+        (WebInspector.FileSystem.didGetFileSystemPath):
+        (WebInspector.FileSystem.didGetFileSystemError):
+        (WebInspector.FileSystem.didGetFileSystemDisabled):
+        * inspector/front-end/NetworkItemView.js:
+        (WebInspector.NetworkItemView):
+        * inspector/front-end/NetworkManager.js: Added.
+        (WebInspector.NetworkManager):
+        (WebInspector.NetworkManager.prototype._createResource):
+        (WebInspector.NetworkManager.prototype.identifierForInitialRequest):
+        (WebInspector.NetworkManager.prototype.willSendRequest):
+        (WebInspector.NetworkManager.prototype._updateResourceWithRequest):
+        (WebInspector.NetworkManager.prototype._appendRedirect):
+        (WebInspector.NetworkManager.prototype.markResourceAsCached):
+        (WebInspector.NetworkManager.prototype.didReceiveResponse):
+        (WebInspector.NetworkManager.prototype._updateResourceWithResponse):
+        (WebInspector.NetworkManager.prototype.didReceiveContentLength):
+        (WebInspector.NetworkManager.prototype.didFinishLoading):
+        (WebInspector.NetworkManager.prototype.didFailLoading):
+        (WebInspector.NetworkManager.prototype.didLoadResourceFromMemoryCache):
+        (WebInspector.NetworkManager.prototype._updateResourceWithCachedResource):
+        (WebInspector.NetworkManager.prototype.setInitialContent):
+        (WebInspector.NetworkManager.prototype.didCommitLoadForFrame):
+        (WebInspector.NetworkManager.prototype.frameDetachedFromParent):
+        (WebInspector.NetworkManager.prototype.didCreateWebSocket):
+        (WebInspector.NetworkManager.prototype.willSendWebSocketHandshakeRequest):
+        (WebInspector.NetworkManager.prototype.didReceiveWebSocketHandshakeResponse):
+        (WebInspector.NetworkManager.prototype.didCloseWebSocket):
+        (WebInspector.NetworkManager.prototype._processCachedResources):
+        (WebInspector.NetworkManager.prototype._addFramesRecursively):
+        (WebInspector.NetworkManager.requestContent):
+        * inspector/front-end/NetworkPanel.js:
+        (WebInspector.NetworkPanel.prototype.refreshResource):
+        * inspector/front-end/Resource.js:
+        (WebInspector.Resource.prototype._innerRequestContent):
+        * inspector/front-end/ResourceManager.js: Removed.
+        * inspector/front-end/ResourceTreeModel.js: Added.
+        (WebInspector.ResourceTreeModel):
+        (WebInspector.ResourceTreeModel.prototype.addOrUpdateFrame):
+        (WebInspector.ResourceTreeModel.prototype.didCommitLoadForFrame):
+        (WebInspector.ResourceTreeModel.prototype.frameDetachedFromParent):
+        (WebInspector.ResourceTreeModel.prototype._clearChildFramesAndResources):
+        (WebInspector.ResourceTreeModel.prototype.addResourceToFrame):
+        (WebInspector.ResourceTreeModel.prototype._clearResources):
+        (WebInspector.ResourceTreeModel.prototype.forAllResources):
+        (WebInspector.ResourceTreeModel.prototype.addConsoleMessage):
+        (WebInspector.ResourceTreeModel.prototype.clearConsoleMessages):
+        (WebInspector.ResourceTreeModel.prototype._callForFrameResources):
+        (WebInspector.ResourceTreeModel.prototype.resourceForURL):
+        (WebInspector.ResourceTreeModel.prototype.bindResourceURL):
+        (WebInspector.ResourceTreeModel.prototype._unbindResourceURL):
+        (WebInspector.ResourceTreeModel.createResource):
+        * inspector/front-end/ResourceView.js:
+        (WebInspector.ResourceView.createResourceView):
+        (WebInspector.ResourceView.resourceViewTypeMatchesResource):
+        (WebInspector.ResourceView.resourceViewForResource):
+        (WebInspector.ResourceView.recreateResourceView):
+        (WebInspector.ResourceView.existingResourceViewForResource):
+        * inspector/front-end/ResourcesPanel.js:
+        (WebInspector.ResourcesPanel.prototype.canShowSourceLine):
+        (WebInspector.ResourcesPanel.prototype.showSourceLine):
+        (WebInspector.ResourcesPanel.prototype.showResource):
+        (WebInspector.ResourcesPanel.prototype.get searchableViews.callback):
+        (WebInspector.ResourcesPanel.prototype.get searchableViews):
+        (WebInspector.FrameResourceTreeElement.prototype._errorsWarningsUpdated):
+        (WebInspector.FrameResourceTreeElement.prototype._contentChanged):
+        * inspector/front-end/ScriptsPanel.js:
+        (WebInspector.ScriptsPanel.prototype._addScript):
+        (WebInspector.ScriptsPanel.prototype.reset):
+        (WebInspector.ScriptsPanel.prototype._sourceFrameForResource):
+        (WebInspector.ScriptsPanel.prototype._showScriptOrResource):
+        * inspector/front-end/WebKit.qrc:
+        * inspector/front-end/inspector.html:
+        * inspector/front-end/inspector.js:
+        (WebInspector.forAllResources):
+        (WebInspector.resourceForURL):
+
 2010-12-27  Helder Correia  <helder@sencha.com>
 
         Reviewed by Ariya Hidayat.
index 4f4b463..f62d883 100644 (file)
             'inspector/front-end/KeyboardShortcut.js',
             'inspector/front-end/MetricsSidebarPane.js',
             'inspector/front-end/NetworkItemView.js',
+            'inspector/front-end/NetworkManager.js',
             'inspector/front-end/NetworkPanel.js',
             'inspector/front-end/Object.js',
             'inspector/front-end/ObjectPropertiesSection.js',
             'inspector/front-end/Resource.js',
             'inspector/front-end/ResourceCategory.js',
             'inspector/front-end/ResourceCookiesView.js',
-            'inspector/front-end/ResourceManager.js',
             'inspector/front-end/ResourceHeadersView.js',
             'inspector/front-end/ResourceTimingView.js',
+            'inspector/front-end/ResourceTreeModel.js',
             'inspector/front-end/ResourceView.js',
             'inspector/front-end/ResourcesPanel.js',
             'inspector/front-end/ScopeChainSidebarPane.js',
index 323e526..ede14b2 100755 (executable)
                                        >
                                </File>
                                <File
+                                       RelativePath="..\inspector\front-end\NetworkManager.js"
+                                       >
+                               </File>
+                               <File
                                        RelativePath="..\inspector\front-end\networkPanel.css"
                                        >
                                </File>
                                        >
                                </File>
                                <File
-                                       RelativePath="..\inspector\front-end\ResourceManager.js"
+                                       RelativePath="..\inspector\front-end\ResourcesPanel.js"
                                        >
                                </File>
                                <File
-                                       RelativePath="..\inspector\front-end\ResourcesPanel.js"
+                                       RelativePath="..\inspector\front-end\ResourceTimingView.js"
                                        >
                                </File>
                                <File
-                                       RelativePath="..\inspector\front-end\ResourceTimingView.js"
+                                       RelativePath="..\inspector\front-end\ResourceTreeModel.js"
                                        >
                                </File>
                                <File
index e960ed6..95f7e8f 100644 (file)
@@ -33,6 +33,20 @@ $typeTransform{"Resources"} = {
     "header" => "InspectorResourceAgent.h",
     "domainAccessor" => "m_inspectorController->m_resourceAgent",
 };
+$typeTransform{"Network"} = {
+    "forward" => "InspectorResourceAgent",
+    "header" => "InspectorResourceAgent.h",
+    "domainAccessor" => "m_inspectorController->m_resourceAgent",
+};
+$typeTransform{"DOMStorage"} = {
+    "forwardHeader" => "InspectorController.h",
+    "domainAccessor" => "m_inspectorController",
+};
+$typeTransform{"Database"} = {
+    "forward" => "InspectorBackend",
+    "header" => "InspectorBackend.h",
+    "domainAccessor" => "m_inspectorController->inspectorBackend()",
+};
 $typeTransform{"DOM"} = {
     "forward" => "InspectorDOMAgent",
     "header" => "InspectorDOMAgent.h",
index a593857..56feb01 100644 (file)
@@ -67,6 +67,8 @@ module core {
         [domain=Inspector] void hideFrameHighlight();
         [notify, domain=Inspector] void updateFocusedNode(out long nodeId);
 
+        [domain=Inspector] void setExtraHeaders(in Object headers);
+
         ///////////////////////////////////////////////////////////////////////
         // Console API
         ///////////////////////////////////////////////////////////////////////
@@ -79,67 +81,63 @@ module core {
         [notify, domain=Inspector] void consoleMessagesCleared();
 
         ///////////////////////////////////////////////////////////////////////
-        // Resources API
+        // Network API
         ///////////////////////////////////////////////////////////////////////
 
-        // FIXME: Network domain
-        [notify, domain=Resources] void identifierForInitialRequest(out long identifier, out String url, out Object loader, out Value callStack);
-        [notify, domain=Resources] void willSendRequest(out long identifier, out double time, out Object request, out Object redirectResponse);
-        [notify, domain=Resources] void markResourceAsCached(out long identifier);
-        [notify, domain=Resources] void didReceiveResponse(out long identifier, out double time, out String resourceType, out Object response);
-        [notify, domain=Resources] void didReceiveContentLength(out long identifier, out double time, out long lengthReceived);
-        [notify, domain=Resources] void didFinishLoading(out long identifier, out double finishTime);
-        [notify, domain=Resources] void didFailLoading(out long identifier, out double time, out String localizedDescription);
-        [notify, domain=Resources] void didLoadResourceFromMemoryCache(out double time, out Object resource);
-        [notify, domain=Resources] void setInitialContent(out long identifier, out String sourceString, out String type);
-        [notify, domain=Resources] void didCommitLoadForFrame(out Object frame, out Object loader);
-        [notify, domain=Resources] void frameDetachedFromParent(out unsigned long frameId);
-       
-        [domain=Inspector] void setExtraHeaders(in Object headers);
+        [notify, domain=Network] void identifierForInitialRequest(out long identifier, out String url, out Object loader, out Value callStack);
+        [notify, domain=Network] void willSendRequest(out long identifier, out double time, out Object request, out Object redirectResponse);
+        [notify, domain=Network] void markResourceAsCached(out long identifier);
+        [notify, domain=Network] void didReceiveResponse(out long identifier, out double time, out String resourceType, out Object response);
+        [notify, domain=Network] void didReceiveContentLength(out long identifier, out double time, out long lengthReceived);
+        [notify, domain=Network] void didFinishLoading(out long identifier, out double finishTime);
+        [notify, domain=Network] void didFailLoading(out long identifier, out double time, out String localizedDescription);
+        [notify, domain=Network] void didLoadResourceFromMemoryCache(out double time, out Object resource);
+        [notify, domain=Network] void setInitialContent(out long identifier, out String sourceString, out String type);
+        [notify, domain=Network] void didCommitLoadForFrame(out Object frame, out Object loader);
+        [notify, domain=Network] void didCreateWebSocket(out unsigned long identifier, out String requestURL);
+        [notify, domain=Network] void willSendWebSocketHandshakeRequest(out unsigned long identifier, out double time, out Object request);
+        [notify, domain=Network] void didReceiveWebSocketHandshakeResponse(out unsigned long identifier, out double time, out Object response);
+        [notify, domain=Network] void didCloseWebSocket(out unsigned long identifier, out double time);
+
+        ///////////////////////////////////////////////////////////////////////
+        // Resources API
+        ///////////////////////////////////////////////////////////////////////
 
         [domain=Resources] void cachedResources(out Object resources);
         [domain=Resources] void resourceContent(in unsigned long frameId, in String url, in boolean base64Encode, out String content);
-
-        [notify, domain=Resources] void didCreateWebSocket(out unsigned long identifier, out String requestURL);
-        [notify, domain=Resources] void willSendWebSocketHandshakeRequest(out unsigned long identifier, out double time, out Object request);
-        [notify, domain=Resources] void didReceiveWebSocketHandshakeResponse(out unsigned long identifier, out double time, out Object response);
-        [notify, domain=Resources] void didCloseWebSocket(out unsigned long identifier, out double time);
+        [notify, domain=Resources] void frameDetachedFromParent(out unsigned long frameId);
 
         // FIXME: Introduce new StorageDomain.
         [domain=Inspector] void getCookies(out Array cookies, out String cookiesString);
         [domain=Inspector] void deleteCookie(in String cookieName, in String domain);
 #if defined(ENABLE_DATABASE) && ENABLE_DATABASE
-        [notify, domain=Resources] void addDatabase(out Object database);
-        [notify, domain=Resources] void selectDatabase(out int databaseId);
-        [domain=Backend] void getDatabaseTableNames(in long databaseId, out Array tableNames);
-        [domain=Backend] void executeSQL(in long databaseId, in String query, out boolean success, out long transactionId);
-        [notify, domain=Resources] void sqlTransactionSucceeded(out long transactionId, out Value columnNames, out Value values);
-        [notify, domain=Resources] void sqlTransactionFailed(out long transactionId, out Value sqlError);
+        [notify, domain=Database] void addDatabase(out Object database);
+        [notify, domain=Database] void selectDatabase(out int databaseId);
+        [domain=Database] void getDatabaseTableNames(in long databaseId, out Array tableNames);
+        [domain=Database] void executeSQL(in long databaseId, in String query, out boolean success, out long transactionId);
+        [notify, domain=Database] void sqlTransactionSucceeded(out long transactionId, out Value columnNames, out Value values);
+        [notify, domain=Database] void sqlTransactionFailed(out long transactionId, out Value sqlError);
 #endif
 #if defined(ENABLE_DOM_STORAGE) && ENABLE_DOM_STORAGE
-        [domain=Inspector] void getDOMStorageEntries(in long storageId, out Array entries);
-        [domain=Inspector] void setDOMStorageItem(in long storageId, in String key, in String value, out boolean success);
-        [domain=Inspector] void removeDOMStorageItem(in long storageId, in String key, out boolean success);
-        // FIXME: nuke these from resource manager asap, dispatch on StorageDomain.
-        [notify, domain=Resources] void addDOMStorage(out Object storage);
-        [notify, domain=Resources] void updateDOMStorage(out int storageId);
-        [notify, domain=Resources] void selectDOMStorage(out int storageId);
-#endif
-#if defined(ENABLE_OFFLINE_WEB_APPLICATIONS) && ENABLE_OFFLINE_WEB_APPLICATIONS
-        [notify, domain=Resources] void updateApplicationCacheStatus(out int status);
-        [notify, domain=Resources] void updateNetworkState(out boolean isNowOnline);
+        [domain=DOMStorage] void getDOMStorageEntries(in long storageId, out Array entries);
+        [domain=DOMStorage] void setDOMStorageItem(in long storageId, in String key, in String value, out boolean success);
+        [domain=DOMStorage] void removeDOMStorageItem(in long storageId, in String key, out boolean success);
+        [notify, domain=DOMStorage] void addDOMStorage(out Object storage);
+        [notify, domain=DOMStorage] void updateDOMStorage(out int storageId);
+        [notify, domain=DOMStorage] void selectDOMStorage(out int storageId);
 #endif
 #if defined(ENABLE_OFFLINE_WEB_APPLICATIONS) && ENABLE_OFFLINE_WEB_APPLICATIONS
         [domain=ApplicationCache] void getApplicationCaches(out Value applicationCaches);
+        [notify, domain=ApplicationCache] void updateApplicationCacheStatus(out int status);
+        [notify, domain=ApplicationCache] void updateNetworkState(out boolean isNowOnline);
 #endif
 #if defined(ENABLE_FILE_SYSTEM) && ENABLE_FILE_SYSTEM
         [domain=FileSystem] void getFileSystemPathAsync(in unsigned int type, in String origin);
         [domain=FileSystem] void revealFolderInOS(in String path);
 
-        // FIXME: nuke these from resource manager asap, dispatch on FileSystem.
-        [notify, domain=Resources] void didGetFileSystemPath(out String root, out int type, out String origin);
-        [notify, domain=Resources] void didGetFileSystemError(out int type, out String origin);
-        [notify, domain=Resources] void didGetFileSystemDisabled();
+        [notify, domain=FileSystem] void didGetFileSystemPath(out String root, out int type, out String origin);
+        [notify, domain=FileSystem] void didGetFileSystemError(out int type, out String origin);
+        [notify, domain=FileSystem] void didGetFileSystemDisabled();
 #endif
 
         ///////////////////////////////////////////////////////////////////////
index cd1b34f..3f79c25 100644 (file)
@@ -326,7 +326,7 @@ WebInspector.AuditRules.UnusedCssRule.prototype = {
                     if (!unusedRules.length)
                         continue;
 
-                    var resource = WebInspector.resourceManager.resourceForURL(styleSheet.sourceURL);
+                    var resource = WebInspector.resourceTreeModel.resourceForURL(styleSheet.sourceURL);
                     var isInlineBlock = resource && resource.type == WebInspector.Resource.Type.Document;
                     var url = !isInlineBlock ? WebInspector.AuditRuleResult.linkifyDisplayName(styleSheet.sourceURL) : String.sprintf("Inline block #%d", ++inlineBlockOrdinal);
                     var pctUnused = Math.round(100 * unusedStylesheetSize / stylesheetSize);
index 2d15582..e8d75b7 100644 (file)
@@ -162,7 +162,7 @@ WebInspector.CSSStyleModel.prototype = {
 
         function callback(href, content)
         {
-            var resource = WebInspector.resourceManager.resourceForURL(href);
+            var resource = WebInspector.resourceTreeModel.resourceForURL(href);
             if (resource && resource.type === WebInspector.Resource.Type.Stylesheet)
                 resource.setContent(content, this._onRevert.bind(this, styleSheetId));
         }
index 03fe14a..c98552d 100644 (file)
@@ -218,7 +218,7 @@ WebInspector.ConsoleView.prototype = {
 
         if (msg instanceof WebInspector.ConsoleMessage && !(msg instanceof WebInspector.ConsoleCommandResult)) {
             this._incrementErrorWarningCount(msg);
-            WebInspector.resourceManager.addConsoleMessage(msg);
+            WebInspector.resourceTreeModel.addConsoleMessage(msg);
             this.commandSincePreviousMessage = false;
             this.previousMessage = msg;
         } else if (msg instanceof WebInspector.ConsoleCommand) {
@@ -285,7 +285,7 @@ WebInspector.ConsoleView.prototype = {
 
     clearMessages: function()
     {
-        WebInspector.resourceManager.clearConsoleMessages();
+        WebInspector.resourceTreeModel.clearConsoleMessages();
 
         this.messages = [];
 
index 432ac3f..89822a3 100644 (file)
@@ -471,6 +471,18 @@ WebInspector.ApplicationCache.getApplicationCachesAsync = function(callback)
     InspectorBackend.getApplicationCaches(mycallback);
 }
 
+WebInspector.ApplicationCache.updateApplicationCacheStatus = function(status)
+{
+    WebInspector.panels.resources.updateApplicationCacheStatus(status);
+}
+
+WebInspector.ApplicationCache.updateNetworkState = function(isNowOnline)
+{
+    WebInspector.panels.resources.updateNetworkState(isNowOnline);
+}
+
+InspectorBackend.registerDomainDispatcher("ApplicationCache", WebInspector.ApplicationCache);
+
 WebInspector.Cookies = {}
 
 WebInspector.Cookies.getCookiesAsync = function(callback)
index 37be8f6..aa14a9c 100644 (file)
@@ -70,3 +70,26 @@ WebInspector.DOMStorage.prototype = {
     }
 }
 
+WebInspector.DOMStorage.addDOMStorage = function(payload)
+{
+    if (!WebInspector.panels.resources)
+        return;
+    var domStorage = new WebInspector.DOMStorage(
+        payload.id,
+        payload.host,
+        payload.isLocalStorage);
+    WebInspector.panels.resources.addDOMStorage(domStorage);
+}
+
+WebInspector.DOMStorage.selectDOMStorage = function(o)
+{
+    WebInspector.showPanel("resources");
+    WebInspector.panels.resources.selectDOMStorage(o);
+}
+
+WebInspector.DOMStorage.updateDOMStorage = function(storageId)
+{
+    WebInspector.panels.resources.updateDOMStorage(storageId);
+}
+
+InspectorBackend.registerDomainDispatcher("DOMStorage", WebInspector.DOMStorage);
index 7aac7d1..0b00330 100644 (file)
@@ -34,8 +34,7 @@ WebInspector.Database = function(id, domain, name, version)
     this._version = version;
 }
 
-WebInspector.Database.successCallbacks = {};
-WebInspector.Database.errorCallbacks = {};
+WebInspector.Database._callbacks = {};
 
 WebInspector.Database.prototype = {
     get id()
@@ -95,9 +94,50 @@ WebInspector.Database.prototype = {
                 onError(WebInspector.UIString("Database not found."));
                 return;
             }
-            WebInspector.Database.successCallbacks[transactionId] = onSuccess;
-            WebInspector.Database.errorCallbacks[transactionId] = onError;
+            WebInspector.Database._callbacks[transactionId] = {"onSuccess": onSuccess, "onError": onError};
         }
         InspectorBackend.executeSQL(this._id, query, callback);
     }
 }
+
+WebInspector.Database.addDatabase = function(payload)
+{
+    if (!WebInspector.panels.resources)
+        return;
+    var database = new WebInspector.Database(
+        payload.id,
+        payload.domain,
+        payload.name,
+        payload.version);
+    WebInspector.panels.resources.addDatabase(database);
+}
+
+WebInspector.Database.selectDatabase = function(o)
+{
+    WebInspector.showPanel("resources");
+    WebInspector.panels.resources.selectDatabase(o);
+}
+
+WebInspector.Database.sqlTransactionSucceeded = function(transactionId, columnNames, values)
+{
+    if (!WebInspector.Database._callbacks[transactionId])
+        return;
+
+    var callback = WebInspector.Database._callbacks[transactionId].onSuccess;
+    delete WebInspector.Database._callbacks[transactionId];
+    if (callback)
+        callback(columnNames, values);
+}
+
+WebInspector.Database.sqlTransactionFailed = function(transactionId, errorObj)
+{
+    if (!WebInspector.Database._callbacks[transactionId])
+        return;
+
+    var callback = WebInspector.Database._callbacks[transactionId].onError;
+    delete WebInspector.Database._callbacks[transactionId];
+    if (callback)
+        callback(errorObj);
+}
+
+InspectorBackend.registerDomainDispatcher("Database", WebInspector.Database);
index 8cd0107..14ecf46 100644 (file)
@@ -40,6 +40,23 @@ WebInspector.FileSystem.getFileSystemPathsAsync = function(origin)
     InspectorBackend.getFileSystemPathAsync(WebInspector.FileSystem.TEMPORARY, origin);
 }
 
+WebInspector.FileSystem.didGetFileSystemPath = function(root, type, origin)
+{
+    WebInspector.panels.resources.updateFileSystemPath(root, type, origin);
+}
+
+WebInspector.FileSystem.didGetFileSystemError = function(type, origin)
+{
+    WebInspector.panels.resources.updateFileSystemError(type, origin);
+}
+
+WebInspector.FileSystem.didGetFileSystemDisabled = function()
+{
+    WebInspector.panels.resources.setFileSystemDisabled();
+}
+
+InspectorBackend.registerDomainDispatcher("FileSystem", WebInspector.FileSystem);
+
 WebInspector.FileSystemView = function(treeElement, fileSystemOrigin)
 {
     WebInspector.View.call(this);
index 48e3b19..418f559 100644 (file)
@@ -36,7 +36,7 @@ WebInspector.NetworkItemView = function(resource)
 
     this._headersView = new WebInspector.ResourceHeadersView(resource);
     // Do not store reference to content view - it can be recreated.
-    var contentView = WebInspector.ResourceManager.resourceViewForResource(resource);
+    var contentView = WebInspector.ResourceView.resourceViewForResource(resource);
 
     this._tabbedPane = new WebInspector.TabbedPane(this.element);
     this._tabbedPane.appendTab("headers", WebInspector.UIString("Headers"), this._headersView);
diff --git a/WebCore/inspector/front-end/NetworkManager.js b/WebCore/inspector/front-end/NetworkManager.js
new file mode 100644 (file)
index 0000000..b8cd481
--- /dev/null
@@ -0,0 +1,297 @@
+/*
+ * Copyright (C) 2009, 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+WebInspector.NetworkManager = function(resourceTreeModel)
+{
+    this._resourcesById = {};
+    this._resourceTreeModel = resourceTreeModel;
+    InspectorBackend.registerDomainDispatcher("Network", this);
+}
+
+WebInspector.NetworkManager.requestContent = function(resource, base64Encode, callback)
+{
+    InspectorBackend.resourceContent(resource.loader.frameId, resource.url, base64Encode, callback);
+}
+
+WebInspector.NetworkManager.updateResourceWithRequest = function(resource, request)
+{
+    resource.requestMethod = request.httpMethod;
+    resource.requestHeaders = request.httpHeaderFields;
+    resource.requestFormData = request.requestFormData;
+}
+
+WebInspector.NetworkManager.updateResourceWithResponse = function(resource, response)
+{
+    if (resource.isNull)
+        return;
+
+    resource.mimeType = response.mimeType;
+    resource.expectedContentLength = response.expectedContentLength;
+    resource.textEncodingName = response.textEncodingName;
+    resource.suggestedFilename = response.suggestedFilename;
+    resource.statusCode = response.httpStatusCode;
+    resource.statusText = response.httpStatusText;
+
+    resource.responseHeaders = response.httpHeaderFields;
+    resource.connectionReused = response.connectionReused;
+    resource.connectionID = response.connectionID;
+
+    if (response.wasCached)
+        resource.cached = true;
+    else
+        resource.timing = response.timing;
+
+    if (response.loadInfo) {
+        if (response.loadInfo.httpStatusCode)
+            resource.statusCode = response.loadInfo.httpStatusCode;
+        if (response.loadInfo.httpStatusText)
+            resource.statusText = response.loadInfo.httpStatusText;
+        resource.requestHeaders = response.loadInfo.requestHeaders;
+        resource.responseHeaders = response.loadInfo.responseHeaders;
+    }
+}
+
+WebInspector.NetworkManager.updateResourceWithCachedResource = function(resource, cachedResource)
+{
+    resource.type = WebInspector.Resource.Type[cachedResource.type];
+    resource.resourceSize = cachedResource.encodedSize;
+    WebInspector.NetworkManager.updateResourceWithResponse(resource, cachedResource.response);
+}
+
+WebInspector.NetworkManager.prototype = {
+    identifierForInitialRequest: function(identifier, url, loader, callStack)
+    {
+        var resource = this._createResource(identifier, url, loader, callStack);
+
+        // It is important to bind resource url early (before scripts compile).
+        this._resourceTreeModel.bindResourceURL(resource);
+
+        WebInspector.panels.network.refreshResource(resource);
+        WebInspector.panels.audits.resourceStarted(resource);
+    },
+
+    willSendRequest: function(identifier, time, request, redirectResponse)
+    {
+        var resource = this._resourcesById[identifier];
+        if (!resource)
+            return;
+
+        // Redirect may have empty URL and we'd like to not crash with invalid HashMap entry.
+        // See http/tests/misc/will-send-request-returns-null-on-redirect.html
+        var isRedirect = !redirectResponse.isNull && request.url.length;
+        if (isRedirect) {
+            resource.endTime = time;
+            this.didReceiveResponse(identifier, time, "Other", redirectResponse);
+            resource = this._appendRedirect(resource.identifier, request.url);
+        }
+
+        WebInspector.NetworkManager.updateResourceWithRequest(resource, request);
+        resource.startTime = time;
+
+        if (isRedirect) {
+            WebInspector.panels.network.refreshResource(resource);
+            WebInspector.panels.audits.resourceStarted(resource);
+        } else
+            WebInspector.panels.network.refreshResource(resource);
+    },
+
+    markResourceAsCached: function(identifier)
+    {
+        var resource = this._resourcesById[identifier];
+        if (!resource)
+            return;
+
+        resource.cached = true;
+        WebInspector.panels.network.refreshResource(resource);
+    },
+
+    didReceiveResponse: function(identifier, time, resourceType, response)
+    {
+        var resource = this._resourcesById[identifier];
+        if (!resource)
+            return;
+
+        resource.responseReceivedTime = time;
+        resource.type = WebInspector.Resource.Type[resourceType];
+
+        WebInspector.NetworkManager.updateResourceWithResponse(resource, response);
+
+        WebInspector.panels.network.refreshResource(resource);
+        this._resourceTreeModel.addResourceToFrame(resource.loader.frameId, resource);
+    },
+
+    didReceiveContentLength: function(identifier, time, lengthReceived)
+    {
+        var resource = this._resourcesById[identifier];
+        if (!resource)
+            return;
+
+        resource.resourceSize += lengthReceived;
+        resource.endTime = time;
+
+        WebInspector.panels.network.refreshResource(resource);
+    },
+
+    didFinishLoading: function(identifier, finishTime)
+    {
+        var resource = this._resourcesById[identifier];
+        if (!resource)
+            return;
+
+        resource.endTime = finishTime;
+        resource.finished = true;
+
+        WebInspector.panels.network.refreshResource(resource);
+        WebInspector.panels.audits.resourceFinished(resource);
+        WebInspector.extensionServer.notifyResourceFinished(resource);
+        delete this._resourcesById[identifier];
+    },
+
+    didFailLoading: function(identifier, time, localizedDescription)
+    {
+        var resource = this._resourcesById[identifier];
+        if (!resource)
+            return;
+
+        resource.failed = true;
+        resource.localizedFailDescription = localizedDescription;
+        resource.finished = true;
+        resource.endTime = time;
+
+        WebInspector.panels.network.refreshResource(resource);
+        WebInspector.panels.audits.resourceFinished(resource);
+        WebInspector.extensionServer.notifyResourceFinished(resource);
+        delete this._resourcesById[identifier];
+    },
+
+    didLoadResourceFromMemoryCache: function(time, cachedResource)
+    {
+        var resource = this._createResource(null, cachedResource.url, cachedResource.loader);
+        WebInspector.NetworkManager.updateResourceWithCachedResource(resource, cachedResource);
+        resource.cached = true;
+        resource.requestMethod = "GET";
+        resource.startTime = resource.responseReceivedTime = resource.endTime = time;
+        resource.finished = true;
+
+        WebInspector.panels.network.refreshResource(resource);
+        WebInspector.panels.audits.resourceStarted(resource);
+        WebInspector.panels.audits.resourceFinished(resource);
+        this._resourceTreeModel.addResourceToFrame(resource.loader.frameId, resource);
+    },
+
+    setInitialContent: function(identifier, sourceString, type)
+    {
+        var resource = WebInspector.panels.network.resources[identifier];
+        if (!resource)
+            return;
+
+        resource.type = WebInspector.Resource.Type[type];
+        resource.setInitialContent(sourceString);
+        WebInspector.panels.resources.refreshResource(resource);
+        WebInspector.panels.network.refreshResource(resource);
+    },
+
+    didCommitLoadForFrame: function(frame, loader)
+    {
+        this._resourceTreeModel.didCommitLoadForFrame(frame, loader);
+        if (!frame.parentId) {
+            var mainResource = this._resourceTreeModel.resourceForURL(frame.url);
+            if (mainResource) {
+                WebInspector.mainResource = mainResource;
+                mainResource.isMainResource = true;
+            }
+        }
+    },
+
+    didCreateWebSocket: function(identifier, requestURL)
+    {
+        var resource = this._createResource(identifier, requestURL);
+        resource.type = WebInspector.Resource.Type.WebSocket;
+        WebInspector.panels.network.refreshResource(resource);
+    },
+
+    willSendWebSocketHandshakeRequest: function(identifier, time, request)
+    {
+        var resource = this._resourcesById[identifier];
+        if (!resource)
+            return;
+
+        resource.requestMethod = "GET";
+        resource.requestHeaders = request.webSocketHeaderFields;
+        resource.webSocketRequestKey3 = request.webSocketRequestKey3;
+        resource.startTime = time;
+
+        WebInspector.panels.network.refreshResource(resource);
+    },
+
+    didReceiveWebSocketHandshakeResponse: function(identifier, time, response)
+    {
+        var resource = this._resourcesById[identifier];
+        if (!resource)
+            return;
+
+        resource.statusCode = response.statusCode;
+        resource.statusText = response.statusText;
+        resource.responseHeaders = response.webSocketHeaderFields;
+        resource.webSocketChallengeResponse = response.webSocketChallengeResponse;
+        resource.responseReceivedTime = time;
+
+        WebInspector.panels.network.refreshResource(resource);
+    },
+
+    didCloseWebSocket: function(identifier, time)
+    {
+        var resource = this._resourcesById[identifier];
+        if (!resource)
+            return;
+        resource.endTime = time;
+
+        WebInspector.panels.network.refreshResource(resource);
+    },
+
+    _createResource: function(identifier, url, loader, callStack)
+    {
+        var resource = WebInspector.ResourceTreeModel.createResource(identifier, url, loader, callStack);
+        this._resourcesById[identifier] = resource;
+        return resource;
+    },
+
+    _appendRedirect: function(identifier, redirectURL)
+    {
+        var originalResource = this._resourcesById[identifier];
+        originalResource.identifier = null;
+
+        var newResource = this._createResource(identifier, redirectURL, originalResource.loader, originalResource.stackTrace);
+        newResource.redirects = originalResource.redirects || [];
+        delete originalResource.redirects;
+        newResource.redirects.push(originalResource);
+        return newResource;
+    }
+}
index 9941dbf..7b6df8b 100644 (file)
@@ -797,14 +797,14 @@ WebInspector.NetworkPanel.prototype = {
         if (!resource)
             return;
 
-        var oldView = WebInspector.ResourceManager.existingResourceViewForResource(resource);
+        var oldView = WebInspector.ResourceView.existingResourceViewForResource(resource);
         if (!oldView)
             return;
 
-        if (WebInspector.ResourceManager.resourceViewTypeMatchesResource(resource))
+        if (WebInspector.ResourceView.resourceViewTypeMatchesResource(resource))
             return;
 
-        var newView = WebInspector.ResourceManager.recreateResourceView(resource);
+        var newView = WebInspector.ResourceView.recreateResourceView(resource);
         if (this.visibleView === oldView)
             this.visibleView = newView;
     },
index da21092..063ca43 100644 (file)
@@ -684,7 +684,7 @@ WebInspector.Resource.prototype = {
             this._pendingContentCallbacks.length = 0;
             delete this._contentRequested;
         }
-        WebInspector.ResourceManager.requestContent(this, this._contentEncoded, onResourceContent.bind(this));
+        WebInspector.NetworkManager.requestContent(this, this._contentEncoded, onResourceContent.bind(this));
     }
 }
 
diff --git a/WebCore/inspector/front-end/ResourceManager.js b/WebCore/inspector/front-end/ResourceManager.js
deleted file mode 100644 (file)
index 7f1c574..0000000
+++ /dev/null
@@ -1,681 +0,0 @@
-/*
- * Copyright (C) 2009, 2010 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-WebInspector.ResourceManager = function()
-{
-    this._resourcesById = {};
-    this._resourcesByURL = {};
-    this._resourceTreeModel = new WebInspector.ResourceTreeModel();
-    InspectorBackend.cachedResources(this._processCachedResources.bind(this));
-    InspectorBackend.registerDomainDispatcher("Resources", this);
-}
-
-WebInspector.ResourceManager.prototype = {
-    identifierForInitialRequest: function(identifier, url, loader, callStack)
-    {
-        var resource = this._createResource(identifier, url, loader, callStack);
-
-        // It is important to bind resource url early (before scripts compile).
-        this._bindResourceURL(resource);
-
-        WebInspector.panels.network.refreshResource(resource);
-        WebInspector.panels.audits.resourceStarted(resource);
-    },
-
-    _createResource: function(identifier, url, loader, stackTrace)
-    {
-        var resource = new WebInspector.Resource(identifier, url);
-        resource.loader = loader;
-        if (loader)
-            resource.documentURL = loader.url;
-        resource.stackTrace = stackTrace;
-
-        this._resourcesById[identifier] = resource;
-        return resource;
-    },
-
-    willSendRequest: function(identifier, time, request, redirectResponse)
-    {
-        var resource = this._resourcesById[identifier];
-        if (!resource)
-            return;
-
-        // Redirect may have empty URL and we'd like to not crash with invalid HashMap entry.
-        // See http/tests/misc/will-send-request-returns-null-on-redirect.html
-        var isRedirect = !redirectResponse.isNull && request.url.length;
-        if (isRedirect) {
-            resource.endTime = time;
-            this.didReceiveResponse(identifier, time, "Other", redirectResponse);
-            resource = this._appendRedirect(resource.identifier, request.url);
-        }
-
-        this._updateResourceWithRequest(resource, request);
-        resource.startTime = time;
-
-        if (isRedirect) {
-            WebInspector.panels.network.refreshResource(resource);
-            WebInspector.panels.audits.resourceStarted(resource);
-        } else 
-            WebInspector.panels.network.refreshResource(resource);
-    },
-
-    _updateResourceWithRequest: function(resource, request)
-    {
-        resource.requestMethod = request.httpMethod;
-        resource.requestHeaders = request.httpHeaderFields;
-        resource.requestFormData = request.requestFormData;
-    },
-
-    _appendRedirect: function(identifier, redirectURL)
-    {
-        var originalResource = this._resourcesById[identifier];
-        originalResource.identifier = null;
-
-        var newResource = this._createResource(identifier, redirectURL, originalResource.loader, originalResource.stackTrace);
-        newResource.redirects = originalResource.redirects || [];
-        delete originalResource.redirects;
-        newResource.redirects.push(originalResource);
-        return newResource;
-    },
-
-    markResourceAsCached: function(identifier)
-    {
-        var resource = this._resourcesById[identifier];
-        if (!resource)
-            return;
-
-        resource.cached = true;
-        WebInspector.panels.network.refreshResource(resource);
-    },
-
-    didReceiveResponse: function(identifier, time, resourceType, response)
-    {
-        var resource = this._resourcesById[identifier];
-        if (!resource)
-            return;
-
-        resource.responseReceivedTime = time;
-        resource.type = WebInspector.Resource.Type[resourceType];
-
-        this._updateResourceWithResponse(resource, response);
-
-        WebInspector.panels.network.refreshResource(resource);
-        this._resourceTreeModel.addResourceToFrame(resource.loader.frameId, resource);
-    },
-
-    _updateResourceWithResponse: function(resource, response)
-    {
-        if (resource.isNull)
-            return;
-
-        resource.mimeType = response.mimeType;
-        resource.expectedContentLength = response.expectedContentLength;
-        resource.textEncodingName = response.textEncodingName;
-        resource.suggestedFilename = response.suggestedFilename;
-        resource.statusCode = response.httpStatusCode;
-        resource.statusText = response.httpStatusText;
-
-        resource.responseHeaders = response.httpHeaderFields;
-        resource.connectionReused = response.connectionReused;
-        resource.connectionID = response.connectionID;
-
-        if (response.wasCached)
-            resource.cached = true;
-        else
-            resource.timing = response.timing;
-
-        if (response.loadInfo) {
-            if (response.loadInfo.httpStatusCode)
-                resource.statusCode = response.loadInfo.httpStatusCode;
-            if (response.loadInfo.httpStatusText)
-                resource.statusText = response.loadInfo.httpStatusText;
-            resource.requestHeaders = response.loadInfo.requestHeaders;
-            resource.responseHeaders = response.loadInfo.responseHeaders;
-        }
-    },
-
-    didReceiveContentLength: function(identifier, time, lengthReceived)
-    {
-        var resource = this._resourcesById[identifier];
-        if (!resource)
-            return;
-
-        resource.resourceSize += lengthReceived;
-        resource.endTime = time;
-
-        WebInspector.panels.network.refreshResource(resource);
-    },
-
-    didFinishLoading: function(identifier, finishTime)
-    {
-        var resource = this._resourcesById[identifier];
-        if (!resource)
-            return;
-
-        resource.endTime = finishTime;
-        resource.finished = true;
-
-        WebInspector.panels.network.refreshResource(resource);
-        WebInspector.panels.audits.resourceFinished(resource);
-        WebInspector.extensionServer.notifyResourceFinished(resource);
-        delete this._resourcesById[identifier];
-    },
-
-    didFailLoading: function(identifier, time, localizedDescription)
-    {
-        var resource = this._resourcesById[identifier];
-        if (!resource)
-            return;
-
-        resource.failed = true;
-        resource.localizedFailDescription = localizedDescription;
-        resource.finished = true;
-        resource.endTime = time;
-
-        WebInspector.panels.network.refreshResource(resource);
-        WebInspector.panels.audits.resourceFinished(resource);
-        WebInspector.extensionServer.notifyResourceFinished(resource);
-        delete this._resourcesById[identifier];
-    },
-
-    didLoadResourceFromMemoryCache: function(time, cachedResource)
-    {
-        var resource = this._createResource(null, cachedResource.url, cachedResource.loader);
-        this._updateResourceWithCachedResource(resource, cachedResource);
-        resource.cached = true;
-        resource.requestMethod = "GET";
-        resource.startTime = resource.responseReceivedTime = resource.endTime = time;
-        resource.finished = true;
-
-        WebInspector.panels.network.refreshResource(resource);
-        WebInspector.panels.audits.resourceStarted(resource);
-        WebInspector.panels.audits.resourceFinished(resource);
-        this._resourceTreeModel.addResourceToFrame(resource.loader.frameId, resource);
-    },
-
-    _updateResourceWithCachedResource: function(resource, cachedResource)
-    {
-        resource.type = WebInspector.Resource.Type[cachedResource.type];
-        resource.resourceSize = cachedResource.encodedSize;
-        this._updateResourceWithResponse(resource, cachedResource.response);
-    },
-
-    setInitialContent: function(identifier, sourceString, type)
-    {
-        var resource = WebInspector.panels.network.resources[identifier];
-        if (!resource)
-            return;
-
-        resource.type = WebInspector.Resource.Type[type];
-        resource.setInitialContent(sourceString);
-        WebInspector.panels.resources.refreshResource(resource);
-        WebInspector.panels.network.refreshResource(resource);
-    },
-
-    didCommitLoadForFrame: function(frame, loader)
-    {
-        this._resourceTreeModel.didCommitLoadForFrame(frame, loader);
-        if (!frame.parentId) {
-            var mainResource = this.resourceForURL(frame.url);
-            if (mainResource) {
-                WebInspector.mainResource = mainResource;
-                mainResource.isMainResource = true;
-            }
-        }
-    },
-
-    frameDetachedFromParent: function(frameId)
-    {
-        this._resourceTreeModel.frameDetachedFromParent(frameId);
-    },
-
-    didCreateWebSocket: function(identifier, requestURL)
-    {
-        var resource = this._createResource(identifier, requestURL);
-        resource.type = WebInspector.Resource.Type.WebSocket;
-        WebInspector.panels.network.refreshResource(resource);
-    },
-
-    willSendWebSocketHandshakeRequest: function(identifier, time, request)
-    {
-        var resource = this._resourcesById[identifier];
-        if (!resource)
-            return;
-
-        resource.requestMethod = "GET";
-        resource.requestHeaders = request.webSocketHeaderFields;
-        resource.webSocketRequestKey3 = request.webSocketRequestKey3;
-        resource.startTime = time;
-
-        WebInspector.panels.network.refreshResource(resource);
-    },
-
-    didReceiveWebSocketHandshakeResponse: function(identifier, time, response)
-    {
-        var resource = this._resourcesById[identifier];
-        if (!resource)
-            return;
-
-        resource.statusCode = response.statusCode;
-        resource.statusText = response.statusText;
-        resource.responseHeaders = response.webSocketHeaderFields;
-        resource.webSocketChallengeResponse = response.webSocketChallengeResponse;
-        resource.responseReceivedTime = time;
-
-        WebInspector.panels.network.refreshResource(resource);
-    },
-
-    didCloseWebSocket: function(identifier, time)
-    {
-        var resource = this._resourcesById[identifier];
-        if (!resource)
-            return;
-        resource.endTime = time;
-
-        WebInspector.panels.network.refreshResource(resource);
-    },
-
-    _processCachedResources: function(mainFramePayload)
-    {
-        var mainResource = this._addFramesRecursively(mainFramePayload);
-        WebInspector.mainResource = mainResource;
-        mainResource.isMainResource = true;
-    },
-
-    _addFramesRecursively: function(framePayload)
-    {
-        var frameResource = this._createResource(null, framePayload.resource.url, framePayload.resource.loader);
-        this._updateResourceWithRequest(frameResource, framePayload.resource.request);
-        this._updateResourceWithResponse(frameResource, framePayload.resource.response);
-        frameResource.type = WebInspector.Resource.Type["Document"];
-        frameResource.finished = true;
-        this._bindResourceURL(frameResource);
-
-        this._resourceTreeModel.addOrUpdateFrame(framePayload);
-        this._resourceTreeModel.addResourceToFrame(framePayload.id, frameResource);
-
-        for (var i = 0; framePayload.children && i < framePayload.children.length; ++i)
-            this._addFramesRecursively(framePayload.children[i]);
-
-        if (!framePayload.subresources)
-            return;
-
-        for (var i = 0; i < framePayload.subresources.length; ++i) {
-            var cachedResource = framePayload.subresources[i];
-            var resource = this._createResource(null, cachedResource.url, cachedResource.loader);
-            this._updateResourceWithCachedResource(resource, cachedResource);
-            resource.finished = true;
-            this._bindResourceURL(resource);
-            this._resourceTreeModel.addResourceToFrame(framePayload.id, resource);
-        }
-        return frameResource;
-    },
-
-    resourceForURL: function(url)
-    {
-        // FIXME: receive frameId here.
-        var entry = this._resourcesByURL[url];
-        if (entry instanceof Array)
-            return entry[0];
-        return entry;
-    },
-
-    addConsoleMessage: function(msg)
-    {
-        var resource = this.resourceForURL(msg.url);
-        if (!resource)
-            return;
-
-        switch (msg.level) {
-        case WebInspector.ConsoleMessage.MessageLevel.Warning:
-            resource.warnings += msg.repeatDelta;
-            break;
-        case WebInspector.ConsoleMessage.MessageLevel.Error:
-            resource.errors += msg.repeatDelta;
-            break;
-        }
-
-        var view = WebInspector.ResourceManager.resourceViewForResource(resource);
-        if (view.addMessage)
-            view.addMessage(msg);
-    },
-
-    clearConsoleMessages: function()
-    {
-        function callback(resource)
-        {
-            resource.clearErrorsAndWarnings();
-        }
-        this._resourceTreeModel.forAllResources(callback);
-    },
-
-    forAllResources: function(callback)
-    {
-        this._resourceTreeModel.forAllResources(callback);
-    },
-
-    _bindResourceURL: function(resource)
-    {
-        var resourceForURL = this._resourcesByURL[resource.url];
-        if (!resourceForURL)
-            this._resourcesByURL[resource.url] = resource;
-        else if (resourceForURL instanceof Array)
-            resourceForURL.push(resource);
-        else
-            this._resourcesByURL[resource.url] = [resourceForURL, resource];
-    },
-
-    _unbindResourceURL: function(resource)
-    {
-        var resourceForURL = this._resourcesByURL[resource.url];
-        if (!resourceForURL)
-            return;
-
-        if (resourceForURL instanceof Array) {
-            resourceForURL.remove(resource, true);
-            if (resourceForURL.length === 1)
-                this._resourcesByURL[resource.url] = resourceForURL[0];
-            return;
-        }
-
-        delete this._resourcesByURL[resource.url];
-    },
-
-    updateDOMStorage: function(storageId)
-    {
-        WebInspector.panels.resources.updateDOMStorage(storageId);
-    },
-
-    updateApplicationCacheStatus: function(status)
-    {
-        WebInspector.panels.resources.updateApplicationCacheStatus(status);
-    },
-
-    didGetFileSystemPath: function(root, type, origin)
-    {
-        WebInspector.panels.resources.updateFileSystemPath(root, type, origin);
-    },
-
-    didGetFileSystemError: function(type, origin)
-    {
-        WebInspector.panels.resources.updateFileSystemError(type, origin);
-    },
-
-    didGetFileSystemDisabled: function()
-    {
-        WebInspector.panels.resources.setFileSystemDisabled();
-    },
-
-    updateNetworkState: function(isNowOnline)
-    {
-        WebInspector.panels.resources.updateNetworkState(isNowOnline);
-    },
-
-    addDOMStorage: function(payload)
-    {
-        if (!WebInspector.panels.resources)
-            return;
-        var domStorage = new WebInspector.DOMStorage(
-            payload.id,
-            payload.host,
-            payload.isLocalStorage);
-        WebInspector.panels.resources.addDOMStorage(domStorage);
-    },
-
-    selectDOMStorage: function(o)
-    {
-        WebInspector.showPanel("resources");
-        WebInspector.panels.resources.selectDOMStorage(o);
-    },
-
-    addDatabase: function(payload)
-    {
-        if (!WebInspector.panels.resources)
-            return;
-        var database = new WebInspector.Database(
-            payload.id,
-            payload.domain,
-            payload.name,
-            payload.version);
-        WebInspector.panels.resources.addDatabase(database);
-    },
-
-    selectDatabase: function(o)
-    {
-        WebInspector.showPanel("resources");
-        WebInspector.panels.resources.selectDatabase(o);
-    },
-
-    sqlTransactionSucceeded: function(transactionId, columnNames, values)
-    {
-        var callback = WebInspector.Database.successCallbacks[transactionId];
-        if (!callback)
-            return;
-        delete WebInspector.Database.successCallbacks[transactionId];
-        callback(columnNames, values);
-    },
-
-    sqlTransactionFailed: function(transactionId, errorObj)
-    {
-        var callback = WebInspector.Database.errorCallbacks[transactionId];
-        if (!callback)
-            return;
-        delete WebInspector.Database.errorCallbacks[transactionId];
-        callback(errorObj);
-    }
-}
-
-WebInspector.ResourceManager.createResourceView = function(resource)
-{
-    switch (resource.category) {
-    case WebInspector.resourceCategories.documents:
-    case WebInspector.resourceCategories.stylesheets:
-    case WebInspector.resourceCategories.scripts:
-    case WebInspector.resourceCategories.xhr:
-        return new WebInspector.SourceView(resource);
-    case WebInspector.resourceCategories.images:
-        return new WebInspector.ImageView(resource);
-    case WebInspector.resourceCategories.fonts:
-        return new WebInspector.FontView(resource);
-    default:
-        return new WebInspector.ResourceView(resource);
-    }
-}
-
-WebInspector.ResourceManager.resourceViewTypeMatchesResource = function(resource)
-{
-    var resourceView = resource._resourcesView;
-    switch (resource.category) {
-    case WebInspector.resourceCategories.documents:
-    case WebInspector.resourceCategories.stylesheets:
-    case WebInspector.resourceCategories.scripts:
-    case WebInspector.resourceCategories.xhr:
-        return resourceView.__proto__ === WebInspector.SourceView.prototype;
-    case WebInspector.resourceCategories.images:
-        return resourceView.__proto__ === WebInspector.ImageView.prototype;
-    case WebInspector.resourceCategories.fonts:
-        return resourceView.__proto__ === WebInspector.FontView.prototype;
-    default:
-        return resourceView.__proto__ === WebInspector.ResourceView.prototype;
-    }
-}
-
-WebInspector.ResourceManager.resourceViewForResource = function(resource)
-{
-    if (!resource)
-        return null;
-    if (!resource._resourcesView)
-        resource._resourcesView = WebInspector.ResourceManager.createResourceView(resource);
-    return resource._resourcesView;
-}
-
-WebInspector.ResourceManager.recreateResourceView = function(resource)
-{
-    var newView = WebInspector.ResourceManager.createResourceView(resource);
-
-    var oldView = resource._resourcesView;
-    var oldViewParentNode = oldView.visible ? oldView.element.parentNode : null;
-    var scrollTop = oldView.scrollTop;
-
-    resource._resourcesView.detach();
-    delete resource._resourcesView;
-
-    resource._resourcesView = newView;
-
-    if (oldViewParentNode)
-        newView.show(oldViewParentNode);
-    if (scrollTop)
-        newView.scrollTop = scrollTop;
-
-    WebInspector.panels.scripts.viewRecreated(oldView, newView);
-    return newView;
-}
-
-WebInspector.ResourceManager.existingResourceViewForResource = function(resource)
-{
-    if (!resource)
-        return null;
-    return resource._resourcesView;
-}
-
-WebInspector.ResourceManager.requestContent = function(resource, base64Encode, callback)
-{
-    InspectorBackend.resourceContent(resource.loader.frameId, resource.url, base64Encode, callback);
-}
-
-WebInspector.ResourceTreeModel = function()
-{
-    this._resourcesByFrameId = {};
-    this._subframes = {};
-}
-
-WebInspector.ResourceTreeModel.prototype = {
-    addOrUpdateFrame: function(frame)
-    {
-        var tmpResource = new WebInspector.Resource(null, frame.url);
-        WebInspector.panels.resources.addOrUpdateFrame(frame.parentId, frame.id, frame.name, tmpResource.displayName);
-        var subframes = this._subframes[frame.parentId];
-        if (!subframes) {
-            subframes = {};
-            this._subframes[frame.parentId || 0] = subframes;
-        }
-        subframes[frame.id] = true;
-    },
-
-    didCommitLoadForFrame: function(frame, loader)
-    {
-        // frame.parentId === 0 is when main frame navigation happens.
-        this._clearChildFramesAndResources(frame.parentId ? frame.id : 0, loader.loaderId);
-
-        this.addOrUpdateFrame(frame);
-
-        var resourcesForFrame = this._resourcesByFrameId[frame.id];
-        for (var i = 0; resourcesForFrame && i < resourcesForFrame.length; ++i)
-            WebInspector.panels.resources.addResourceToFrame(frame.id, resourcesForFrame[i]);
-    },
-
-    frameDetachedFromParent: function(frameId)
-    {
-        this._clearChildFramesAndResources(frameId, 0);
-        WebInspector.panels.resources.removeFrame(frameId);
-    },
-
-    _clearChildFramesAndResources: function(frameId, loaderId)
-    {
-        WebInspector.panels.resources.removeResourcesFromFrame(frameId);
-
-        this._clearResources(frameId, loaderId);
-        var subframes = this._subframes[frameId];
-        if (!subframes)
-            return;
-
-        for (var childFrameId in subframes) {
-            WebInspector.panels.resources.removeFrame(childFrameId);
-            this._clearChildFramesAndResources(childFrameId, loaderId);
-        }
-        delete this._subframes[frameId];
-    },
-
-    addResourceToFrame: function(frameId, resource)
-    {
-        var resourcesForFrame = this._resourcesByFrameId[frameId];
-        if (!resourcesForFrame) {
-            resourcesForFrame = [];
-            this._resourcesByFrameId[frameId] = resourcesForFrame;
-        }
-        resourcesForFrame.push(resource);
-
-        WebInspector.panels.resources.addResourceToFrame(frameId, resource);
-    },
-
-    _clearResources: function(frameId, loaderToPreserveId)
-    {
-        var resourcesForFrame = this._resourcesByFrameId[frameId];
-        if (!resourcesForFrame)
-            return;
-
-        var preservedResourcesForFrame = [];
-        for (var i = 0; i < resourcesForFrame.length; ++i) {
-            var resource = resourcesForFrame[i];
-            if (resource.loader.loaderId === loaderToPreserveId) {
-                preservedResourcesForFrame.push(resource);
-                continue;
-            }
-            WebInspector.resourceManager._unbindResourceURL(resource);
-        }
-
-        delete this._resourcesByFrameId[frameId];
-        if (preservedResourcesForFrame.length)
-            this._resourcesByFrameId[frameId] = preservedResourcesForFrame;
-    },
-
-    forAllResources: function(callback)
-    {
-        this._callForFrameResources(0, callback);
-    },
-
-    _callForFrameResources: function(frameId, callback)
-    {
-        var resources = this._resourcesByFrameId[frameId];
-        for (var i = 0; resources && i < resources.length; ++i) {
-            if (callback(resources[i]))
-                return true;
-        }
-        
-        var frames = this._subframes[frameId];
-        if (frames) {
-            for (var id in frames) {
-                if (this._callForFrameResources(id, callback))
-                    return true;
-            }
-        }
-        return false;
-    }
-}
diff --git a/WebCore/inspector/front-end/ResourceTreeModel.js b/WebCore/inspector/front-end/ResourceTreeModel.js
new file mode 100644 (file)
index 0000000..7c7b86d
--- /dev/null
@@ -0,0 +1,255 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+WebInspector.ResourceTreeModel = function()
+{
+    this._resourcesByURL = {};
+    this._resourcesByFrameId = {};
+    this._subframes = {};
+    InspectorBackend.registerDomainDispatcher("Resources", this);
+    InspectorBackend.cachedResources(this._processCachedResources.bind(this));
+}
+
+WebInspector.ResourceTreeModel.createResource = function(identifier, url, loader, stackTrace)
+{
+    var resource = new WebInspector.Resource(identifier, url);
+    resource.loader = loader;
+    if (loader)
+        resource.documentURL = loader.url;
+    resource.stackTrace = stackTrace;
+
+    return resource;
+}
+
+WebInspector.ResourceTreeModel.prototype = {
+    addOrUpdateFrame: function(frame)
+    {
+        var tmpResource = new WebInspector.Resource(null, frame.url);
+        WebInspector.panels.resources.addOrUpdateFrame(frame.parentId, frame.id, frame.name, tmpResource.displayName);
+        var subframes = this._subframes[frame.parentId];
+        if (!subframes) {
+            subframes = {};
+            this._subframes[frame.parentId || 0] = subframes;
+        }
+        subframes[frame.id] = true;
+    },
+
+    didCommitLoadForFrame: function(frame, loader)
+    {
+        // frame.parentId === 0 is when main frame navigation happens.
+        this._clearChildFramesAndResources(frame.parentId ? frame.id : 0, loader.loaderId);
+
+        this.addOrUpdateFrame(frame);
+
+        var resourcesForFrame = this._resourcesByFrameId[frame.id];
+        for (var i = 0; resourcesForFrame && i < resourcesForFrame.length; ++i)
+            WebInspector.panels.resources.addResourceToFrame(frame.id, resourcesForFrame[i]);
+    },
+
+    frameDetachedFromParent: function(frameId)
+    {
+        this._clearChildFramesAndResources(frameId, 0);
+        WebInspector.panels.resources.removeFrame(frameId);
+    },
+
+    addResourceToFrame: function(frameId, resource)
+    {
+        var resourcesForFrame = this._resourcesByFrameId[frameId];
+        if (!resourcesForFrame) {
+            resourcesForFrame = [];
+            this._resourcesByFrameId[frameId] = resourcesForFrame;
+        }
+        resourcesForFrame.push(resource);
+
+        WebInspector.panels.resources.addResourceToFrame(frameId, resource);
+    },
+
+    forAllResources: function(callback)
+    {
+        this._callForFrameResources(0, callback);
+    },
+
+    addConsoleMessage: function(msg)
+    {
+        var resource = this.resourceForURL(msg.url);
+        if (!resource)
+            return;
+
+        switch (msg.level) {
+        case WebInspector.ConsoleMessage.MessageLevel.Warning:
+            resource.warnings += msg.repeatDelta;
+            break;
+        case WebInspector.ConsoleMessage.MessageLevel.Error:
+            resource.errors += msg.repeatDelta;
+            break;
+        }
+
+        var view = WebInspector.ResourceView.resourceViewForResource(resource);
+        if (view.addMessage)
+            view.addMessage(msg);
+    },
+
+    clearConsoleMessages: function()
+    {
+        function callback(resource)
+        {
+            resource.clearErrorsAndWarnings();
+        }
+        this.forAllResources(callback);
+    },
+
+    resourceForURL: function(url)
+    {
+        // FIXME: receive frameId here.
+        var entry = this._resourcesByURL[url];
+        if (entry instanceof Array)
+            return entry[0];
+        return entry;
+    },
+
+    bindResourceURL: function(resource)
+    {
+        var resourceForURL = this._resourcesByURL[resource.url];
+        if (!resourceForURL)
+            this._resourcesByURL[resource.url] = resource;
+        else if (resourceForURL instanceof Array)
+            resourceForURL.push(resource);
+        else
+            this._resourcesByURL[resource.url] = [resourceForURL, resource];
+    },
+
+    _clearChildFramesAndResources: function(frameId, loaderId)
+    {
+        WebInspector.panels.resources.removeResourcesFromFrame(frameId);
+
+        this._clearResources(frameId, loaderId);
+        var subframes = this._subframes[frameId];
+        if (!subframes)
+            return;
+
+        for (var childFrameId in subframes) {
+            WebInspector.panels.resources.removeFrame(childFrameId);
+            this._clearChildFramesAndResources(childFrameId, loaderId);
+        }
+        delete this._subframes[frameId];
+    },
+
+    _clearResources: function(frameId, loaderToPreserveId)
+    {
+        var resourcesForFrame = this._resourcesByFrameId[frameId];
+        if (!resourcesForFrame)
+            return;
+
+        var preservedResourcesForFrame = [];
+        for (var i = 0; i < resourcesForFrame.length; ++i) {
+            var resource = resourcesForFrame[i];
+            if (resource.loader.loaderId === loaderToPreserveId) {
+                preservedResourcesForFrame.push(resource);
+                continue;
+            }
+            this._unbindResourceURL(resource);
+        }
+
+        delete this._resourcesByFrameId[frameId];
+        if (preservedResourcesForFrame.length)
+            this._resourcesByFrameId[frameId] = preservedResourcesForFrame;
+    },
+
+    _callForFrameResources: function(frameId, callback)
+    {
+        var resources = this._resourcesByFrameId[frameId];
+        for (var i = 0; resources && i < resources.length; ++i) {
+            if (callback(resources[i]))
+                return true;
+        }
+        
+        var frames = this._subframes[frameId];
+        if (frames) {
+            for (var id in frames) {
+                if (this._callForFrameResources(id, callback))
+                    return true;
+            }
+        }
+        return false;
+    },
+
+    _unbindResourceURL: function(resource)
+    {
+        var resourceForURL = this._resourcesByURL[resource.url];
+        if (!resourceForURL)
+            return;
+
+        if (resourceForURL instanceof Array) {
+            resourceForURL.remove(resource, true);
+            if (resourceForURL.length === 1)
+                this._resourcesByURL[resource.url] = resourceForURL[0];
+            return;
+        }
+
+        delete this._resourcesByURL[resource.url];
+    },
+
+    _processCachedResources: function(mainFramePayload)
+    {
+        var mainResource = this._addFramesRecursively(mainFramePayload);
+        WebInspector.mainResource = mainResource;
+        mainResource.isMainResource = true;
+    },
+
+    _addFramesRecursively: function(framePayload)
+    {
+        var frameResource = WebInspector.ResourceTreeModel.createResource(null, framePayload.resource.url, framePayload.resource.loader);
+        WebInspector.NetworkManager.updateResourceWithRequest(frameResource, framePayload.resource.request);
+        WebInspector.NetworkManager.updateResourceWithResponse(frameResource, framePayload.resource.response);
+        frameResource.type = WebInspector.Resource.Type["Document"];
+        frameResource.finished = true;
+
+        this.bindResourceURL(frameResource);
+        this.addOrUpdateFrame(framePayload);
+        this.addResourceToFrame(framePayload.id, frameResource);
+
+        for (var i = 0; framePayload.children && i < framePayload.children.length; ++i)
+            this._addFramesRecursively(framePayload.children[i]);
+
+        if (!framePayload.subresources)
+            return;
+
+        for (var i = 0; i < framePayload.subresources.length; ++i) {
+            var cachedResource = framePayload.subresources[i];
+            var resource = WebInspector.ResourceTreeModel.createResource(null, cachedResource.url, cachedResource.loader);
+            WebInspector.NetworkManager.updateResourceWithCachedResource(resource, cachedResource);
+            resource.finished = true;
+            this.bindResourceURL(resource);
+            this.addResourceToFrame(framePayload.id, resource);
+        }
+        return frameResource;
+    }
+}
index a284da1..b69097d 100644 (file)
@@ -42,3 +42,76 @@ WebInspector.ResourceView.prototype = {
 }
 
 WebInspector.ResourceView.prototype.__proto__ = WebInspector.View.prototype;
+
+WebInspector.ResourceView.createResourceView = function(resource)
+{
+    switch (resource.category) {
+    case WebInspector.resourceCategories.documents:
+    case WebInspector.resourceCategories.stylesheets:
+    case WebInspector.resourceCategories.scripts:
+    case WebInspector.resourceCategories.xhr:
+        return new WebInspector.SourceView(resource);
+    case WebInspector.resourceCategories.images:
+        return new WebInspector.ImageView(resource);
+    case WebInspector.resourceCategories.fonts:
+        return new WebInspector.FontView(resource);
+    default:
+        return new WebInspector.ResourceView(resource);
+    }
+}
+
+WebInspector.ResourceView.resourceViewTypeMatchesResource = function(resource)
+{
+    var resourceView = resource._resourcesView;
+    switch (resource.category) {
+    case WebInspector.resourceCategories.documents:
+    case WebInspector.resourceCategories.stylesheets:
+    case WebInspector.resourceCategories.scripts:
+    case WebInspector.resourceCategories.xhr:
+        return resourceView.__proto__ === WebInspector.SourceView.prototype;
+    case WebInspector.resourceCategories.images:
+        return resourceView.__proto__ === WebInspector.ImageView.prototype;
+    case WebInspector.resourceCategories.fonts:
+        return resourceView.__proto__ === WebInspector.FontView.prototype;
+    default:
+        return resourceView.__proto__ === WebInspector.ResourceView.prototype;
+    }
+}
+
+WebInspector.ResourceView.resourceViewForResource = function(resource)
+{
+    if (!resource)
+        return null;
+    if (!resource._resourcesView)
+        resource._resourcesView = WebInspector.ResourceView.createResourceView(resource);
+    return resource._resourcesView;
+}
+
+WebInspector.ResourceView.recreateResourceView = function(resource)
+{
+    var newView = WebInspector.ResourceView.createResourceView(resource);
+
+    var oldView = resource._resourcesView;
+    var oldViewParentNode = oldView.visible ? oldView.element.parentNode : null;
+    var scrollTop = oldView.scrollTop;
+
+    resource._resourcesView.detach();
+    delete resource._resourcesView;
+
+    resource._resourcesView = newView;
+
+    if (oldViewParentNode)
+        newView.show(oldViewParentNode);
+    if (scrollTop)
+        newView.scrollTop = scrollTop;
+
+    WebInspector.panels.scripts.viewRecreated(oldView, newView);
+    return newView;
+}
+
+WebInspector.ResourceView.existingResourceViewForResource = function(resource)
+{
+    if (!resource)
+        return null;
+    return resource._resourcesView;
+}
index d6f7172..ee63daf 100644 (file)
@@ -329,12 +329,12 @@ WebInspector.ResourcesPanel.prototype = {
 
     canShowSourceLine: function(url, line)
     {
-        return !!WebInspector.resourceManager.resourceForURL(url);
+        return !!WebInspector.resourceView.resourceForURL(url);
     },
 
     showSourceLine: function(url, line)
     {
-        var resource = WebInspector.resourceManager.resourceForURL(url);
+        var resource = WebInspector.resourceTreeModel.resourceForURL(url);
         if (resource.type === WebInspector.Resource.Type.XHR) {
             // Show XHRs in the network panel only.
             if (WebInspector.panels.network && WebInspector.panels.network.canShowSourceLine(url, line)) {
@@ -343,7 +343,7 @@ WebInspector.ResourcesPanel.prototype = {
             }
             return;
         }
-        this.showResource(WebInspector.resourceManager.resourceForURL(url), line);
+        this.showResource(WebInspector.resourceTreeModel.resourceForURL(url), line);
     },
 
     showResource: function(resource, line)
@@ -355,7 +355,7 @@ WebInspector.ResourcesPanel.prototype = {
         }
 
         if (line) {
-            var view = WebInspector.ResourceManager.resourceViewForResource(resource);
+            var view = WebInspector.ResourceView.resourceViewForResource(resource);
             if (view.revealLine)
                 view.revealLine(line);
             if (view.highlightLine)
@@ -366,7 +366,7 @@ WebInspector.ResourcesPanel.prototype = {
 
     _showResourceView: function(resource)
     {
-        var view = WebInspector.ResourceManager.resourceViewForResource(resource);
+        var view = WebInspector.ResourceView.resourceViewForResource(resource);
 
         // Consider rendering diff markup here.
         if (resource.baseRevision && view instanceof WebInspector.SourceView) {
@@ -687,7 +687,7 @@ WebInspector.ResourcesPanel.prototype = {
         function callback(resourceTreeElement)
         {
             var resource = resourceTreeElement._resource;
-            var resourceView = WebInspector.ResourceManager.resourceViewForResource(resource);
+            var resourceView = WebInspector.ResourceView.resourceViewForResource(resource);
             if (resourceView.performSearch && resourceView !== visibleView)
                 views.push(resourceView);
         }
@@ -1069,7 +1069,7 @@ WebInspector.FrameResourceTreeElement.prototype = {
     {
         // FIXME: move to the Script/SourceView.
         if (!this._resource.warnings && !this._resource.errors) {
-            var view = WebInspector.ResourceManager.existingResourceViewForResource(this._resource);
+            var view = WebInspector.ResourceView.existingResourceViewForResource(this._resource);
             if (view && view.clearMessages)
                 view.clearMessages();
         }
@@ -1092,9 +1092,9 @@ WebInspector.FrameResourceTreeElement.prototype = {
     _contentChanged: function(event)
     {
         this.insertChild(new WebInspector.ResourceRevisionTreeElement(this._storagePanel, event.data.revision), 0);
-        var oldView = WebInspector.ResourceManager.existingResourceViewForResource(this._resource);
+        var oldView = WebInspector.ResourceView.existingResourceViewForResource(this._resource);
         if (oldView) {
-            var newView = WebInspector.ResourceManager.recreateResourceView(this._resource);
+            var newView = WebInspector.ResourceView.recreateResourceView(this._resource);
             if (oldView === this._storagePanel.visibleView)
                 this._storagePanel.visibleView = newView;
         }
index 56facf2..fd44404 100644 (file)
@@ -256,7 +256,7 @@ WebInspector.ScriptsPanel.prototype = {
             if (resource.finished) {
                 // Resource is finished, bind the script right away.
                 script.resource = resource;
-                var view = WebInspector.ResourceManager.existingResourceViewForResource(resource);
+                var view = WebInspector.ResourceView.existingResourceViewForResource(resource);
                 if (view && view.sourceFrame)
                     view.sourceFrame.addScript(script);
             } else {
@@ -434,10 +434,6 @@ WebInspector.ScriptsPanel.prototype = {
         this.functionsSelectElement.removeChildren();
         this.viewsContainerElement.removeChildren();
 
-        var scripts = WebInspector.debuggerModel.queryScripts(function(s) { return !!s.resource; });
-        for (var i = 0; i < scripts.length; ++i)
-            delete scripts[i].resource._resourcesView;
-
         this.sidebarPanes.watchExpressions.refreshExpressions();
         if (!preserveItems)
             this.sidebarPanes.workers.reset();
@@ -545,7 +541,7 @@ WebInspector.ScriptsPanel.prototype = {
 
     _sourceFrameForResource: function(resource)
     {
-        var view = WebInspector.ResourceManager.resourceViewForResource(resource);
+        var view = WebInspector.ResourceView.resourceViewForResource(resource);
         if (!view)
             return null;
 
@@ -566,7 +562,7 @@ WebInspector.ScriptsPanel.prototype = {
 
         var view;
         if (scriptOrResource instanceof WebInspector.Resource)
-            view = WebInspector.ResourceManager.resourceViewForResource(scriptOrResource);
+            view = WebInspector.ResourceView.resourceViewForResource(scriptOrResource);
         else if (scriptOrResource instanceof WebInspector.Script)
             view = this.scriptViewForScript(scriptOrResource);
 
index 90c4317..2444913 100644 (file)
@@ -58,6 +58,7 @@
     <file>KeyboardShortcut.js</file>
     <file>MetricsSidebarPane.js</file>
     <file>NetworkItemView.js</file>
+    <file>NetworkManager.js</file>
     <file>NetworkPanel.js</file>
     <file>Object.js</file>
     <file>ObjectPropertiesSection.js</file>
@@ -75,7 +76,6 @@
     <file>ResourceCategory.js</file>
     <file>ResourceCookiesView.js</file>
     <file>ResourceHeadersView.js</file>
-    <file>ResourceManager.js</file>
     <file>ResourceTimingView.js</file>
     <file>ResourceView.js</file>
     <file>ResourcesPanel.js</file>
index 9ed5019..e1590f2 100644 (file)
@@ -61,7 +61,8 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     <script type="text/javascript" src="Panel.js"></script>
     <script type="text/javascript" src="TimelineGrid.js"></script>    
     <script type="text/javascript" src="Resource.js"></script>
-    <script type="text/javascript" src="ResourceManager.js"></script>
+    <script type="text/javascript" src="NetworkManager.js"></script>
+    <script type="text/javascript" src="ResourceTreeModel.js"></script>
     <script type="text/javascript" src="ResourceCategory.js"></script>
     <script type="text/javascript" src="Database.js"></script>
     <script type="text/javascript" src="DOMStorage.js"></script>
index a57f0f4..cc255aa 100644 (file)
@@ -445,12 +445,12 @@ var WebInspector = {
 
     forAllResources: function(callback)
     {
-        WebInspector.resourceManager.forAllResources(callback);
+        WebInspector.resourceTreeModel.forAllResources(callback);
     },
 
     resourceForURL: function(url)
     {
-        return this.resourceManager.resourceForURL(url);
+        return this.resourceTreeModel.resourceForURL(url);
     }
 }
 
@@ -517,7 +517,8 @@ WebInspector.doLoadedDone = function()
     // this.changes = new WebInspector.ChangesView(this.drawer);
     // TODO: Remove class="hidden" from inspector.html on button#changes-status-bar-item
     this.drawer.visibleView = this.console;
-    this.resourceManager = new WebInspector.ResourceManager();
+    this.resourceTreeModel = new WebInspector.ResourceTreeModel();
+    this.networkManager = new WebInspector.NetworkManager(this.resourceTreeModel);
     this.domAgent = new WebInspector.DOMAgent();
 
     InspectorBackend.registerDomainDispatcher("Inspector", this);