[SCM] WebKit Debian packaging branch, webkit-1.3, updated. upstream/1.3.7-4207-g178b198

yurys at chromium.org yurys at chromium.org
Sun Feb 20 22:51:27 UTC 2011


The following commit has been merged in the webkit-1.3 branch:
commit 389a624659b35b768a1dc2b1e9d6aeed3aabd241
Author: yurys at chromium.org <yurys at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Jan 12 13:06:42 2011 +0000

    2010-12-29  Yury Semikhatsky  <yurys at chromium.org>
    
            Reviewed by Pavel Feldman.
    
            inspector/timeline-network-resource.html fails when run twice
            https://bugs.webkit.org/show_bug.cgi?id=37394
    
            Send didReceiveResponse notification to the timeline agent from ResourceLoadNotifier
            instead of ResourceLoader::didReceiveResponse to cover the cases when resources
            are loaded from memory cache.
    
            Network notifications are now send to InspectorInstrumentation which dispatches
            them to interested agents and InspectorController.
            fix
    
            * inspector/timeline-network-resource-expected.txt:
            * inspector/timeline-network-resource.html:
            * inspector/timeline-network-resource.js:
    2010-12-29  Yury Semikhatsky  <yurys at chromium.org>
    
            Reviewed by Pavel Feldman.
    
            inspector/timeline-network-resource.html fails when run twice
            https://bugs.webkit.org/show_bug.cgi?id=37394
    
            Send didReceiveResponse notification to the timeline agent from ResourceLoadNotifier
            instead of ResourceLoader::didReceiveResponse to cover the cases when resources
            are loaded from memory cache.
    
            Network notifications are now sent to InspectorInstrumentation which dispatches
            them to interested agents and InspectorController.
    
            * inspector/Inspector.idl:
            * inspector/InspectorApplicationCacheAgent.cpp:
            (WebCore::InspectorApplicationCacheAgent::didReceiveManifestResponse):
            * inspector/InspectorController.cpp:
            (WebCore::InspectorController::InspectorController):
            (WebCore::InspectorController::didCommitLoad):
            (WebCore::InspectorController::willSendRequest):
            (WebCore::InspectorController::didReceiveResponse):
            (WebCore::InspectorController::didFailLoading):
            (WebCore::InspectorController::resourceRetrievedByXMLHttpRequest):
            * inspector/InspectorController.h:
            * inspector/InspectorInstrumentation.cpp:
            (WebCore::InspectorInstrumentation::identifierForInitialRequestImpl):
            (WebCore::InspectorInstrumentation::willSendRequestImpl):
            (WebCore::InspectorInstrumentation::markResourceAsCachedImpl):
            (WebCore::InspectorInstrumentation::didLoadResourceFromMemoryCacheImpl):
            (WebCore::InspectorInstrumentation::willReceiveResourceResponseImpl):
            (WebCore::InspectorInstrumentation::didReceiveContentLengthImpl):
            (WebCore::InspectorInstrumentation::didFinishLoadingImpl):
            (WebCore::InspectorInstrumentation::didFailLoadingImpl):
            (WebCore::InspectorInstrumentation::resourceRetrievedByXMLHttpRequestImpl):
            (WebCore::InspectorInstrumentation::scriptImportedImpl):
            (WebCore::InspectorInstrumentation::retrieveResourceAgent):
            * inspector/InspectorInstrumentation.h:
            (WebCore::InspectorInstrumentation::identifierForInitialRequest):
            (WebCore::InspectorInstrumentation::willSendRequest):
            (WebCore::InspectorInstrumentation::markResourceAsCached):
            (WebCore::InspectorInstrumentation::didLoadResourceFromMemoryCache):
            (WebCore::InspectorInstrumentation::willReceiveResourceResponse):
            (WebCore::InspectorInstrumentation::didReceiveContentLength):
            (WebCore::InspectorInstrumentation::didFinishLoading):
            (WebCore::InspectorInstrumentation::didFailLoading):
            (WebCore::InspectorInstrumentation::resourceRetrievedByXMLHttpRequest):
            (WebCore::InspectorInstrumentation::scriptImported):
            * inspector/InspectorResourceAgent.cpp:
            (WebCore::InspectorResourceAgent::identifierForInitialRequest):
            * inspector/InspectorResourceAgent.h:
            * inspector/InspectorTimelineAgent.cpp:
            (WebCore::InspectorTimelineAgent::willSendResourceRequest):
            * inspector/InspectorTimelineAgent.h:
            * inspector/TimelineRecordFactory.cpp:
            (WebCore::TimelineRecordFactory::createResourceSendRequestData):
            * inspector/TimelineRecordFactory.h:
            * inspector/front-end/NetworkManager.js:
            (WebInspector.NetworkManager.prototype.identifierForInitialRequest):
            * inspector/front-end/TimelinePanel.js:
            (WebInspector.TimelinePanel.prototype.addRecordToTimeline):
            * loader/FrameLoader.cpp:
            (WebCore::FrameLoader::loadedResourceFromMemoryCache):
            * loader/ResourceLoadNotifier.cpp:
            (WebCore::ResourceLoadNotifier::didReceiveResponse):
            (WebCore::ResourceLoadNotifier::didFailToLoad):
            (WebCore::ResourceLoadNotifier::assignIdentifierToInitialRequest):
            (WebCore::ResourceLoadNotifier::dispatchWillSendRequest):
            (WebCore::ResourceLoadNotifier::dispatchDidReceiveResponse):
            (WebCore::ResourceLoadNotifier::dispatchDidReceiveContentLength):
            (WebCore::ResourceLoadNotifier::dispatchDidFinishLoading):
            (WebCore::ResourceLoadNotifier::sendRemainingDelegateMessages):
            * loader/ResourceLoader.cpp:
            (WebCore::ResourceLoader::didReceiveResponse):
            * loader/appcache/ApplicationCacheGroup.cpp:
            (WebCore::ApplicationCacheGroup::createResourceHandle):
            (WebCore::ApplicationCacheGroup::didReceiveResponse):
            (WebCore::ApplicationCacheGroup::didReceiveData):
            (WebCore::ApplicationCacheGroup::didFinishLoading):
            (WebCore::ApplicationCacheGroup::didFail):
            * loader/appcache/ApplicationCacheGroup.h:
            * workers/DefaultSharedWorkerRepository.cpp:
            (WebCore::SharedWorkerScriptLoader::notifyFinished):
            * workers/Worker.cpp:
            (WebCore::Worker::notifyFinished):
            * workers/WorkerContext.cpp:
            (WebCore::WorkerContext::importScripts):
            * xml/XMLHttpRequest.cpp:
            (WebCore::XMLHttpRequest::didFinishLoading):
    2010-12-29  Yury Semikhatsky  <yurys at chromium.org>
    
            Reviewed by Pavel Feldman.
    
            inspector/timeline-network-resource.html fails when run twice
            https://bugs.webkit.org/show_bug.cgi?id=37394
    
            Send didReceiveResponse notification to the timeline agent from ResourceLoadNotifier
            instead of ResourceLoader::didReceiveResponse to cover the cases when resources
            are loaded from memory cache.
    
            Network notifications are now sent to InspectorInstrumentation which dispatches
            them to interested agents and InspectorController.
    
            * src/SharedWorkerRepository.cpp:
            (WebCore::SharedWorkerScriptLoader::notifyFinished):
            * src/WebDevToolsAgentImpl.cpp:
            (WebKit::WebDevToolsAgentImpl::mainFrame):
            (WebKit::WebDevToolsAgentImpl::identifierForInitialRequest):
            (WebKit::WebDevToolsAgentImpl::willSendRequest):
            (WebKit::WebDevToolsAgentImpl::didReceiveData):
            (WebKit::WebDevToolsAgentImpl::didReceiveResponse):
            (WebKit::WebDevToolsAgentImpl::didFinishLoading):
            (WebKit::WebDevToolsAgentImpl::didFailLoading):
            * src/WebDevToolsAgentImpl.h:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@75604 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index f274af3..326e004 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,22 @@
+2010-12-29  Yury Semikhatsky  <yurys at chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        inspector/timeline-network-resource.html fails when run twice
+        https://bugs.webkit.org/show_bug.cgi?id=37394
+
+        Send didReceiveResponse notification to the timeline agent from ResourceLoadNotifier
+        instead of ResourceLoader::didReceiveResponse to cover the cases when resources
+        are loaded from memory cache.
+
+        Network notifications are now send to InspectorInstrumentation which dispatches
+        them to interested agents and InspectorController.
+        fix
+
+        * inspector/timeline-network-resource-expected.txt:
+        * inspector/timeline-network-resource.html:
+        * inspector/timeline-network-resource.js:
+
 2011-01-12  Jeremy Orlow  <jorlow at chromium.org>
 
         Add forgotten file.
diff --git a/LayoutTests/inspector/timeline-network-resource-expected.txt b/LayoutTests/inspector/timeline-network-resource-expected.txt
index d9418ca..9269775 100644
--- a/LayoutTests/inspector/timeline-network-resource-expected.txt
+++ b/LayoutTests/inspector/timeline-network-resource-expected.txt
@@ -8,7 +8,6 @@ ResourceSendRequest Properties:
         identifier : <number>
         url : <string>
         requestMethod : "GET"
-        isMainResource : false
     }
     type : 12
     usedHeapSize : <number>
@@ -22,7 +21,7 @@ ResourceReceiveResponse Properties:
         identifier : <number>
         statusCode : 0
         mimeType : <string>
-        expectedContentLength : 210
+        expectedContentLength : 208
         url : <string>
     }
     children : <object>
diff --git a/LayoutTests/inspector/timeline-network-resource.html b/LayoutTests/inspector/timeline-network-resource.html
index fe28ed3..7286fb6 100644
--- a/LayoutTests/inspector/timeline-network-resource.html
+++ b/LayoutTests/inspector/timeline-network-resource.html
@@ -6,16 +6,16 @@
 
 var scriptUrl = "timeline-network-resource.js";
 
-function runAfterScriptIsEvaluated(continuation)
+function runAfterScriptIsEvaluated()
 {
-    function step()
-    {
-        if (!window.scriptEvaluated)
-            setTimeout(step, 100);
-        else
-            continuation();
-    }
-    setTimeout(step, 100);
+    printTimelineRecords(null, null, function(record) {
+        if (record.type === timelineAgentRecordType["ResourceSendRequest"])
+            printSend(record);
+        else if (record.type === timelineAgentRecordType["ResourceReceiveResponse"])
+            printReceive(record);
+        else if (record.type === timelineAgentRecordType["ResourceFinish"])
+            printFinish(record);
+    });
 }
 
 function printRecord(record)
@@ -60,17 +60,6 @@ function doit()
     var script = document.createElement("script");
     script.src = scriptUrl;
     document.body.appendChild(script);
-    runAfterScriptIsEvaluated(function() {
-        printTimelineRecords(null, null, function(record) {
-            if (record.type === timelineAgentRecordType["ResourceSendRequest"])
-                printSend(record);
-     
-            else if (record.type === timelineAgentRecordType["ResourceReceiveResponse"])
-                printReceive(record);
-            else if (record.type === timelineAgentRecordType["ResourceFinish"])
-                printFinish(record);
-        });
-    });
 }
 
 </script>
diff --git a/LayoutTests/inspector/timeline-network-resource.js b/LayoutTests/inspector/timeline-network-resource.js
index 6fe0d18..de7c720 100644
--- a/LayoutTests/inspector/timeline-network-resource.js
+++ b/LayoutTests/inspector/timeline-network-resource.js
@@ -3,4 +3,4 @@
 var element = document.createElement("div");
 element.innerHTML = "Script resource loaded";
 document.body.appendChild(element);
