[chromium] Lower priority of preloaded images
authorsimonjam@chromium.org <simonjam@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Feb 2013 23:47:52 +0000 (23:47 +0000)
committersimonjam@chromium.org <simonjam@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Feb 2013 23:47:52 +0000 (23:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=110527

Source/WebCore:

Reviewed by Nate Chapin.

This improves Speed Index by ~5%, because it encourages us to load images that are needed for
painting over speculative preloads. Ideally, all embedders would use this, but it relies on
ResourceHandle::didChangePriority being implemented. Currently, only Chrome does that.

Test: http/tests/loading/promote-img-preload-priority.html

* loader/FrameLoaderClient.h:
(FrameLoaderClient):
(WebCore::FrameLoaderClient::dispatchDidChangeResourcePriority): Added callback to enable testing.
* loader/cache/CachedResource.cpp:
(WebCore::CachedResource::setLoadPriority): Signal callback.
* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::preload): Actual behavior change.

Source/WebKit/chromium:

Plumb the didChangePriority signal into DRT so it can be tested.

Reviewed by Nate Chapin.

* public/WebFrameClient.h:
(WebKit):
(WebKit::WebFrameClient::didChangeResourcePriority):
(WebFrameClient):
* src/FrameLoaderClientImpl.cpp:
(WebKit::FrameLoaderClientImpl::dispatchDidChangeResourcePriority):
(WebKit):
* src/FrameLoaderClientImpl.h:
(FrameLoaderClientImpl):

Tools:

Plumb the didChangePriority signal into DRT so it can be tested.

Reviewed by Nate Chapin.

* DumpRenderTree/chromium/TestRunner/public/WebTestProxy.h:
(WebKit):
(WebTestRunner::WebTestProxy::didChangeResourcePriority):
* DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp:
(WebTestRunner::TestRunner::TestRunner):
(WebTestRunner::TestRunner::reset):
(WebTestRunner::TestRunner::shouldDumpResourcePriorities):
(WebTestRunner):
(WebTestRunner::TestRunner::dumpResourceRequestPriorities):
* DumpRenderTree/chromium/TestRunner/src/TestRunner.h:
(TestRunner):
* DumpRenderTree/chromium/TestRunner/src/WebTestProxy.cpp:
(WebTestRunner::WebTestProxyBase::assignIdentifierToRequest):
(WebTestRunner::WebTestProxyBase::willSendRequest):
(WebTestRunner::WebTestProxyBase::didChangeResourcePriority):
(WebTestRunner):

LayoutTests:

Reviewed by Nate Chapin.

* http/tests/loading/promote-img-preload-priority-expected.txt: Added.
* http/tests/loading/promote-img-preload-priority.html: Added.

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

24 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/loading/promote-img-preload-priority-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/loading/promote-img-preload-priority.html [new file with mode: 0644]
LayoutTests/platform/efl/TestExpectations
LayoutTests/platform/gtk/TestExpectations
LayoutTests/platform/mac/TestExpectations
LayoutTests/platform/qt/TestExpectations
LayoutTests/platform/win/TestExpectations
LayoutTests/platform/wincairo/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/loader/FrameLoaderClient.h
Source/WebCore/loader/ResourceLoader.cpp
Source/WebCore/loader/ResourceLoader.h
Source/WebCore/loader/cache/CachedResource.cpp
Source/WebCore/loader/cache/CachedResourceLoader.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/public/WebFrameClient.h
Source/WebKit/chromium/src/FrameLoaderClientImpl.cpp
Source/WebKit/chromium/src/FrameLoaderClientImpl.h
Tools/ChangeLog
Tools/DumpRenderTree/chromium/TestRunner/public/WebTestProxy.h
Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp
Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.h
Tools/DumpRenderTree/chromium/TestRunner/src/WebTestProxy.cpp