-window.scriptEvaluated = true;
+runAfterScriptIsEvaluated();
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index bc55e27..5bf1073 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,93 @@
+2010-12-29  Yury Semikhatsky  <yurys at chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        inspector/timeline-network-resource.html fails when run twice
+        https://bugs.webkit.org/show_bug.cgi?id=37394
+
+        Send didReceiveResponse notification to the timeline agent from ResourceLoadNotifier
+        instead of ResourceLoader::didReceiveResponse to cover the cases when resources
+        are loaded from memory cache.
+
+        Network notifications are now sent to InspectorInstrumentation which dispatches
+        them to interested agents and InspectorController.
+
+        * inspector/Inspector.idl:
+        * inspector/InspectorApplicationCacheAgent.cpp:
+        (WebCore::InspectorApplicationCacheAgent::didReceiveManifestResponse):
+        * inspector/InspectorController.cpp:
+        (WebCore::InspectorController::InspectorController):
+        (WebCore::InspectorController::didCommitLoad):
+        (WebCore::InspectorController::willSendRequest):
+        (WebCore::InspectorController::didReceiveResponse):
+        (WebCore::InspectorController::didFailLoading):
+        (WebCore::InspectorController::resourceRetrievedByXMLHttpRequest):
+        * inspector/InspectorController.h:
+        * inspector/InspectorInstrumentation.cpp:
+        (WebCore::InspectorInstrumentation::identifierForInitialRequestImpl):
+        (WebCore::InspectorInstrumentation::willSendRequestImpl):
+        (WebCore::InspectorInstrumentation::markResourceAsCachedImpl):
+        (WebCore::InspectorInstrumentation::didLoadResourceFromMemoryCacheImpl):
+        (WebCore::InspectorInstrumentation::willReceiveResourceResponseImpl):
+        (WebCore::InspectorInstrumentation::didReceiveContentLengthImpl):
+        (WebCore::InspectorInstrumentation::didFinishLoadingImpl):
+        (WebCore::InspectorInstrumentation::didFailLoadingImpl):
+        (WebCore::InspectorInstrumentation::resourceRetrievedByXMLHttpRequestImpl):
+        (WebCore::InspectorInstrumentation::scriptImportedImpl):
+        (WebCore::InspectorInstrumentation::retrieveResourceAgent):
+        * inspector/InspectorInstrumentation.h:
+        (WebCore::InspectorInstrumentation::identifierForInitialRequest):
+        (WebCore::InspectorInstrumentation::willSendRequest):
+        (WebCore::InspectorInstrumentation::markResourceAsCached):
+        (WebCore::InspectorInstrumentation::didLoadResourceFromMemoryCache):
+        (WebCore::InspectorInstrumentation::willReceiveResourceResponse):
+        (WebCore::InspectorInstrumentation::didReceiveContentLength):
+        (WebCore::InspectorInstrumentation::didFinishLoading):
+        (WebCore::InspectorInstrumentation::didFailLoading):
+        (WebCore::InspectorInstrumentation::resourceRetrievedByXMLHttpRequest):
+        (WebCore::InspectorInstrumentation::scriptImported):
+        * inspector/InspectorResourceAgent.cpp:
+        (WebCore::InspectorResourceAgent::identifierForInitialRequest):
+        * inspector/InspectorResourceAgent.h:
+        * inspector/InspectorTimelineAgent.cpp:
+        (WebCore::InspectorTimelineAgent::willSendResourceRequest):
+        * inspector/InspectorTimelineAgent.h:
+        * inspector/TimelineRecordFactory.cpp:
+        (WebCore::TimelineRecordFactory::createResourceSendRequestData):
+        * inspector/TimelineRecordFactory.h:
+        * inspector/front-end/NetworkManager.js:
+        (WebInspector.NetworkManager.prototype.identifierForInitialRequest):
+        * inspector/front-end/TimelinePanel.js:
+        (WebInspector.TimelinePanel.prototype.addRecordToTimeline):
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::loadedResourceFromMemoryCache):
+        * loader/ResourceLoadNotifier.cpp:
+        (WebCore::ResourceLoadNotifier::didReceiveResponse):
+        (WebCore::ResourceLoadNotifier::didFailToLoad):
+        (WebCore::ResourceLoadNotifier::assignIdentifierToInitialRequest):
+        (WebCore::ResourceLoadNotifier::dispatchWillSendRequest):
+        (WebCore::ResourceLoadNotifier::dispatchDidReceiveResponse):
+        (WebCore::ResourceLoadNotifier::dispatchDidReceiveContentLength):
+        (WebCore::ResourceLoadNotifier::dispatchDidFinishLoading):
+        (WebCore::ResourceLoadNotifier::sendRemainingDelegateMessages):
+        * loader/ResourceLoader.cpp:
+        (WebCore::ResourceLoader::didReceiveResponse):
+        * loader/appcache/ApplicationCacheGroup.cpp:
+        (WebCore::ApplicationCacheGroup::createResourceHandle):
+        (WebCore::ApplicationCacheGroup::didReceiveResponse):
+        (WebCore::ApplicationCacheGroup::didReceiveData):
+        (WebCore::ApplicationCacheGroup::didFinishLoading):
+        (WebCore::ApplicationCacheGroup::didFail):
+        * loader/appcache/ApplicationCacheGroup.h:
+        * workers/DefaultSharedWorkerRepository.cpp:
+        (WebCore::SharedWorkerScriptLoader::notifyFinished):
+        * workers/Worker.cpp:
+        (WebCore::Worker::notifyFinished):
+        * workers/WorkerContext.cpp:
+        (WebCore::WorkerContext::importScripts):
+        * xml/XMLHttpRequest.cpp:
+        (WebCore::XMLHttpRequest::didFinishLoading):
+
 2011-01-12  Pavel Podivilov  <podivilov at chromium.org>
 
         Reviewed by Pavel Feldman.