index df40cc0..1088691 100644 (file)
@@ -1,3 +1,13 @@
+2013-02-27  James Simonsen  <simonjam@chromium.org>
+
+        [chromium] Lower priority of preloaded images
+        https://bugs.webkit.org/show_bug.cgi?id=110527
+
+        Reviewed by Nate Chapin.
+
+        * http/tests/loading/promote-img-preload-priority-expected.txt: Added.
+        * http/tests/loading/promote-img-preload-priority.html: Added.
+
 2013-02-27  Philip Rogers  <pdr@google.com>
 
         Rebaseline 2 SVG tests after WK108429
diff --git a/LayoutTests/http/tests/loading/promote-img-preload-priority-expected.txt b/LayoutTests/http/tests/loading/promote-img-preload-priority-expected.txt
new file mode 100644 (file)
index 0000000..89d9663
--- /dev/null
@@ -0,0 +1,13 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didCommitLoadForFrame
+http://127.0.0.1:8000/resources/js-test-pre.js has priority Medium
+http://127.0.0.1:8000/misc/resources/image-slow.pl has priority VeryLow
+http://127.0.0.1:8000/resources/js-test-post.js has priority Medium
+http://127.0.0.1:8000/misc/resources/image-slow.pl changed priority to Low
+main frame - didFinishDocumentLoadForFrame
+main frame - didHandleOnloadEventsForFrame
+main frame - didFinishLoadForFrame
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/http/tests/loading/promote-img-preload-priority.html b/LayoutTests/http/tests/loading/promote-img-preload-priority.html
new file mode 100644 (file)
index 0000000..6f5f056
--- /dev/null
@@ -0,0 +1,15 @@
+<html>
+    <head>
+        <script>
+            if (window.testRunner) {
+                testRunner.dumpResourceRequestPriorities();
+                testRunner.dumpAsText();
+            }
+        </script>
+        <script src="/resources/js-test-pre.js"></script>
+    </head>
+    <body>
+        <img src="../misc/resources/image-slow.pl">
+        <script src="/resources/js-test-post.js"></script>
+    </body>
+</html>
index dcc57c1..0ba54ba 100644 (file)
@@ -1874,3 +1874,6 @@ webkit.org/b/110654 svg/custom/foreign-object-skew.svg [ Failure ]
 webkit.org/b/110654 tables/mozilla/bugs/bug92647-2.html [ Failure ]
 # New test
 webkit.org/b/110654 css3/flexbox/button.html [ Failure ]
+
+# Need support for ResourceHandle::didChangePriority and DRT support
+webkit.org/b/111016 http/tests/loading/promote-img-preload-priority.html [ Failure ]
index 9ed0895..c00dab2 100644 (file)
@@ -1403,6 +1403,9 @@ webkit.org/b/110694 html5lib/generated/run-domjs-unsafe-data.html [ Failure ]
 webkit.org/b/110694 html5lib/generated/run-pending-spec-changes-plain-text-unsafe-data.html [ Failure ]
 webkit.org/b/110694 html5lib/generated/run-plain-text-unsafe-data.html [ Failure ]
 
+# Need support for ResourceHandle::didChangePriority and DRT support
+webkit.org/b/?????? http/tests/loading/promote-img-preload-priority.html [ Failure ]
+
 #////////////////////////////////////////////////////////////////////////////////////////
 # End of Tests failing
 #////////////////////////////////////////////////////////////////////////////////////////
index 8d9c49f..1befafd 100644 (file)
@@ -1449,3 +1449,6 @@ webkit.org/b/110654 svg/custom/foreign-object-skew.svg [ Failure ]
 webkit.org/b/110654 tables/mozilla/bugs/bug92647-2.html [ Failure ]
 # New test
 webkit.org/b/110654 css3/flexbox/button.html [ Failure ]
+
+# Need support for ResourceHandle::didChangePriority and DRT support
+webkit.org/b/111016 http/tests/loading/promote-img-preload-priority.html [ Failure ]
index 80e9bdd..f84e41d 100644 (file)
@@ -2673,3 +2673,6 @@ webkit.org/b/110654 svg/custom/foreign-object-skew.svg [ Failure ]
 webkit.org/b/110654 tables/mozilla/bugs/bug92647-2.html [ Failure ]
 # New test
 webkit.org/b/110654 css3/flexbox/button.html [ Failure ]
+
+# Need support for ResourceHandle::didChangePriority and DRT support
+webkit.org/b/111016 http/tests/loading/promote-img-preload-priority.html [ Failure ]
index 2194140..7f9c8fd 100644 (file)
@@ -2654,3 +2654,6 @@ webkit.org/b/110654 svg/custom/foreign-object-skew.svg [ Failure ]
 webkit.org/b/110654 tables/mozilla/bugs/bug92647-2.html [ Failure ]
 # New test
 webkit.org/b/110654 css3/flexbox/button.html [ Failure ]
+
+# Need support for ResourceHandle::didChangePriority and DRT support
+webkit.org/b/111016 http/tests/loading/promote-img-preload-priority.html [ Failure ]
index 3cb5bd4..fe7d616 100644 (file)
@@ -2998,3 +2998,6 @@ webkit.org/b/108370 editing/spelling/spelling-subword-selection.html [ Skip ]
 webkit.org/b/108370 editing/spelling/spelling-with-punctuation-selection.html [ Skip ]
 webkit.org/b/108370 editing/spelling/spelling-with-underscore-selection.html [ Skip ]
 webkit.org/b/108370 editing/spelling/spelling-with-whitespace-selection.html [ Skip ]
+
+# Need support for ResourceHandle::didChangePriority and DRT support
+webkit.org/b/?????? http/tests/loading/promote-img-preload-priority.html [ Failure ]
index d147c46..0c847d5 100644 (file)
@@ -1,3 +1,24 @@
+2013-02-27  James Simonsen  <simonjam@chromium.org>
+
+        [chromium] Lower priority of preloaded images
+        https://bugs.webkit.org/show_bug.cgi?id=110527
+
+        Reviewed by Nate Chapin.
+
+        This improves Speed Index by ~5%, because it encourages us to load images that are needed for
+        painting over speculative preloads. Ideally, all embedders would use this, but it relies on
+        ResourceHandle::didChangePriority being implemented. Currently, only Chrome does that.
+
+        Test: http/tests/loading/promote-img-preload-priority.html
+
+        * loader/FrameLoaderClient.h:
+        (FrameLoaderClient):
+        (WebCore::FrameLoaderClient::dispatchDidChangeResourcePriority): Added callback to enable testing.
+        * loader/cache/CachedResource.cpp:
+        (WebCore::CachedResource::setLoadPriority): Signal callback.
+        * loader/cache/CachedResourceLoader.cpp:
+        (WebCore::CachedResourceLoader::preload): Actual behavior change.
+
 2013-02-27  Csaba Osztrogon√°c  <ossy@webkit.org>
 
         Unreviewed trivial buildfix after r144190.
index cac0d2a..91f6457 100644 (file)
@@ -33,6 +33,7 @@
 #include "FrameLoaderTypes.h"
 #include "IconURL.h"
 #include "LayoutMilestones.h"
+#include "ResourceLoadPriority.h"
 #include <wtf/Forward.h>
 #include <wtf/Vector.h>
 
@@ -364,6 +365,8 @@ namespace WebCore {
 
         // If an HTML document is being loaded, informs the embedder that the document will have its <body> attached soon.
         virtual void dispatchWillInsertBody() { }
+
+        virtual void dispatchDidChangeResourcePriority(unsigned long /*identifier*/, ResourceLoadPriority) { }
     };
 
 } // namespace WebCore
index 7812ba0..be7e3ce 100644 (file)
@@ -364,6 +364,14 @@ void ResourceLoader::didFail(const ResourceError& error)
     releaseResources();
 }
 