diff --git a/Source/WebCore/inspector/Inspector.idl b/Source/WebCore/inspector/Inspector.idl
index 5359e16..ed00cc7 100644
--- a/Source/WebCore/inspector/Inspector.idl
+++ b/Source/WebCore/inspector/Inspector.idl
@@ -91,7 +91,7 @@ module core {
         [domain=Network] void resourceContent(in unsigned long frameId, in String url, in boolean base64Encode, out String content);
         [notify, domain=Network] void frameDetachedFromParent(out unsigned long frameId);
 
-        [notify, domain=Network] void identifierForInitialRequest(out long identifier, out String url, out Object loader, out Value callStack);
+        [notify, domain=Network] void identifierForInitialRequest(out long identifier, out String url, out Object loader, out boolean isMainResourceLoader, 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);
diff --git a/Source/WebCore/inspector/InspectorApplicationCacheAgent.cpp b/Source/WebCore/inspector/InspectorApplicationCacheAgent.cpp
index ced61c5..1cca6fe 100644
--- a/Source/WebCore/inspector/InspectorApplicationCacheAgent.cpp
+++ b/Source/WebCore/inspector/InspectorApplicationCacheAgent.cpp
@@ -35,6 +35,7 @@
 #include "InspectorController.h"
 #include "InspectorFrontend.h"
 #include "InspectorValues.h"
+#include "NetworkStateNotifier.h"
 #include "Page.h"
 #include "ResourceResponse.h"
 
@@ -46,18 +47,15 @@ InspectorApplicationCacheAgent::InspectorApplicationCacheAgent(InspectorControll
 {
 }
 
-void InspectorApplicationCacheAgent::didReceiveManifestResponse(unsigned long identifier, const ResourceResponse& response)
-{
-    m_inspectorController->didReceiveResponse(identifier, 0, response);
-}
-
-void InspectorApplicationCacheAgent::updateApplicationCacheStatus(ApplicationCacheHost::Status status)
+void InspectorApplicationCacheAgent::updateApplicationCacheStatus(Frame* frame)
 {
+    ApplicationCacheHost::Status status = frame->loader()->documentLoader()->applicationCacheHost()->status();
     m_frontend->updateApplicationCacheStatus(status);
 }
 
-void InspectorApplicationCacheAgent::updateNetworkState(bool isNowOnline)
+void InspectorApplicationCacheAgent::networkStateChanged()
 {
+    bool isNowOnline = networkStateNotifier().onLine();
     m_frontend->updateNetworkState(isNowOnline);
 }
 
diff --git a/Source/WebCore/inspector/InspectorApplicationCacheAgent.h b/Source/WebCore/inspector/InspectorApplicationCacheAgent.h
index 11f10ce..3d9e494 100644
--- a/Source/WebCore/inspector/InspectorApplicationCacheAgent.h
+++ b/Source/WebCore/inspector/InspectorApplicationCacheAgent.h
@@ -33,6 +33,7 @@
 
 namespace WebCore {
 
+class Frame;
 class InspectorArray;
 class InspectorController;
 class InspectorFrontend;
@@ -46,9 +47,8 @@ public:
     ~InspectorApplicationCacheAgent() { }
 
     // Backend to Frontend
-    void didReceiveManifestResponse(unsigned long identifier, const ResourceResponse&);
-    void updateApplicationCacheStatus(ApplicationCacheHost::Status);
-    void updateNetworkState(bool isNowOnline);
+    void updateApplicationCacheStatus(Frame*);
+    void networkStateChanged();
 
     // From Frontend
     void getApplicationCaches(RefPtr<InspectorValue>* applicationCaches);
diff --git a/Source/WebCore/inspector/InspectorController.cpp b/Source/WebCore/inspector/InspectorController.cpp
index b0babdc..ee1536f 100644
--- a/Source/WebCore/inspector/InspectorController.cpp
+++ b/Source/WebCore/inspector/InspectorController.cpp
@@ -140,7 +140,6 @@ InspectorController::InspectorController(Page* page, InspectorClient* client)
     , m_client(client)
     , m_openingFrontend(false)
     , m_cssAgent(new InspectorCSSAgent())
-    , m_mainResourceIdentifier(0)
     , m_expiredConsoleMessageCount(0)
     , m_previousMessage(0)
     , m_settingsLoaded(false)
@@ -759,7 +758,6 @@ void InspectorController::didCommitLoad(DocumentLoader* loader)
 #endif
 
         if (m_frontend) {
-            m_mainResourceIdentifier = 0;
             m_frontend->didCommitLoad();
             m_domAgent->setDocument(m_inspectedPage->mainFrame()->document());
         }
@@ -775,33 +773,6 @@ void InspectorController::frameDetachedFromParent(Frame* rootFrame)
         m_resourceAgent->frameDetachedFromParent(rootFrame);
 }
 
-void InspectorController::didLoadResourceFromMemoryCache(DocumentLoader* loader, const CachedResource* cachedResource)
-{
-    if (!enabled())
-        return;
-
-    ensureSettingsLoaded();
-
-    if (m_resourceAgent)
-        m_resourceAgent->didLoadResourceFromMemoryCache(loader, cachedResource);
-}
-
-void InspectorController::identifierForInitialRequest(unsigned long identifier, DocumentLoader* loader, const ResourceRequest& request)
-{
-    if (!enabled())
-        return;
-    ASSERT(m_inspectedPage);
-
-    bool isMainResource = isMainResourceLoader(loader, request.url());
-    if (isMainResource)
-        m_mainResourceIdentifier = identifier;
-
-    ensureSettingsLoaded();
-
-    if (m_resourceAgent)
-        m_resourceAgent->identifierForInitialRequest(identifier, request.url(), loader);
-}
-
 void InspectorController::mainResourceFiredDOMContentEvent(DocumentLoader* loader, const KURL& url)
 {
     if (!enabled() || !isMainResourceLoader(loader, url))
@@ -829,7 +800,7 @@ bool InspectorController::isMainResourceLoader(DocumentLoader* loader, const KUR
     return loader->frame() == m_inspectedPage->mainFrame() && requestUrl == loader->requestURL();
 }
 
-void InspectorController::willSendRequest(unsigned long identifier, ResourceRequest& request, const ResourceResponse& redirectResponse)
+void InspectorController::willSendRequest(ResourceRequest& request)
 {
     if (!enabled())
         return;
@@ -845,95 +816,37 @@ void InspectorController::willSendRequest(unsigned long identifier, ResourceRequ
                 request.setHTTPHeaderField(it->first, it->second);
         }
     }
-
-    bool isMainResource = m_mainResourceIdentifier == identifier;
-    if (m_timelineAgent)
-        m_timelineAgent->willSendResourceRequest(identifier, isMainResource, request);
-
-    if (m_resourceAgent)
-        m_resourceAgent->willSendRequest(identifier, request, redirectResponse);
 }
 
-void InspectorController::markResourceAsCached(unsigned long identifier)
+void InspectorController::didReceiveResponse(unsigned long identifier, const ResourceResponse& response)
 {
     if (!enabled())
         return;
 
-    if (m_resourceAgent)
-        m_resourceAgent->markResourceAsCached(identifier);
-}
-
-void InspectorController::didReceiveResponse(unsigned long identifier, DocumentLoader* loader, const ResourceResponse& response)
-{
-    if (!enabled())
-        return;
-
-    if (m_resourceAgent)
-        m_resourceAgent->didReceiveResponse(identifier, loader, response);
-
     if (response.httpStatusCode() >= 400) {
         String message = makeString("Failed to load resource: the server responded with a status of ", String::number(response.httpStatusCode()), " (", response.httpStatusText(), ')');
         addConsoleMessage(new ConsoleMessage(OtherMessageSource, NetworkErrorMessageType, ErrorMessageLevel, message, response.url().string(), identifier));
     }
 }
 
-void InspectorController::didReceiveContentLength(unsigned long identifier, int lengthReceived)
-{
-    if (!enabled())
-        return;
-
-    if (m_resourceAgent)
-        m_resourceAgent->didReceiveContentLength(identifier, lengthReceived);
-}
-
-void InspectorController::didFinishLoading(unsigned long identifier, double finishTime)
-{
-    if (!enabled())
-        return;
-
-    if (m_timelineAgent)
-        m_timelineAgent->didFinishLoadingResource(identifier, false, finishTime);
-
-    if (m_resourceAgent)
-        m_resourceAgent->didFinishLoading(identifier, finishTime);
-}
-
 void InspectorController::didFailLoading(unsigned long identifier, const ResourceError& error)
 {
     if (!enabled())
         return;
 
-    if (m_timelineAgent)
-        m_timelineAgent->didFinishLoadingResource(identifier, true, 0);
-
     String message = "Failed to load resource";
-        if (!error.localizedDescription().isEmpty())
-            message += ": " + error.localizedDescription();
-        addConsoleMessage(new ConsoleMessage(OtherMessageSource, NetworkErrorMessageType, ErrorMessageLevel, message, error.failingURL(), identifier));
-
-    if (m_resourceAgent)
-        m_resourceAgent->didFailLoading(identifier, error);
+    if (!error.localizedDescription().isEmpty())
+        message += ": " + error.localizedDescription();
+    addConsoleMessage(new ConsoleMessage(OtherMessageSource, NetworkErrorMessageType, ErrorMessageLevel, message, error.failingURL(), identifier));
 }
 
-void InspectorController::resourceRetrievedByXMLHttpRequest(unsigned long identifier, const String& sourceString, const String& url, const String& sendURL, unsigned sendLineNumber)
+void InspectorController::resourceRetrievedByXMLHttpRequest(const String& url, const String& sendURL, unsigned sendLineNumber)
 {
     if (!enabled())
         return;
 
     if (m_state->getBoolean(InspectorState::monitoringXHR))
         addMessageToConsole(JSMessageSource, LogMessageType, LogMessageLevel, "XHR finished loading: \"" + url + "\".", sendLineNumber, sendURL);
-
-    if (m_resourceAgent)
-        m_resourceAgent->setInitialContent(identifier, sourceString, "XHR");
-}
-
-void InspectorController::scriptImported(unsigned long identifier, const String& sourceString)
-{
-    if (!enabled())
-        return;
-
-    if (m_resourceAgent)
-        m_resourceAgent->setInitialContent(identifier, sourceString, "Script");
 }
 
 void InspectorController::ensureSettingsLoaded()
diff --git a/Source/WebCore/inspector/InspectorController.h b/Source/WebCore/inspector/InspectorController.h
index 481344d..fef2a6d 100644
--- a/Source/WebCore/inspector/InspectorController.h
+++ b/Source/WebCore/inspector/InspectorController.h
@@ -158,22 +158,9 @@ public:
 
     void didCommitLoad(DocumentLoader*);
     void frameDetachedFromParent(Frame*);
-    void didLoadResourceFromMemoryCache(DocumentLoader*, const CachedResource*);
-
-    void identifierForInitialRequest(unsigned long identifier, DocumentLoader*, const ResourceRequest&);
-    void willSendRequest(unsigned long identifier, ResourceRequest&, const ResourceResponse& redirectResponse);
-    void markResourceAsCached(unsigned long identifier);
-    void didReceiveResponse(unsigned long identifier, DocumentLoader*, const ResourceResponse&);
-    void didReceiveContentLength(unsigned long identifier, int lengthReceived);
-    void didFinishLoading(unsigned long identifier, double finishTime);
-    void didFailLoading(unsigned long identifier, const ResourceError&);
-    void resourceRetrievedByXMLHttpRequest(unsigned long identifier, const String& sourceString, const String& url, const String& sendURL, unsigned sendLineNumber);
-    void scriptImported(unsigned long identifier, const String& sourceString);
 
     void setExtraHeaders(PassRefPtr<InspectorObject>);
 
-    void ensureSettingsLoaded();
-
     void startTimelineProfiler();
     void stopTimelineProfiler();
     InspectorTimelineAgent* timelineAgent() { return m_timelineAgent.get(); }
@@ -277,21 +264,27 @@ public:
     static const unsigned defaultAttachedHeight;
 
 private:
-    void getInspectorState(RefPtr<InspectorObject>* state);
-    void setConsoleMessagesEnabled(bool enabled);
-
     friend class InspectorBackend;
     friend class InspectorBackendDispatcher;
     friend class InspectorInstrumentation;
     friend class InjectedScriptHost;
 
+    void willSendRequest(ResourceRequest&);
+    void didReceiveResponse(unsigned long identifier, const ResourceResponse&);
+    void didFailLoading(unsigned long identifier, const ResourceError&);
+    void resourceRetrievedByXMLHttpRequest(const String& url, const String& sendURL, unsigned sendLineNumber);
+
+    void ensureSettingsLoaded();
+
+    void getInspectorState(RefPtr<InspectorObject>* state);
+    void setConsoleMessagesEnabled(bool);
+
+    void populateScriptObjects();
+    void restoreDebugger();
     enum ProfilerRestoreAction {
         ProfilerRestoreNoAction = 0,
         ProfilerRestoreResetAgent = 1
     };
-    
-    void populateScriptObjects();
-    void restoreDebugger();
     void restoreProfiler(ProfilerRestoreAction action);
     void unbindAllResources();
     void setSearchingForNode(bool enabled);
@@ -349,7 +342,6 @@ private:
 
     RefPtr<Node> m_nodeToFocus;
     RefPtr<InspectorResourceAgent> m_resourceAgent;
-    unsigned long m_mainResourceIdentifier;
     Vector<OwnPtr<ConsoleMessage> > m_consoleMessages;
     unsigned m_expiredConsoleMessageCount;
     HashMap<String, double> m_times;
diff --git a/Source/WebCore/inspector/InspectorInstrumentation.cpp b/Source/WebCore/inspector/InspectorInstrumentation.cpp
index f3a73ba..9395dd5 100644
--- a/Source/WebCore/inspector/InspectorInstrumentation.cpp
+++ b/Source/WebCore/inspector/InspectorInstrumentation.cpp
@@ -34,11 +34,14 @@
 #if ENABLE(INSPECTOR)
 
 #include "DOMWindow.h"
+#include "DocumentLoader.h"
 #include "Event.h"
 #include "EventContext.h"
+#include "InspectorApplicationCacheAgent.h"
 #include "InspectorController.h"
 #include "InspectorDOMAgent.h"
 #include "InspectorDebuggerAgent.h"
+#include "InspectorResourceAgent.h"
 #include "InspectorTimelineAgent.h"
 #include "XMLHttpRequest.h"
 #include <wtf/text/CString.h>
@@ -372,6 +375,40 @@ void InspectorInstrumentation::didRecalculateStyleImpl(const InspectorInstrument
         timelineAgent->didRecalculateStyle();
 }
 
+void InspectorInstrumentation::identifierForInitialRequestImpl(InspectorController* ic, unsigned long identifier, DocumentLoader* loader, const ResourceRequest& request)
+{
+    if (!ic->enabled())
+        return;
+    ic->ensureSettingsLoaded();
+
+    if (InspectorResourceAgent* resourceAgent = retrieveResourceAgent(ic))
+        resourceAgent->identifierForInitialRequest(identifier, request.url(), loader, ic->isMainResourceLoader(loader, request.url()));
+}
+
+void InspectorInstrumentation::willSendRequestImpl(InspectorController* ic, unsigned long identifier, ResourceRequest& request, const ResourceResponse& redirectResponse)
+{
+    ic->willSendRequest(request);
+    if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(ic))
+        timelineAgent->willSendResourceRequest(identifier, request);
+    if (InspectorResourceAgent* resourceAgent = retrieveResourceAgent(ic))
+        resourceAgent->willSendRequest(identifier, request, redirectResponse);
+}
+
+void InspectorInstrumentation::markResourceAsCachedImpl(InspectorController* ic, unsigned long identifier)
+{
+    if (InspectorResourceAgent* resourceAgent = retrieveResourceAgent(ic))
+        resourceAgent->markResourceAsCached(identifier);
+}
+
+void InspectorInstrumentation::didLoadResourceFromMemoryCacheImpl(InspectorController* ic, DocumentLoader* loader, const CachedResource* cachedResource)
+{
+    if (!ic->enabled())
+        return;
+    ic->ensureSettingsLoaded();
+    if (InspectorResourceAgent* resourceAgent = retrieveResourceAgent(ic))
+        resourceAgent->didLoadResourceFromMemoryCache(loader, cachedResource);
+}
+
 InspectorInstrumentationCookie InspectorInstrumentation::willReceiveResourceDataImpl(InspectorController* inspectorController, unsigned long identifier)
 {
     int timelineAgentId = 0;
@@ -400,12 +437,54 @@ InspectorInstrumentationCookie InspectorInstrumentation::willReceiveResourceResp
     return InspectorInstrumentationCookie(inspectorController, timelineAgentId);
 }
 
-void InspectorInstrumentation::didReceiveResourceResponseImpl(const InspectorInstrumentationCookie& cookie)
+void InspectorInstrumentation::didReceiveResourceResponseImpl(const InspectorInstrumentationCookie& cookie, unsigned long identifier, DocumentLoader* loader, const ResourceResponse& response)
 {
+    InspectorController* ic = cookie.first;
+    if (InspectorResourceAgent* resourceAgent = retrieveResourceAgent(ic))
+        resourceAgent->didReceiveResponse(identifier, loader, response);
+    // FIXME(52282): move this to console agent.
+    ic->didReceiveResponse(identifier, response);
     if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(cookie))
         timelineAgent->didReceiveResourceResponse();
 }
 