+void ResourceLoader::didChangePriority(ResourceLoadPriority loadPriority)
+{
+    if (handle()) {
+        frameLoader()->client()->dispatchDidChangeResourcePriority(identifier(), loadPriority);
+        handle()->didChangePriority(loadPriority);
+    }
+}
+
 void ResourceLoader::cancel()
 {
     cancel(ResourceError());
index bc9d9e5..18dba7f 100644 (file)
@@ -88,6 +88,7 @@ public:
 #if USE(NETWORK_CFDATA_ARRAY_CALLBACK)
     virtual void didReceiveDataArray(CFArrayRef dataArray);
 #endif
+    void didChangePriority(ResourceLoadPriority);
 
     virtual bool shouldUseCredentialStorage();
     virtual void didReceiveAuthenticationChallenge(const AuthenticationChallenge&);
index e9974a1..f05ee4c 100644 (file)
@@ -916,8 +916,8 @@ void CachedResource::setLoadPriority(ResourceLoadPriority loadPriority)
     if (loadPriority == m_loadPriority)
         return;
     m_loadPriority = loadPriority;
-    if (m_loader && m_loader->handle())
-        m_loader->handle()->didChangePriority(loadPriority);
+    if (m_loader)
+        m_loader->didChangePriority(loadPriority);
 }
 
 
index c51fb7b..dc72e48 100644 (file)
@@ -833,6 +833,11 @@ void CachedResourceLoader::preload(CachedResource::Type type, CachedResourceRequ
 #if PLATFORM(IOS) || PLATFORM(CHROMIUM)
     delaySubresourceLoad = false;
 #endif
+#if PLATFORM(CHROMIUM)
+    // FIXME: All ports should take advantage of this, but first must support ResourceHandle::didChangePriority().
+    if (type == CachedResource::ImageResource)
+        request.setPriority(ResourceLoadPriorityVeryLow);
+#endif
     if (delaySubresourceLoad) {
         bool hasRendering = m_document->body() && m_document->body()->renderer();
         bool canBlockParser = type == CachedResource::Script || type == CachedResource::CSSStyleSheet;
index c9e39ee..d068750 100644 (file)
@@ -1,3 +1,22 @@
+2013-02-27  James Simonsen  <simonjam@chromium.org>
+
+        [chromium] Lower priority of preloaded images
+        https://bugs.webkit.org/show_bug.cgi?id=110527
+
+        Plumb the didChangePriority signal into DRT so it can be tested.
+
+        Reviewed by Nate Chapin.
+
+        * public/WebFrameClient.h:
+        (WebKit):
+        (WebKit::WebFrameClient::didChangeResourcePriority):
+        (WebFrameClient):
+        * src/FrameLoaderClientImpl.cpp:
+        (WebKit::FrameLoaderClientImpl::dispatchDidChangeResourcePriority):
+        (WebKit):
+        * src/FrameLoaderClientImpl.h:
+        (FrameLoaderClientImpl):
+
 2013-02-27  Min Qin  <qinmin@chromium.org>
 
         Unlock partially decoded images after passing them to the ImageDecodingStore
index 30b808b..2df153f 100644 (file)
@@ -34,6 +34,7 @@
 #include "../../../Platform/chromium/public/WebCommon.h"
 #include "../../../Platform/chromium/public/WebFileSystem.h"
 #include "../../../Platform/chromium/public/WebURLError.h"
+#include "../../../Platform/chromium/public/WebURLRequest.h"
 #include "WebDOMMessageEvent.h"
 #include "WebIconURL.h"
 #include "WebNavigationPolicy.h"
@@ -68,7 +69,6 @@ class WebStorageQuotaCallbacks;
 class WebString;
 class WebURL;
 class WebURLLoader;
-class WebURLRequest;
 class WebURLResponse;
 class WebWorker;
 struct WebPluginParams;
@@ -272,6 +272,9 @@ public:
     virtual void didReceiveResponse(
         WebFrame*, unsigned identifier, const WebURLResponse&) { }
 
+    virtual void didChangeResourcePriority(
+        WebFrame*, unsigned identifier, const WebKit::WebURLRequest::Priority&) { }
+
     // The resource request given by identifier succeeded.
     virtual void didFinishResourceLoad(
         WebFrame*, unsigned identifier) { }
index 499dda0..6b23cde 100644 (file)
@@ -438,6 +438,13 @@ void FrameLoaderClientImpl::dispatchDidReceiveContentLength(
 {
 }
 
+void FrameLoaderClientImpl::dispatchDidChangeResourcePriority(unsigned long identifier,
+                                                              ResourceLoadPriority priority)
+{
+    if (m_webFrame->client())
+        m_webFrame->client()->didChangeResourcePriority(m_webFrame, identifier, static_cast<WebKit::WebURLRequest::Priority>(priority));
+}
+
 // Called when a particular resource load completes
 void FrameLoaderClientImpl::dispatchDidFinishLoading(DocumentLoader* loader,
                                                     unsigned long identifier)
index e9a5e80..bccec0f 100644 (file)
@@ -88,6 +88,7 @@ public:
     virtual void dispatchDidCancelAuthenticationChallenge(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::AuthenticationChallenge&);
     virtual void dispatchDidReceiveResponse(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceResponse&);
     virtual void dispatchDidReceiveContentLength(WebCore::DocumentLoader*, unsigned long identifier, int dataLength);
+    virtual void dispatchDidChangeResourcePriority(unsigned long identifier, WebCore::ResourceLoadPriority);
     virtual void dispatchDidFinishLoading(WebCore::DocumentLoader*, unsigned long identifier);
     virtual void dispatchDidFailLoading(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceError&);
     virtual bool dispatchDidLoadResourceFromMemoryCache(WebCore::DocumentLoader*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&, int length);
index 391dab3..d235670 100644 (file)
@@ -1,3 +1,29 @@
+2013-02-27  James Simonsen  <simonjam@chromium.org>
+
+        [chromium] Lower priority of preloaded images
+        https://bugs.webkit.org/show_bug.cgi?id=110527
+
+        Plumb the didChangePriority signal into DRT so it can be tested.
+
+        Reviewed by Nate Chapin.
+
+        * DumpRenderTree/chromium/TestRunner/public/WebTestProxy.h:
+        (WebKit):
+        (WebTestRunner::WebTestProxy::didChangeResourcePriority):
+        * DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp:
+        (WebTestRunner::TestRunner::TestRunner):
+        (WebTestRunner::TestRunner::reset):
+        (WebTestRunner::TestRunner::shouldDumpResourcePriorities):
+        (WebTestRunner):
+        (WebTestRunner::TestRunner::dumpResourceRequestPriorities):
+        * DumpRenderTree/chromium/TestRunner/src/TestRunner.h:
+        (TestRunner):
+        * DumpRenderTree/chromium/TestRunner/src/WebTestProxy.cpp:
+        (WebTestRunner::WebTestProxyBase::assignIdentifierToRequest):
+        (WebTestRunner::WebTestProxyBase::willSendRequest):
+        (WebTestRunner::WebTestProxyBase::didChangeResourcePriority):
+        (WebTestRunner):
+
 2013-02-27  Chris Fleizach  <cfleizach@apple.com>
 
         AX: Mac platform should support ability to scroll an element into visible
index cb40672..5aeae06 100644 (file)
@@ -33,6 +33,7 @@
 
 #include "Platform/chromium/public/WebRect.h"
 #include "Platform/chromium/public/WebURLError.h"
+#include "Platform/chromium/public/WebURLRequest.h"
 #include "WebKit/chromium/public/WebAccessibilityNotification.h"
 #include "WebKit/chromium/public/WebDOMMessageEvent.h"
 #include "WebKit/chromium/public/WebDragOperation.h"
@@ -69,7 +70,6 @@ class WebSpeechRecognizer;
 class WebSpellCheckClient;
 class WebString;
 class WebURL;
-class WebURLRequest;
 class WebURLResponse;
 class WebUserMediaClient;
 class WebView;
@@ -183,6 +183,7 @@ protected:
     void didCreateDataSource(WebKit::WebFrame*, WebKit::WebDataSource*);
     void willSendRequest(WebKit::WebFrame*, unsigned identifier, WebKit::WebURLRequest&, const WebKit::WebURLResponse& redirectResponse);
     void didReceiveResponse(WebKit::WebFrame*, unsigned identifier, const WebKit::WebURLResponse&);
+    void didChangeResourcePriority(WebKit::WebFrame*, unsigned identifier, const WebKit::WebURLRequest::Priority&);
     void didFinishResourceLoad(WebKit::WebFrame*, unsigned identifier);
     void didFailResourceLoad(WebKit::WebFrame*, unsigned identifier, const WebKit::WebURLError&);
     void unableToImplementPolicyWithError(WebKit::WebFrame*, const WebKit::WebURLError&);
@@ -213,6 +214,7 @@ private:
     WebKit::WebRect m_paintRect;
     bool m_isPainting;
     std::map<unsigned, std::string> m_resourceIdentifierMap;
+    std::map<unsigned, WebKit::WebURLRequest> m_requestMap;
 
     bool m_logConsoleOutput;
 
@@ -527,6 +529,11 @@ public:
         WebTestProxyBase::didReceiveResponse(frame, identifier, response);
         Base::didReceiveResponse(frame, identifier, response);
     }
+    virtual void didChangeResourcePriority(WebKit::WebFrame* frame, unsigned identifier, const WebKit::WebURLRequest::Priority& priority)
+    {
+        WebTestProxyBase::didChangeResourcePriority(frame, identifier, priority);
+        Base::didChangeResourcePriority(frame, identifier, priority);
+    }
     virtual void didFinishResourceLoad(WebKit::WebFrame* frame, unsigned identifier)
     {
         WebTestProxyBase::didFinishResourceLoad(frame, identifier);
index 172a7ae..7390a17 100644 (file)
@@ -266,6 +266,7 @@ TestRunner::TestRunner(TestInterfaces* interfaces)
     bindMethod("setWillSendRequestClearHeader", &TestRunner::setWillSendRequestClearHeader);
     bindMethod("setWillSendRequestReturnsNull", &TestRunner::setWillSendRequestReturnsNull);
     bindMethod("setWillSendRequestReturnsNullOnRedirect", &TestRunner::setWillSendRequestReturnsNullOnRedirect);
+    bindMethod("dumpResourceRequestPriorities", &TestRunner::dumpResourceRequestPriorities);
 
     // The following methods interact with the WebTestProxy.
     // The following methods interact with the WebTestDelegate.
@@ -416,6 +417,7 @@ void TestRunner::reset()
 #else
     m_selectTrailingWhitespaceEnabled = false;
 #endif
+    m_shouldDumpResourcePriorities = false;
 
     m_httpHeadersToClear.clear();
 
@@ -683,6 +685,11 @@ bool TestRunner::isSelectTrailingWhitespaceEnabled() const
     return m_selectTrailingWhitespaceEnabled;
 }
 
+bool TestRunner::shouldDumpResourcePriorities() const
+{
+    return m_shouldDumpResourcePriorities;
+}
+
 #if ENABLE_NOTIFICATIONS
 WebNotificationPresenter* TestRunner::notificationPresenter() const
 {
@@ -1507,6 +1514,12 @@ void TestRunner::setSelectTrailingWhitespaceEnabled(const CppArgumentList& argum
     result->setNull();
 }
 
+void TestRunner::dumpResourceRequestPriorities(const CppArgumentList& arguments, CppVariant* result)
+{
+    m_shouldDumpResourcePriorities = true;
+    result->setNull();
+}
+
 void TestRunner::enableAutoResizeMode(const CppArgumentList& arguments, CppVariant* result)
 {
     if (arguments.size() != 4) {
index 74cc81e..fad08e7 100644 (file)
@@ -120,6 +120,7 @@ public:
     bool shouldInterceptPostMessage() const;
     bool isSmartInsertDeleteEnabled() const;
     bool isSelectTrailingWhitespaceEnabled() const;
+    bool shouldDumpResourcePriorities() const;
 #if ENABLE_NOTIFICATIONS
     WebKit::WebNotificationPresenter* notificationPresenter() const;
 #endif
@@ -420,6 +421,11 @@ private:
     // Causes WillSendRequest to return an empty request.
     void setWillSendRequestReturnsNull(const CppArgumentList&, CppVariant*);
 
+    // This function sets a flag that tells the test_shell to dump a descriptive
+    // line for each resource load's priority and any time that priority
+    // changes. It takes no arguments, and ignores any that may be present.
+    void dumpResourceRequestPriorities(const CppArgumentList&, CppVariant*);
+
     ///////////////////////////////////////////////////////////////////////////
     // Methods interacting with the WebTestProxy
 
@@ -669,6 +675,8 @@ private:
 
     bool m_selectTrailingWhitespaceEnabled;
 
+    bool m_shouldDumpResourcePriorities;
+
     std::set<std::string> m_httpHeadersToClear;
 
     // WAV audio data is stored here.
index a938a77..6819882 100644 (file)
@@ -197,6 +197,25 @@ string URLDescription(const GURL& url)
     return url.possibly_invalid_spec();
 }
 
+string PriorityDescription(const WebURLRequest::Priority& priority)
+{
+    switch (priority) {
+    case WebURLRequest::PriorityVeryLow:
+        return "VeryLow";
+    case WebURLRequest::PriorityLow:
+        return "Low";
+    case WebURLRequest::PriorityMedium:
+        return "Medium";
+    case WebURLRequest::PriorityHigh:
+        return "High";
+    case WebURLRequest::PriorityVeryHigh:
+        return "VeryHigh";
+    case WebURLRequest::PriorityUnresolved:
+    default:
+        return "Unresolved";
+    }
+}
+
 void blockRequest(WebURLRequest& request)
 {
     request.setURL(WebURL());
@@ -1196,7 +1215,7 @@ void WebTestProxyBase::didDetectXSS(WebFrame*, const WebURL&, bool)
 
 void WebTestProxyBase::assignIdentifierToRequest(WebFrame*, unsigned identifier, const WebKit::WebURLRequest& request)
 {
-    if (m_testInterfaces->testRunner()->shouldDumpResourceLoadCallbacks()) {
+    if (m_testInterfaces->testRunner()->shouldDumpResourceLoadCallbacks() || m_testInterfaces->testRunner()->shouldDumpResourcePriorities()) {
         WEBKIT_ASSERT(m_resourceIdentifierMap.find(identifier) == m_resourceIdentifierMap.end());
         m_resourceIdentifierMap[identifier] = descriptionSuitableForTestResult(request.url().spec());
     }
@@ -1268,6 +1287,13 @@ void WebTestProxyBase::willSendRequest(WebFrame*, unsigned identifier, WebKit::W
         m_delegate->printMessage("\n");
     }
 
+    if (m_testInterfaces->testRunner()->shouldDumpResourcePriorities()) {
+        m_delegate->printMessage(descriptionSuitableForTestResult(requestURL).c_str());
+        m_delegate->printMessage(" has priority ");
+        m_delegate->printMessage(PriorityDescription(request.priority()));
+        m_delegate->printMessage("\n");
+    }
+
     if (!redirectResponse.isNull() && m_testInterfaces->testRunner()->shouldBlockRedirects()) {
         m_delegate->printMessage("Returning null for this redirect\n");
         blockRequest(request);
@@ -1322,6 +1348,19 @@ void WebTestProxyBase::didReceiveResponse(WebFrame*, unsigned identifier, const
     }
 }
 
+void WebTestProxyBase::didChangeResourcePriority(WebFrame*, unsigned identifier, const WebKit::WebURLRequest::Priority& priority)
+{
+    if (m_testInterfaces->testRunner()->shouldDumpResourcePriorities()) {
+        if (m_resourceIdentifierMap.find(identifier) == m_resourceIdentifierMap.end())
+            m_delegate->printMessage("<unknown>");
+        else
+            m_delegate->printMessage(m_resourceIdentifierMap[identifier]);
+        m_delegate->printMessage(" changed priority to ");
+        m_delegate->printMessage(PriorityDescription(priority));
+        m_delegate->printMessage("\n");
+    }
+}
+
 void WebTestProxyBase::didFinishResourceLoad(WebFrame*, unsigned identifier)
 {
     if (m_testInterfaces->testRunner()->shouldDumpResourceLoadCallbacks()) {