+void InspectorInstrumentation::didReceiveContentLengthImpl(InspectorController* ic, unsigned long identifier, int lengthReceived)
+{
+    if (InspectorResourceAgent* resourceAgent = retrieveResourceAgent(ic))
+        resourceAgent->didReceiveContentLength(identifier, lengthReceived);
+}
+
+void InspectorInstrumentation::didFinishLoadingImpl(InspectorController* ic, unsigned long identifier, double finishTime)
+{
+    if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(ic))
+        timelineAgent->didFinishLoadingResource(identifier, false, finishTime);
+    if (InspectorResourceAgent* resourceAgent = retrieveResourceAgent(ic))
+        resourceAgent->didFinishLoading(identifier, finishTime);
+}
+
+void InspectorInstrumentation::didFailLoadingImpl(InspectorController* ic, unsigned long identifier, const ResourceError& error)
+{
+    // FIXME(52282): move this to console agent.
+    ic->didFailLoading(identifier, error);
+    if (InspectorTimelineAgent* timelineAgent = retrieveTimelineAgent(ic))
+        timelineAgent->didFinishLoadingResource(identifier, true, 0);
+    if (InspectorResourceAgent* resourceAgent = retrieveResourceAgent(ic))
+        resourceAgent->didFailLoading(identifier, error);
+}
+
+void InspectorInstrumentation::resourceRetrievedByXMLHttpRequestImpl(InspectorController* ic, unsigned long identifier, const String& sourceString, const String& url, const String& sendURL, unsigned sendLineNumber)
+{
+    ic->resourceRetrievedByXMLHttpRequest(url, sendURL, sendLineNumber);
+    if (InspectorResourceAgent* resourceAgent = retrieveResourceAgent(ic))
+        resourceAgent->setInitialContent(identifier, sourceString, "XHR");
+}
+
+void InspectorInstrumentation::scriptImportedImpl(InspectorController* ic, unsigned long identifier, const String& sourceString)
+{
+    if (InspectorResourceAgent* resourceAgent = retrieveResourceAgent(ic))
+        resourceAgent->setInitialContent(identifier, sourceString, "Script");
+}
+
 InspectorInstrumentationCookie InspectorInstrumentation::willWriteHTMLImpl(InspectorController* inspectorController, unsigned int length, unsigned int startLine)
 {
     int timelineAgentId = 0;
@@ -445,6 +524,20 @@ void InspectorInstrumentation::didCloseWebSocketImpl(InspectorController* inspec
 }
 #endif
 
+#if ENABLE(OFFLINE_WEB_APPLICATIONS)
+void InspectorInstrumentation::networkStateChangedImpl(InspectorController* ic)
+{
+    if (InspectorApplicationCacheAgent* applicationCacheAgent = ic->applicationCacheAgent())
+        applicationCacheAgent->networkStateChanged();
+}
+
+void InspectorInstrumentation::updateApplicationCacheStatusImpl(InspectorController* ic, Frame* frame)
+{
+    if (InspectorApplicationCacheAgent* applicationCacheAgent = ic->applicationCacheAgent())
+        applicationCacheAgent->updateApplicationCacheStatus(frame);
+}
+#endif
+
 bool InspectorInstrumentation::hasFrontend(InspectorController* inspectorController)
 {
     return inspectorController->hasFrontend();
@@ -490,6 +583,11 @@ InspectorTimelineAgent* InspectorInstrumentation::retrieveTimelineAgent(const In
     return 0;
 }
 
+InspectorResourceAgent* InspectorInstrumentation::retrieveResourceAgent(InspectorController* ic)
+{
+    return ic->m_resourceAgent.get();
+}
+
 } // namespace WebCore
 
 #endif // !ENABLE(INSPECTOR)
diff --git a/Source/WebCore/inspector/InspectorInstrumentation.h b/Source/WebCore/inspector/InspectorInstrumentation.h
index 9c69055..3b86b19 100644
--- a/Source/WebCore/inspector/InspectorInstrumentation.h
+++ b/Source/WebCore/inspector/InspectorInstrumentation.h
@@ -41,12 +41,15 @@ class CharacterData;
 class Document;
 class Element;
 class EventContext;
+class DocumentLoader;
 class InspectorController;
+class InspectorResourceAgent;
 class InspectorTimelineAgent;
 class KURL;
 class Node;
 class ResourceRequest;
 class ResourceResponse;
+class ScriptExecutionContext;
 class XMLHttpRequest;
 
 #if ENABLE(WEB_SOCKETS)
@@ -90,10 +93,20 @@ public:
     static void didPaint(const InspectorInstrumentationCookie&);
     static InspectorInstrumentationCookie willRecalculateStyle(Document*);
     static void didRecalculateStyle(const InspectorInstrumentationCookie&);
+
+    static void identifierForInitialRequest(Frame*, unsigned long identifier, DocumentLoader*, const ResourceRequest&);
+    static void willSendRequest(Frame*, unsigned long identifier, ResourceRequest&, const ResourceResponse& redirectResponse);
+    static void markResourceAsCached(Page*, unsigned long identifier);
+    static void didLoadResourceFromMemoryCache(Page*, DocumentLoader*, const CachedResource*);
     static InspectorInstrumentationCookie willReceiveResourceData(Frame*, unsigned long identifier);
     static void didReceiveResourceData(const InspectorInstrumentationCookie&);
-    static InspectorInstrumentationCookie willReceiveResourceResponse(Frame*, unsigned long identifier, const ResourceResponse& response);
-    static void didReceiveResourceResponse(const InspectorInstrumentationCookie&);
+    static InspectorInstrumentationCookie willReceiveResourceResponse(Frame*, unsigned long identifier, const ResourceResponse&);
+    static void didReceiveResourceResponse(const InspectorInstrumentationCookie&, unsigned long identifier, DocumentLoader*, const ResourceResponse&);
+    static void didReceiveContentLength(Frame*, unsigned long identifier, int lengthReceived);
+    static void didFinishLoading(Frame*, unsigned long identifier, double finishTime);
+    static void didFailLoading(Frame*, unsigned long identifier, const ResourceError&);
+    static void resourceRetrievedByXMLHttpRequest(ScriptExecutionContext*, unsigned long identifier, const String& sourceString, const String& url, const String& sendURL, unsigned sendLineNumber);
+    static void scriptImported(ScriptExecutionContext*, unsigned long identifier, const String& sourceString);
     static InspectorInstrumentationCookie willWriteHTML(Document*, unsigned int length, unsigned int startLine);
     static void didWriteHTML(const InspectorInstrumentationCookie&, unsigned int endLine);
 
@@ -103,7 +116,10 @@ public:
     static void didReceiveWebSocketHandshakeResponse(ScriptExecutionContext*, unsigned long identifier, const WebSocketHandshakeResponse&);
     static void didCloseWebSocket(ScriptExecutionContext*, unsigned long identifier);
 #endif
-
+    static void networkStateChanged(Page*);
+#if ENABLE(OFFLINE_WEB_APPLICATIONS)
+    static void updateApplicationCacheStatus(Frame*);
+#endif
 #if ENABLE(INSPECTOR)
     static void frontendCreated() { s_frontendCounter += 1; }
     static void frontendDeleted() { s_frontendCounter -= 1; }
@@ -147,10 +163,19 @@ private:
     static void didPaintImpl(const InspectorInstrumentationCookie&);
     static InspectorInstrumentationCookie willRecalculateStyleImpl(InspectorController*);
     static void didRecalculateStyleImpl(const InspectorInstrumentationCookie&);
+    static void identifierForInitialRequestImpl(InspectorController*, unsigned long identifier, DocumentLoader*, const ResourceRequest&);
+    static void willSendRequestImpl(InspectorController*, unsigned long identifier, ResourceRequest&, const ResourceResponse& redirectResponse);
+    static void markResourceAsCachedImpl(InspectorController*, unsigned long identifier);
+    static void didLoadResourceFromMemoryCacheImpl(InspectorController*, DocumentLoader*, const CachedResource*);
     static InspectorInstrumentationCookie willReceiveResourceDataImpl(InspectorController*, unsigned long identifier);
     static void didReceiveResourceDataImpl(const InspectorInstrumentationCookie&);
-    static InspectorInstrumentationCookie willReceiveResourceResponseImpl(InspectorController*, unsigned long identifier, const ResourceResponse& response);
-    static void didReceiveResourceResponseImpl(const InspectorInstrumentationCookie&);
+    static InspectorInstrumentationCookie willReceiveResourceResponseImpl(InspectorController*, unsigned long identifier, const ResourceResponse&);
+    static void didReceiveResourceResponseImpl(const InspectorInstrumentationCookie&, unsigned long identifier, DocumentLoader*, const ResourceResponse&);
+    static void didReceiveContentLengthImpl(InspectorController*, unsigned long identifier, int lengthReceived);
+    static void didFinishLoadingImpl(InspectorController*, unsigned long identifier, double finishTime);
+    static void didFailLoadingImpl(InspectorController*, unsigned long identifier, const ResourceError&);
+    static void resourceRetrievedByXMLHttpRequestImpl(InspectorController*, unsigned long identifier, const String& sourceString, const String& url, const String& sendURL, unsigned sendLineNumber);
+    static void scriptImportedImpl(InspectorController*, unsigned long identifier, const String& sourceString);
     static InspectorInstrumentationCookie willWriteHTMLImpl(InspectorController*, unsigned int length, unsigned int startLine);
     static void didWriteHTMLImpl(const InspectorInstrumentationCookie&, unsigned int endLine);
 
@@ -161,6 +186,11 @@ private:
     static void didCloseWebSocketImpl(InspectorController*, unsigned long identifier);
 #endif
 
+#if ENABLE(OFFLINE_WEB_APPLICATIONS)
+    static void networkStateChangedImpl(InspectorController*);
+    static void updateApplicationCacheStatusImpl(InspectorController*, Frame*);
+#endif
+
     static InspectorController* inspectorControllerForContext(ScriptExecutionContext*);
     static InspectorController* inspectorControllerForDocument(Document*);
     static InspectorController* inspectorControllerForFrame(Frame*);
@@ -171,6 +201,7 @@ private:
     static void cancelPauseOnNativeEvent(InspectorController*);
     static InspectorTimelineAgent* retrieveTimelineAgent(InspectorController*);
     static InspectorTimelineAgent* retrieveTimelineAgent(const InspectorInstrumentationCookie&);
+    static InspectorResourceAgent* retrieveResourceAgent(InspectorController*);
 
     static int s_frontendCounter;
 #endif
@@ -429,6 +460,39 @@ inline void InspectorInstrumentation::didRecalculateStyle(const InspectorInstrum
 #endif
 }
 
+inline void InspectorInstrumentation::identifierForInitialRequest(Frame* frame, unsigned long identifier, DocumentLoader* loader, const ResourceRequest& request)
+{
+#if ENABLE(INSPECTOR)
+    // This notification should be procecessed even in cases there is no frontend.
+    if (!frame)
+        return;
+    if (InspectorController* ic = frame->page()->inspectorController())
+        identifierForInitialRequestImpl(ic, identifier, loader, request);
+#endif
+}
+
+inline void InspectorInstrumentation::willSendRequest(Frame* frame, unsigned long identifier, ResourceRequest& request, const ResourceResponse& redirectResponse)
+{
+#if ENABLE(INSPECTOR)
+    if (InspectorController* ic = inspectorControllerForFrame(frame))
+        willSendRequestImpl(ic, identifier, request, redirectResponse);
+#endif
+}
+
+inline void InspectorInstrumentation::markResourceAsCached(Page* page, unsigned long identifier)
+{
+#if ENABLE(INSPECTOR)
+    markResourceAsCachedImpl(page->inspectorController(), identifier); 
+#endif
+}
+
+inline void InspectorInstrumentation::didLoadResourceFromMemoryCache(Page* page, DocumentLoader* loader, const CachedResource* resource)
+{
+#if ENABLE(INSPECTOR)
+    didLoadResourceFromMemoryCacheImpl(page->inspectorController(), loader, resource);
+#endif
+}
+
 inline InspectorInstrumentationCookie InspectorInstrumentation::willReceiveResourceData(Frame* frame, unsigned long identifier)
 {
 #if ENABLE(INSPECTOR)
@@ -455,11 +519,51 @@ inline InspectorInstrumentationCookie InspectorInstrumentation::willReceiveResou
     return InspectorInstrumentationCookie();
 }
 
-inline void InspectorInstrumentation::didReceiveResourceResponse(const InspectorInstrumentationCookie& cookie)
+inline void InspectorInstrumentation::didReceiveResourceResponse(const InspectorInstrumentationCookie& cookie, unsigned long identifier, DocumentLoader* loader, const ResourceResponse& response)
 {
 #if ENABLE(INSPECTOR)
     if (hasFrontends() && cookie.first)
-        didReceiveResourceResponseImpl(cookie);
+        didReceiveResourceResponseImpl(cookie, identifier, loader, response);
+#endif
+}
+
+inline void InspectorInstrumentation::didReceiveContentLength(Frame* frame, unsigned long identifier, int lengthReceived)
+{
+#if ENABLE(INSPECTOR)
+    if (InspectorController* inspectorController = inspectorControllerForFrame(frame))
+        didReceiveContentLengthImpl(inspectorController, identifier, lengthReceived);
+#endif
+}
+
+inline void InspectorInstrumentation::didFinishLoading(Frame* frame, unsigned long identifier, double finishTime)
+{
+#if ENABLE(INSPECTOR)
+    if (InspectorController* inspectorController = inspectorControllerForFrame(frame))
+        didFinishLoadingImpl(inspectorController, identifier, finishTime);
+#endif
+}
+
+inline void InspectorInstrumentation::didFailLoading(Frame* frame, unsigned long identifier, const ResourceError& error)
+{
+#if ENABLE(INSPECTOR)
+    if (InspectorController* inspectorController = inspectorControllerForFrame(frame))
+        didFailLoadingImpl(inspectorController, identifier, error);
+#endif
+}
+
+inline void InspectorInstrumentation::resourceRetrievedByXMLHttpRequest(ScriptExecutionContext* context, unsigned long identifier, const String& sourceString, const String& url, const String& sendURL, unsigned sendLineNumber)
+{
+#if ENABLE(INSPECTOR)
+    if (InspectorController* inspectorController = context->inspectorController())
+        resourceRetrievedByXMLHttpRequestImpl(inspectorController, identifier, sourceString, url, sendURL, sendLineNumber);
+#endif
+}
+
+inline void InspectorInstrumentation::scriptImported(ScriptExecutionContext* context, unsigned long identifier, const String& sourceString)
+{
+#if ENABLE(INSPECTOR)
+    if (InspectorController* inspectorController = context->inspectorController())
+        scriptImportedImpl(inspectorController, identifier, sourceString);
 #endif
 }
 
@@ -514,6 +618,22 @@ inline void InspectorInstrumentation::didCloseWebSocket(ScriptExecutionContext*
 }
 #endif
 
+inline void InspectorInstrumentation::networkStateChanged(Page* page)
+{
+#if ENABLE(INSPECTOR) && ENABLE(OFFLINE_WEB_APPLICATIONS)
+    if (InspectorController* inspectorController = inspectorControllerForPage(page))
+        networkStateChangedImpl(inspectorController);
+#endif
+}
+
+#if ENABLE(INSPECTOR) && ENABLE(OFFLINE_WEB_APPLICATIONS)
+inline void InspectorInstrumentation::updateApplicationCacheStatus(Frame* frame)
+{
+    if (InspectorController* inspectorController = inspectorControllerForFrame(frame))
+        updateApplicationCacheStatusImpl(inspectorController, frame);
+}
+#endif
+
 #if ENABLE(INSPECTOR)
 inline InspectorController* InspectorInstrumentation::inspectorControllerForContext(ScriptExecutionContext* context)
 {
diff --git a/Source/WebCore/inspector/InspectorResourceAgent.cpp b/Source/WebCore/inspector/InspectorResourceAgent.cpp
index 9fc562c..a425797 100644
--- a/Source/WebCore/inspector/InspectorResourceAgent.cpp
+++ b/Source/WebCore/inspector/InspectorResourceAgent.cpp
@@ -283,7 +283,7 @@ InspectorResourceAgent::~InspectorResourceAgent()
 {
 }
 
-void InspectorResourceAgent::identifierForInitialRequest(unsigned long identifier, const KURL& url, DocumentLoader* loader)
+void InspectorResourceAgent::identifierForInitialRequest(unsigned long identifier, const KURL& url, DocumentLoader* loader, bool isMainResource)
 {
     RefPtr<InspectorObject> loaderObject = buildObjectForDocumentLoader(loader);
     RefPtr<ScriptCallStack> callStack = createScriptCallStack(ScriptCallStack::maxCallStackSizeToCapture, true);
@@ -292,7 +292,7 @@ void InspectorResourceAgent::identifierForInitialRequest(unsigned long identifie
         callStackValue = callStack->buildInspectorObject();
     else
         callStackValue = InspectorValue::null();
-    m_frontend->identifierForInitialRequest(identifier, url.string(), loaderObject, callStackValue);
+    m_frontend->identifierForInitialRequest(identifier, url.string(), loaderObject, isMainResource, callStackValue);
 }
 
 void InspectorResourceAgent::willSendRequest(unsigned long identifier, ResourceRequest& request, const ResourceResponse& redirectResponse)
diff --git a/Source/WebCore/inspector/InspectorResourceAgent.h b/Source/WebCore/inspector/InspectorResourceAgent.h
index 1e77d58..f3f3211 100644
--- a/Source/WebCore/inspector/InspectorResourceAgent.h
+++ b/Source/WebCore/inspector/InspectorResourceAgent.h
@@ -77,7 +77,7 @@ public:
 
     ~InspectorResourceAgent();
 
-    void identifierForInitialRequest(unsigned long identifier, const KURL&, DocumentLoader*);
+    void identifierForInitialRequest(unsigned long identifier, const KURL&, DocumentLoader*, bool isMainResource);
     void willSendRequest(unsigned long identifier, ResourceRequest&, const ResourceResponse& redirectResponse);
     void markResourceAsCached(unsigned long identifier);
     void didReceiveResponse(unsigned long identifier, DocumentLoader* laoder, const ResourceResponse&);
diff --git a/Source/WebCore/inspector/InspectorTimelineAgent.cpp b/Source/WebCore/inspector/InspectorTimelineAgent.cpp
index 74739e1..081a5f0 100644
--- a/Source/WebCore/inspector/InspectorTimelineAgent.cpp
+++ b/Source/WebCore/inspector/InspectorTimelineAgent.cpp
@@ -209,12 +209,11 @@ void InspectorTimelineAgent::didScheduleResourceRequest(const String& url)
     addRecordToTimeline(record.release(), ScheduleResourceRequestTimelineRecordType);
 }
 
-void InspectorTimelineAgent::willSendResourceRequest(unsigned long identifier, bool isMainResource,
-    const ResourceRequest& request)
+void InspectorTimelineAgent::willSendResourceRequest(unsigned long identifier, const ResourceRequest& request)
 {
     pushGCEventRecords();
     RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(WTF::currentTimeMS());
-    record->setObject("data", TimelineRecordFactory::createResourceSendRequestData(identifier, isMainResource, request));
+    record->setObject("data", TimelineRecordFactory::createResourceSendRequestData(identifier, request));
     record->setNumber("type", ResourceSendRequestTimelineRecordType);
     setHeapSizeStatistic(record.get());
     m_frontend->addRecordToTimeline(record.release());
diff --git a/Source/WebCore/inspector/InspectorTimelineAgent.h b/Source/WebCore/inspector/InspectorTimelineAgent.h
index bc1e027..33e2737 100644
--- a/Source/WebCore/inspector/InspectorTimelineAgent.h
+++ b/Source/WebCore/inspector/InspectorTimelineAgent.h
@@ -119,7 +119,7 @@ public:
     void didMarkLoadEvent();
 
     void didScheduleResourceRequest(const String& url);
-    void willSendResourceRequest(unsigned long, bool isMainResource, const ResourceRequest&);
+    void willSendResourceRequest(unsigned long, const ResourceRequest&);
     void willReceiveResourceResponse(unsigned long, const ResourceResponse&);
     void didReceiveResourceResponse();
     void didFinishLoadingResource(unsigned long, bool didFail, double finishTime);
diff --git a/Source/WebCore/inspector/TimelineRecordFactory.cpp b/Source/WebCore/inspector/TimelineRecordFactory.cpp
index 7f339cd..dd7f2be 100644
--- a/Source/WebCore/inspector/TimelineRecordFactory.cpp
+++ b/Source/WebCore/inspector/TimelineRecordFactory.cpp
@@ -129,13 +129,12 @@ PassRefPtr<InspectorObject> TimelineRecordFactory::createScheduleResourceRequest
     return data.release();
 }
 
-PassRefPtr<InspectorObject> TimelineRecordFactory::createResourceSendRequestData(unsigned long identifier, bool isMainResource, const ResourceRequest& request)
+PassRefPtr<InspectorObject> TimelineRecordFactory::createResourceSendRequestData(unsigned long identifier, const ResourceRequest& request)
 {
     RefPtr<InspectorObject> data = InspectorObject::create();
     data->setNumber("identifier", identifier);
     data->setString("url", request.url().string());
     data->setString("requestMethod", request.httpMethod());
-    data->setBoolean("isMainResource", isMainResource);
     return data.release();
 }
 
diff --git a/Source/WebCore/inspector/TimelineRecordFactory.h b/Source/WebCore/inspector/TimelineRecordFactory.h
index 5d4cb77..fafeae6 100644
--- a/Source/WebCore/inspector/TimelineRecordFactory.h
+++ b/Source/WebCore/inspector/TimelineRecordFactory.h
@@ -64,8 +64,7 @@ namespace WebCore {
 
         static PassRefPtr<InspectorObject> createMarkTimelineData(const String&);
 
-        static PassRefPtr<InspectorObject> createResourceSendRequestData(unsigned long identifier,
-            bool isMainResource, const ResourceRequest&);
+        static PassRefPtr<InspectorObject> createResourceSendRequestData(unsigned long identifier, const ResourceRequest&);
 
         static PassRefPtr<InspectorObject> createScheduleResourceRequestData(const String&);
 
diff --git a/Source/WebCore/inspector/front-end/NetworkManager.js b/Source/WebCore/inspector/front-end/NetworkManager.js
index adb6ca2..9c9381b 100644
--- a/Source/WebCore/inspector/front-end/NetworkManager.js
+++ b/Source/WebCore/inspector/front-end/NetworkManager.js
@@ -86,9 +86,13 @@ WebInspector.NetworkManager.updateResourceWithCachedResource = function(resource
 }
 
 WebInspector.NetworkManager.prototype = {
-    identifierForInitialRequest: function(identifier, url, loader, callStack)
+    identifierForInitialRequest: function(identifier, url, loader, isMainResource, callStack)
     {
         var resource = this._createResource(identifier, url, loader, callStack);
+        if (isMainResource) {
+            WebInspector.mainResource = resource;
+            resource.isMainResource = true;
+        }
 
         // It is important to bind resource url early (before scripts compile).
         this._resourceTreeModel.bindResourceURL(resource);
@@ -226,14 +230,7 @@ WebInspector.NetworkManager.prototype = {
     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;
-                WebInspector.panels.network.refreshResource(mainResource);
-            }
-        }
+        WebInspector.panels.network.refreshResource(WebInspector.mainResource);
     },
 
     didCreateWebSocket: function(identifier, requestURL)
@@ -299,6 +296,11 @@ WebInspector.NetworkManager.prototype = {
         newResource.redirects = originalResource.redirects || [];
         delete originalResource.redirects;
         newResource.redirects.push(originalResource);
+        if (originalResource.isMainResource) {
+            delete originalResource.isMainResource;
+            newResource.isMainResource = true;
+            WebInspector.mainResource = newResource;
+        }
         return newResource;
     }
 }
diff --git a/Source/WebCore/inspector/front-end/TimelinePanel.js b/Source/WebCore/inspector/front-end/TimelinePanel.js
index a661b75..acca387 100644
--- a/Source/WebCore/inspector/front-end/TimelinePanel.js
+++ b/Source/WebCore/inspector/front-end/TimelinePanel.js
@@ -297,8 +297,9 @@ WebInspector.TimelinePanel.prototype = {
 
     addRecordToTimeline: function(record)
     {
-        if (record.type == WebInspector.TimelineAgent.RecordType.ResourceSendRequest && record.data.isMainResource) {
-            if (this._mainResourceIdentifier != record.data.identifier) {
+        if (record.type == WebInspector.TimelineAgent.RecordType.ResourceSendRequest) {
+            var isMainResource = (record.data.identifier === WebInspector.mainResource.identifier);
+            if (isMainResource && this._mainResourceIdentifier !== record.data.identifier) {
                 // We are loading new main resource -> clear the panel. Check above is necessary since
                 // there may be several resource loads with main resource marker upon redirects, redirects are reported with
                 // the original identifier.
diff --git a/Source/WebCore/loader/FrameLoader.cpp b/Source/WebCore/loader/FrameLoader.cpp
index 0df8db6..34fa195 100644
--- a/Source/WebCore/loader/FrameLoader.cpp
+++ b/Source/WebCore/loader/FrameLoader.cpp
@@ -70,6 +70,7 @@
 #include "IconDatabase.h"
 #include "IconLoader.h"
 #include "InspectorController.h"
+#include "InspectorInstrumentation.h"
 #include "Logging.h"
 #include "MIMETypeRegistry.h"
 #include "MainResourceLoader.h"
@@ -3048,9 +3049,7 @@ void FrameLoader::loadedResourceFromMemoryCache(const CachedResource* resource)
         return;
 
     if (!page->areMemoryCacheClientCallsEnabled()) {
-#if ENABLE(INSPECTOR)
-        page->inspectorController()->didLoadResourceFromMemoryCache(m_documentLoader.get(), resource);
-#endif
+        InspectorInstrumentation::didLoadResourceFromMemoryCache(page, m_documentLoader.get(), resource);
         m_documentLoader->recordMemoryCacheLoadForFutureClientNotification(resource->url());
         m_documentLoader->didTellClientAboutLoad(resource->url());
         return;
@@ -3058,9 +3057,7 @@ void FrameLoader::loadedResourceFromMemoryCache(const CachedResource* resource)
 
     ResourceRequest request(resource->url());
     if (m_client->dispatchDidLoadResourceFromMemoryCache(m_documentLoader.get(), request, resource->response(), resource->encodedSize())) {
-#if ENABLE(INSPECTOR)
-        page->inspectorController()->didLoadResourceFromMemoryCache(m_documentLoader.get(), resource);
-#endif
+        InspectorInstrumentation::didLoadResourceFromMemoryCache(page, m_documentLoader.get(), resource);
         m_documentLoader->didTellClientAboutLoad(resource->url());
         return;
     }
@@ -3068,9 +3065,7 @@ void FrameLoader::loadedResourceFromMemoryCache(const CachedResource* resource)
     unsigned long identifier;
     ResourceError error;
     requestFromDelegate(request, identifier, error);
-#if ENABLE(INSPECTOR)
-    page->inspectorController()->markResourceAsCached(identifier);
-#endif
+    InspectorInstrumentation::markResourceAsCached(page, identifier);
     notifier()->sendRemainingDelegateMessages(m_documentLoader.get(), identifier, resource->response(), resource->encodedSize(), error);
 }
 
diff --git a/Source/WebCore/loader/ResourceLoadNotifier.cpp b/Source/WebCore/loader/ResourceLoadNotifier.cpp
index a36ed94..c928557 100644
--- a/Source/WebCore/loader/ResourceLoadNotifier.cpp
+++ b/Source/WebCore/loader/ResourceLoadNotifier.cpp
@@ -35,7 +35,7 @@
 #include "Frame.h"
 #include "FrameLoader.h"
 #include "FrameLoaderClient.h"
-#include "InspectorController.h"
+#include "InspectorInstrumentation.h"
 #include "Page.h"
 #include "ProgressTracker.h"
 #include "ResourceLoader.h"
@@ -97,20 +97,14 @@ void ResourceLoadNotifier::didFailToLoad(ResourceLoader* loader, const ResourceE
     if (!error.isNull())
         m_frame->loader()->client()->dispatchDidFailLoading(loader->documentLoader(), loader->identifier(), error);
 
-#if ENABLE(INSPECTOR)
-    if (Page* page = m_frame->page())
-        page->inspectorController()->didFailLoading(loader->identifier(), error);
-#endif
+    InspectorInstrumentation::didFailLoading(m_frame, loader->identifier(), error);
 }
 
 void ResourceLoadNotifier::assignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader* loader, const ResourceRequest& request)
 {
     m_frame->loader()->client()->assignIdentifierToInitialRequest(identifier, loader, request);
 
-#if ENABLE(INSPECTOR)
-    if (Page* page = m_frame->page())
-        page->inspectorController()->identifierForInitialRequest(identifier, loader, request);
-#endif
+    InspectorInstrumentation::identifierForInitialRequest(m_frame, identifier, loader, request);
 }
 
 void ResourceLoadNotifier::dispatchWillSendRequest(DocumentLoader* loader, unsigned long identifier, ResourceRequest& request, const ResourceResponse& redirectResponse)
@@ -124,10 +118,7 @@ void ResourceLoadNotifier::dispatchWillSendRequest(DocumentLoader* loader, unsig
     if (!request.isNull() && oldRequestURL != request.url().string().impl())
         m_frame->loader()->documentLoader()->didTellClientAboutLoad(request.url());
 
-#if ENABLE(INSPECTOR)
-    if (Page* page = m_frame->page())
-        page->inspectorController()->willSendRequest(identifier, request, redirectResponse);
-#endif
+    InspectorInstrumentation::willSendRequest(m_frame, identifier, request, redirectResponse);
 
     // Report WebTiming for all frames.
     if (loader && !request.isNull() && request.url() == loader->requestURL())
@@ -136,32 +127,23 @@ void ResourceLoadNotifier::dispatchWillSendRequest(DocumentLoader* loader, unsig
 
 void ResourceLoadNotifier::dispatchDidReceiveResponse(DocumentLoader* loader, unsigned long identifier, const ResourceResponse& r)
 {
+    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiveResourceResponse(m_frame, identifier, r);
     m_frame->loader()->client()->dispatchDidReceiveResponse(loader, identifier, r);
-
-#if ENABLE(INSPECTOR)
-    if (Page* page = m_frame->page())
-        page->inspectorController()->didReceiveResponse(identifier, loader, r);
-#endif
+    InspectorInstrumentation::didReceiveResourceResponse(cookie, identifier, loader, r);
 }
 
 void ResourceLoadNotifier::dispatchDidReceiveContentLength(DocumentLoader* loader, unsigned long identifier, int length)
 {
     m_frame->loader()->client()->dispatchDidReceiveContentLength(loader, identifier, length);
 
-#if ENABLE(INSPECTOR)
-    if (Page* page = m_frame->page())
-        page->inspectorController()->didReceiveContentLength(identifier, length);
-#endif
+    InspectorInstrumentation::didReceiveContentLength(m_frame, identifier, length);
 }
 
 void ResourceLoadNotifier::dispatchDidFinishLoading(DocumentLoader* loader, unsigned long identifier, double finishTime)
 {
     m_frame->loader()->client()->dispatchDidFinishLoading(loader, identifier);
 
-#if ENABLE(INSPECTOR)
-    if (Page* page = m_frame->page())
-        page->inspectorController()->didFinishLoading(identifier, finishTime);
-#endif
+    InspectorInstrumentation::didFinishLoading(m_frame, identifier, finishTime);
 }
 
 void ResourceLoadNotifier::dispatchTransferLoadingResourceFromPage(unsigned long identifier, DocumentLoader* loader, const ResourceRequest& request, Page* oldPage)
diff --git a/Source/WebCore/loader/ResourceLoader.cpp b/Source/WebCore/loader/ResourceLoader.cpp
index de39986..ea0d02a 100644
--- a/Source/WebCore/loader/ResourceLoader.cpp
+++ b/Source/WebCore/loader/ResourceLoader.cpp
@@ -420,9 +420,7 @@ void ResourceLoader::didReceiveResponse(ResourceHandle*, const ResourceResponse&
     if (documentLoader()->applicationCacheHost()->maybeLoadFallbackForResponse(this, response))
         return;
 #endif
-    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiveResourceResponse(m_frame.get(), identifier(), response);
     didReceiveResponse(response);
-    InspectorInstrumentation::didReceiveResourceResponse(cookie);
 }
 
 void ResourceLoader::didReceiveData(ResourceHandle*, const char* data, int length, int lengthReceived)
diff --git a/Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp b/Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp
index 6454b90..8595638 100644
--- a/Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp
+++ b/Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp
@@ -40,6 +40,7 @@
 #include "Frame.h"
 #include "FrameLoader.h"
 #include "FrameLoaderClient.h"
+#include "InspectorInstrumentation.h"
 #include "MainResourceLoader.h"
 #include "ManifestParser.h"
 #include "Page.h"
@@ -48,11 +49,7 @@
 #include <wtf/HashMap.h>
 
 #if ENABLE(INSPECTOR)
-#include "InspectorApplicationCacheAgent.h"
-#include "InspectorController.h"
 #include "ProgressTracker.h"
-#else
-#include <wtf/UnusedParam.h>
 #endif
 
 namespace WebCore {
@@ -395,30 +392,13 @@ void ApplicationCacheGroup::stopLoadingInFrame(Frame* frame)
     stopLoading();
 }
 
-#if ENABLE(INSPECTOR)
-static void inspectorUpdateApplicationCacheStatus(Frame* frame)
-{
-    if (!frame)
-        return;
-
-    if (Page *page = frame->page()) {
-        if (InspectorApplicationCacheAgent* applicationCacheAgent = page->inspectorController()->applicationCacheAgent()) {
-            ApplicationCacheHost::Status status = frame->loader()->documentLoader()->applicationCacheHost()->status();
-            applicationCacheAgent->updateApplicationCacheStatus(status);
-        }
-    }
-}
-#endif
-
 void ApplicationCacheGroup::setNewestCache(PassRefPtr<ApplicationCache> newestCache)
 {
     m_newestCache = newestCache;
 
     m_caches.add(m_newestCache.get());
     m_newestCache->setGroup(this);
-#if ENABLE(INSPECTOR)
-    inspectorUpdateApplicationCacheStatus(m_frame);
-#endif
+    InspectorInstrumentation::updateApplicationCacheStatus(m_frame);
 }
 
 void ApplicationCacheGroup::makeObsolete()
@@ -429,9 +409,7 @@ void ApplicationCacheGroup::makeObsolete()
     m_isObsolete = true;
     cacheStorage().cacheGroupMadeObsolete(this);
     ASSERT(!m_storageID);
-#if ENABLE(INSPECTOR)
-    inspectorUpdateApplicationCacheStatus(m_frame);
-#endif
+    InspectorInstrumentation::updateApplicationCacheStatus(m_frame);
 }
 
 void ApplicationCacheGroup::update(Frame* frame, ApplicationCacheUpdateOption updateOption)
@@ -496,35 +474,19 @@ PassRefPtr<ResourceHandle> ApplicationCacheGroup::createResourceHandle(const KUR
     // Because willSendRequest only gets called during redirects, we initialize
     // the identifier and the first willSendRequest here.
     m_currentResourceIdentifier = m_frame->page()->progress()->createUniqueIdentifier();
-    if (Page* page = m_frame->page()) {
-        InspectorController* inspectorController = page->inspectorController();
-        inspectorController->identifierForInitialRequest(m_currentResourceIdentifier, m_frame->loader()->documentLoader(), handle->firstRequest());
-        ResourceResponse redirectResponse = ResourceResponse();
-        inspectorController->willSendRequest(m_currentResourceIdentifier, request, redirectResponse);
-    }
+    InspectorInstrumentation::identifierForInitialRequest(m_frame, m_currentResourceIdentifier, m_frame->loader()->documentLoader(), handle->firstRequest());
+    ResourceResponse redirectResponse = ResourceResponse();
+    InspectorInstrumentation::willSendRequest(m_frame, m_currentResourceIdentifier, request, redirectResponse);
 #endif
     return handle;
 }
 
-#if ENABLE(INSPECTOR)
-void ApplicationCacheGroup::willSendRequest(ResourceHandle*, ResourceRequest& request, const ResourceResponse& redirectResponse)
-{
-    // This only gets called by ResourceHandleMac if there is a redirect.
-    if (Page* page = m_frame->page())
-        page->inspectorController()->willSendRequest(m_currentResourceIdentifier, request, redirectResponse);
-}
-#endif
-
 void ApplicationCacheGroup::didReceiveResponse(ResourceHandle* handle, const ResourceResponse& response)
 {
 #if ENABLE(INSPECTOR)
-    if (Page* page = m_frame->page()) {
-        if (handle == m_manifestHandle) {
-            if (InspectorApplicationCacheAgent* applicationCacheAgent = page->inspectorController()->applicationCacheAgent())
-                applicationCacheAgent->didReceiveManifestResponse(m_currentResourceIdentifier, response);
-        } else
-            page->inspectorController()->didReceiveResponse(m_currentResourceIdentifier, m_frame->loader()->documentLoader(), response);
-    }
+    DocumentLoader* loader = (handle == m_manifestHandle) ? 0 : m_frame->loader()->documentLoader();
+    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiveResourceResponse(m_frame, m_currentResourceIdentifier, response);
+    InspectorInstrumentation::didReceiveResourceResponse(cookie, m_currentResourceIdentifier, loader, response);
 #endif
 
     if (handle == m_manifestHandle) {
@@ -593,12 +555,7 @@ void ApplicationCacheGroup::didReceiveResponse(ResourceHandle* handle, const Res
 
 void ApplicationCacheGroup::didReceiveData(ResourceHandle* handle, const char* data, int length, int lengthReceived)
 {
-#if ENABLE(INSPECTOR)
-    if (Page* page = m_frame->page())
-        page->inspectorController()->didReceiveContentLength(m_currentResourceIdentifier, lengthReceived);
-#else
-    UNUSED_PARAM(lengthReceived);
-#endif
+    InspectorInstrumentation::didReceiveContentLength(m_frame, m_currentResourceIdentifier, lengthReceived);
 
     if (handle == m_manifestHandle) {
         didReceiveManifestData(data, length);
@@ -615,10 +572,7 @@ void ApplicationCacheGroup::didReceiveData(ResourceHandle* handle, const char* d
 
 void ApplicationCacheGroup::didFinishLoading(ResourceHandle* handle, double finishTime)
 {
-#if ENABLE(INSPECTOR)
-    if (Page* page = m_frame->page())
-        page->inspectorController()->didFinishLoading(m_currentResourceIdentifier, finishTime);
-#endif
+    InspectorInstrumentation::didFinishLoading(m_frame, m_currentResourceIdentifier, finishTime);
 
     if (handle == m_manifestHandle) {
         didFinishLoadingManifest();
@@ -657,12 +611,7 @@ void ApplicationCacheGroup::didFinishLoading(ResourceHandle* handle, double fini
 
 void ApplicationCacheGroup::didFail(ResourceHandle* handle, const ResourceError& error)
 {
-#if ENABLE(INSPECTOR)
-    if (Page* page = m_frame->page())
-        page->inspectorController()->didFailLoading(m_currentResourceIdentifier, error);
-#else
-    UNUSED_PARAM(error);
-#endif
+    InspectorInstrumentation::didFailLoading(m_frame, m_currentResourceIdentifier, error);
 
     if (handle == m_manifestHandle) {
         cacheUpdateFailed();
@@ -1161,9 +1110,7 @@ void ApplicationCacheGroup::postListenerTask(ApplicationCacheHost::EventID event
 void ApplicationCacheGroup::setUpdateStatus(UpdateStatus status)
 {
     m_updateStatus = status;
-#if ENABLE(INSPECTOR)
-    inspectorUpdateApplicationCacheStatus(m_frame);
-#endif
+    InspectorInstrumentation::updateApplicationCacheStatus(m_frame);
 }
 
 void ApplicationCacheGroup::clearStorageID()
diff --git a/Source/WebCore/loader/appcache/ApplicationCacheGroup.h b/Source/WebCore/loader/appcache/ApplicationCacheGroup.h
index 29d0749..2d8b83e 100644
--- a/Source/WebCore/loader/appcache/ApplicationCacheGroup.h
+++ b/Source/WebCore/loader/appcache/ApplicationCacheGroup.h
@@ -110,9 +110,6 @@ private:
     // the existing client callback cannot be used, so assume that any client that enables application cache also wants it to use credential storage.
     virtual bool shouldUseCredentialStorage(ResourceHandle*) { return true; }
 
-#if ENABLE(INSPECTOR)
-    virtual void willSendRequest(ResourceHandle*, ResourceRequest&, const ResourceResponse&);
-#endif
     virtual void didReceiveResponse(ResourceHandle*, const ResourceResponse&);
     virtual void didReceiveData(ResourceHandle*, const char*, int length, int lengthReceived);
     virtual void didFinishLoading(ResourceHandle*, double finishTime);
diff --git a/Source/WebCore/page/Page.cpp b/Source/WebCore/page/Page.cpp
index 3718d0a..3a248a1 100644
--- a/Source/WebCore/page/Page.cpp
+++ b/Source/WebCore/page/Page.cpp
@@ -47,6 +47,7 @@
 #include "HTMLElement.h"
 #include "HistoryItem.h"
 #include "InspectorController.h"
+#include "InspectorInstrumentation.h"
 #include "Logging.h"
 #include "MediaCanStartListener.h"
 #include "Navigator.h"
@@ -94,10 +95,6 @@
 #include "GeolocationController.h"
 #endif
 
-#if ENABLE(INSPECTOR) && ENABLE(OFFLINE_WEB_APPLICATIONS)
-#include "InspectorApplicationCacheAgent.h"
-#endif
-
 namespace WebCore {
 
 static HashSet<Page*>* allPages;
@@ -110,19 +107,12 @@ static void networkStateChanged()
 {
     Vector<RefPtr<Frame> > frames;
     
-#if ENABLE(INSPECTOR) && ENABLE(OFFLINE_WEB_APPLICATIONS)
-    bool isNowOnline = networkStateNotifier().onLine();
-#endif
-
     // Get all the frames of all the pages in all the page groups
     HashSet<Page*>::iterator end = allPages->end();
     for (HashSet<Page*>::iterator it = allPages->begin(); it != end; ++it) {
         for (Frame* frame = (*it)->mainFrame(); frame; frame = frame->tree()->traverseNext())
             frames.append(frame);
-#if ENABLE(INSPECTOR) && ENABLE(OFFLINE_WEB_APPLICATIONS)
-        if (InspectorApplicationCacheAgent* applicationCacheAgent = (*it)->inspectorController()->applicationCacheAgent())
-            applicationCacheAgent->updateNetworkState(isNowOnline);
-#endif
+        InspectorInstrumentation::networkStateChanged(*it);
     }
 
     AtomicString eventName = networkStateNotifier().onLine() ? eventNames().onlineEvent : eventNames().offlineEvent;
diff --git a/Source/WebCore/workers/DefaultSharedWorkerRepository.cpp b/Source/WebCore/workers/DefaultSharedWorkerRepository.cpp
index 4a8e947..3a14b62 100644
--- a/Source/WebCore/workers/DefaultSharedWorkerRepository.cpp
+++ b/Source/WebCore/workers/DefaultSharedWorkerRepository.cpp
@@ -37,7 +37,7 @@
 #include "ActiveDOMObject.h"
 #include "CrossThreadTask.h"
 #include "Document.h"
-#include "InspectorController.h"
+#include "InspectorInstrumentation.h"
 #include "MessageEvent.h"
 #include "MessagePort.h"
 #include "NotImplemented.h"
@@ -291,10 +291,7 @@ void SharedWorkerScriptLoader::notifyFinished()
     if (m_scriptLoader->failed())
         m_worker->dispatchEvent(Event::create(eventNames().errorEvent, false, true));
     else {
-#if ENABLE(INSPECTOR)
-        if (InspectorController* inspector = m_worker->scriptExecutionContext()->inspectorController())
-            inspector->scriptImported(m_scriptLoader->identifier(), m_scriptLoader->script());
-#endif
+        InspectorInstrumentation::scriptImported(m_worker->scriptExecutionContext(), m_scriptLoader->identifier(), m_scriptLoader->script());
         DefaultSharedWorkerRepository::instance().workerScriptLoaded(*m_proxy, m_worker->scriptExecutionContext()->userAgent(m_scriptLoader->url()), m_scriptLoader->script(), m_port.release());
     }
     m_worker->unsetPendingActivity(m_worker.get());
diff --git a/Source/WebCore/workers/Worker.cpp b/Source/WebCore/workers/Worker.cpp
index 32ec997..8a2f62a 100644
--- a/Source/WebCore/workers/Worker.cpp
+++ b/Source/WebCore/workers/Worker.cpp
@@ -41,6 +41,7 @@
 #include "Frame.h"
 #include "FrameLoader.h"
 #include "InspectorController.h"
+#include "InspectorInstrumentation.h"
 #include "MessageEvent.h"
 #include "TextEncoding.h"
 #include "WorkerContextProxy.h"
@@ -135,10 +136,7 @@ void Worker::notifyFinished()
         dispatchEvent(Event::create(eventNames().errorEvent, false, true));
     else {
         m_contextProxy->startWorkerContext(m_scriptLoader->url(), scriptExecutionContext()->userAgent(m_scriptLoader->url()), m_scriptLoader->script());
-#if ENABLE(INSPECTOR)
-        if (InspectorController* inspector = scriptExecutionContext()->inspectorController())
-            inspector->scriptImported(m_scriptLoader->identifier(), m_scriptLoader->script());
-#endif
+        InspectorInstrumentation::scriptImported(scriptExecutionContext(), m_scriptLoader->identifier(), m_scriptLoader->script());
     }
     m_scriptLoader = 0;
 
diff --git a/Source/WebCore/workers/WorkerContext.cpp b/Source/WebCore/workers/WorkerContext.cpp
index 345e5b7..6c50f1a 100644
--- a/Source/WebCore/workers/WorkerContext.cpp
+++ b/Source/WebCore/workers/WorkerContext.cpp
@@ -42,7 +42,7 @@
 #include "ErrorEvent.h"
 #include "Event.h"
 #include "EventException.h"
-#include "InspectorController.h"
+#include "InspectorInstrumentation.h"
 #include "KURL.h"
 #include "MessagePort.h"
 #include "NotImplemented.h"
@@ -245,10 +245,7 @@ void WorkerContext::importScripts(const Vector<String>& urls, ExceptionCode& ec)
             return;
         }
 
-#if ENABLE(INSPECTOR)
-        if (InspectorController* inspector = scriptExecutionContext()->inspectorController())
-            inspector->scriptImported(scriptLoader.identifier(), scriptLoader.script());
-#endif
+       InspectorInstrumentation::scriptImported(scriptExecutionContext(), scriptLoader.identifier(), scriptLoader.script());
 
         ScriptValue exception;
         m_script->evaluate(ScriptSourceCode(scriptLoader.script(), *it), &exception);
diff --git a/Source/WebCore/xml/XMLHttpRequest.cpp b/Source/WebCore/xml/XMLHttpRequest.cpp
index 5786176..ee9e20f 100644
--- a/Source/WebCore/xml/XMLHttpRequest.cpp
+++ b/Source/WebCore/xml/XMLHttpRequest.cpp
@@ -35,7 +35,6 @@
 #include "EventNames.h"
 #include "File.h"
 #include "HTTPParsers.h"
-#include "InspectorController.h"
 #include "InspectorInstrumentation.h"
 #include "ResourceError.h"
 #include "ResourceRequest.h"
@@ -998,10 +997,7 @@ void XMLHttpRequest::didFinishLoading(unsigned long identifier)
     // FIXME: Set m_responseBlob to something here in the ResponseTypeBlob case.
 #endif
 
-#if ENABLE(INSPECTOR)
-    if (InspectorController* inspector = scriptExecutionContext()->inspectorController())
-        inspector->resourceRetrievedByXMLHttpRequest(identifier, m_responseBuilder.toStringPreserveCapacity(), m_url, m_lastSendURL, m_lastSendLineNumber);
-#endif
+    InspectorInstrumentation::resourceRetrievedByXMLHttpRequest(scriptExecutionContext(), identifier, m_responseBuilder.toStringPreserveCapacity(), m_url, m_lastSendURL, m_lastSendLineNumber);
 
     bool hadLoader = m_loader;
     m_loader = 0;
diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog
index c98f15b..bae9ea1 100644
--- a/WebKit/chromium/ChangeLog
+++ b/WebKit/chromium/ChangeLog
@@ -1,3 +1,29 @@
+2010-12-29  Yury Semikhatsky  <yurys at chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        inspector/timeline-network-resource.html fails when run twice
+        https://bugs.webkit.org/show_bug.cgi?id=37394
+
+        Send didReceiveResponse notification to the timeline agent from ResourceLoadNotifier
+        instead of ResourceLoader::didReceiveResponse to cover the cases when resources
+        are loaded from memory cache.
+
+        Network notifications are now sent to InspectorInstrumentation which dispatches
+        them to interested agents and InspectorController.
+
+        * src/SharedWorkerRepository.cpp:
+        (WebCore::SharedWorkerScriptLoader::notifyFinished):
+        * src/WebDevToolsAgentImpl.cpp:
+        (WebKit::WebDevToolsAgentImpl::mainFrame):
+        (WebKit::WebDevToolsAgentImpl::identifierForInitialRequest):
+        (WebKit::WebDevToolsAgentImpl::willSendRequest):
+        (WebKit::WebDevToolsAgentImpl::didReceiveData):
+        (WebKit::WebDevToolsAgentImpl::didReceiveResponse):
+        (WebKit::WebDevToolsAgentImpl::didFinishLoading):
+        (WebKit::WebDevToolsAgentImpl::didFailLoading):
+        * src/WebDevToolsAgentImpl.h:
+
 2011-01-11  Tony Chang  <tony at chromium.org>
 
         Reviewed by Eric Seidel.
diff --git a/WebKit/chromium/src/ApplicationCacheHost.cpp b/WebKit/chromium/src/ApplicationCacheHost.cpp
index 85dfd20..2696b2c 100644
--- a/WebKit/chromium/src/ApplicationCacheHost.cpp
+++ b/WebKit/chromium/src/ApplicationCacheHost.cpp
@@ -38,7 +38,7 @@
 #include "DOMApplicationCache.h"
 #include "Frame.h"
 #include "InspectorApplicationCacheAgent.h"
-#include "InspectorController.h"
+#include "InspectorInstrumentation.h"
 #include "Page.h"
 #include "ProgressEvent.h"
 #include "Settings.h"
@@ -208,12 +208,8 @@ void ApplicationCacheHost::setDOMApplicationCache(DOMApplicationCache* domApplic
 void ApplicationCacheHost::notifyDOMApplicationCache(EventID id, int total, int done)
 {
 #if ENABLE(INSPECTOR)
-    // If host's frame is main frame and inspector frontend is connected, update appcache status.
-    if (id != PROGRESS_EVENT && m_documentLoader->frame()) {
-        Page* page = m_documentLoader->frame()->page();
-        if (page && page->inspectorController()->applicationCacheAgent() && page->mainFrame() == m_documentLoader->frame())
-            page->inspectorController()->applicationCacheAgent()->updateApplicationCacheStatus(status());
-    }
+    if (id != PROGRESS_EVENT)
+        InspectorInstrumentation::updateApplicationCacheStatus(m_documentLoader->frame());
 #endif
 
     if (m_defersEvents) {
diff --git a/WebKit/chromium/src/SharedWorkerRepository.cpp b/WebKit/chromium/src/SharedWorkerRepository.cpp
index 88d3ec5..3d4428a 100644
--- a/WebKit/chromium/src/SharedWorkerRepository.cpp
+++ b/WebKit/chromium/src/SharedWorkerRepository.cpp
@@ -36,7 +36,7 @@
 
 #include "Event.h"
 #include "EventNames.h"
-#include "InspectorController.h"
+#include "InspectorInstrumentation.h"
 #include "MessagePortChannel.h"
 #include "PlatformMessagePortChannel.h"
 #include "ScriptExecutionContext.h"
@@ -162,10 +162,7 @@ void SharedWorkerScriptLoader::notifyFinished()
         m_worker->dispatchEvent(Event::create(eventNames().errorEvent, false, true));
         delete this;
     } else {
-#if ENABLE(INSPECTOR)
-        if (InspectorController* inspector = m_worker->scriptExecutionContext()->inspectorController())
-            inspector->scriptImported(m_scriptLoader.identifier(), m_scriptLoader.script());
-#endif
+        InspectorInstrumentation::scriptImported(m_worker->scriptExecutionContext(), m_scriptLoader.identifier(), m_scriptLoader.script());
         // Pass the script off to the worker, then send a connect event.
         m_webWorker->startWorkerContext(m_url, m_name, m_worker->scriptExecutionContext()->userAgent(m_url), m_scriptLoader.script(), m_responseAppCacheID);
         sendConnect();
diff --git a/WebKit/chromium/src/WebDevToolsAgentImpl.cpp b/WebKit/chromium/src/WebDevToolsAgentImpl.cpp
index dbd6dca..11ce797 100644
--- a/WebKit/chromium/src/WebDevToolsAgentImpl.cpp
+++ b/WebKit/chromium/src/WebDevToolsAgentImpl.cpp
@@ -37,6 +37,7 @@
 #include "InjectedScriptHost.h"
 #include "InspectorBackendDispatcher.h"
 #include "InspectorController.h"
+#include "InspectorInstrumentation.h"
 #include "Page.h"
 #include "PageGroup.h"
 #include "PlatformString.h"
@@ -69,6 +70,8 @@ using WebCore::InjectedScriptHost;
 using WebCore::InspectorArray;
 using WebCore::InspectorBackendDispatcher;
 using WebCore::InspectorController;
+using WebCore::InspectorInstrumentation;
+using WebCore::InspectorInstrumentationCookie;
 using WebCore::Node;
 using WebCore::Page;
 using WebCore::ResourceError;
@@ -266,25 +269,30 @@ WebCore::InspectorController* WebDevToolsAgentImpl::inspectorController()
     return 0;
 }
 
+WebCore::Frame* WebDevToolsAgentImpl::mainFrame()
+{
+    if (Page* page = m_webViewImpl->page())
+        return page->mainFrame();
+    return 0;
+}
+
 
 //------- plugin resource load notifications ---------------
 void WebDevToolsAgentImpl::identifierForInitialRequest(
     unsigned long resourceId,
-    WebFrame* frame,
+    WebFrame* webFrame,
     const WebURLRequest& request)
 {
-    if (InspectorController* ic = inspectorController()) {
-        WebFrameImpl* webFrameImpl = static_cast<WebFrameImpl*>(frame);
-        FrameLoader* frameLoader = webFrameImpl->frame()->loader();
-        DocumentLoader* loader = frameLoader->activeDocumentLoader();
-        ic->identifierForInitialRequest(resourceId, loader, request.toResourceRequest());
-    }
+    WebFrameImpl* webFrameImpl = static_cast<WebFrameImpl*>(webFrame);
+    WebCore::Frame* frame = webFrameImpl->frame();
+    DocumentLoader* loader = frame->loader()->activeDocumentLoader();
+    InspectorInstrumentation::identifierForInitialRequest(frame, resourceId, loader, request.toResourceRequest());
 }
 
 void WebDevToolsAgentImpl::willSendRequest(unsigned long resourceId, WebURLRequest& request)
 {
     if (InspectorController* ic = inspectorController()) {
-        ic->willSendRequest(resourceId, request.toMutableResourceRequest(), ResourceResponse());
+        InspectorInstrumentation::willSendRequest(mainFrame(), resourceId, request.toMutableResourceRequest(), ResourceResponse());
         if (ic->hasFrontend() && request.reportLoadTiming())
             request.setReportRawHeaders(true);
     }
@@ -292,27 +300,23 @@ void WebDevToolsAgentImpl::willSendRequest(unsigned long resourceId, WebURLReque
 
 void WebDevToolsAgentImpl::didReceiveData(unsigned long resourceId, int length)
 {
-    if (InspectorController* ic = inspectorController())
-        ic->didReceiveContentLength(resourceId, length);
+    InspectorInstrumentation::didReceiveContentLength(mainFrame(), resourceId, length);
 }
 
 void WebDevToolsAgentImpl::didReceiveResponse(unsigned long resourceId, const WebURLResponse& response)
 {
-    if (InspectorController* ic = inspectorController())
-        ic->didReceiveResponse(resourceId, 0, response.toResourceResponse());
+    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiveResourceResponse(mainFrame(), resourceId, response.toResourceResponse());
+    InspectorInstrumentation::didReceiveResourceResponse(cookie, resourceId, 0, response.toResourceResponse());
 }
 
 void WebDevToolsAgentImpl::didFinishLoading(unsigned long resourceId)
 {
-    if (InspectorController* ic = inspectorController())
-        ic->didFinishLoading(resourceId, 0);
+    InspectorInstrumentation::didFinishLoading(mainFrame(), resourceId, 0);
 }
 
 void WebDevToolsAgentImpl::didFailLoading(unsigned long resourceId, const WebURLError& error)
 {
-    ResourceError resourceError;
-    if (InspectorController* ic = inspectorController())
-        ic->didFailLoading(resourceId, resourceError);
+    InspectorInstrumentation::didFailLoading(mainFrame(), resourceId, error);
 }
 
 void WebDevToolsAgentImpl::inspectorDestroyed()
diff --git a/WebKit/chromium/src/WebDevToolsAgentImpl.h b/WebKit/chromium/src/WebDevToolsAgentImpl.h
index 9b3c053..8d97aa4 100644
--- a/WebKit/chromium/src/WebDevToolsAgentImpl.h
+++ b/WebKit/chromium/src/WebDevToolsAgentImpl.h
@@ -101,6 +101,7 @@ public:
 
 private:
     WebCore::InspectorController* inspectorController();
+    WebCore::Frame* mainFrame();
 
     int m_hostId;
     WebDevToolsAgentClient* m_client;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list