Title: [144248] trunk
Revision
144248
Author
[email protected]
Date
2013-02-27 15:47:52 -0800 (Wed, 27 Feb 2013)

Log Message

[chromium] Lower priority of preloaded images
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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (144247 => 144248)


--- trunk/LayoutTests/ChangeLog	2013-02-27 23:25:14 UTC (rev 144247)
+++ trunk/LayoutTests/ChangeLog	2013-02-27 23:47:52 UTC (rev 144248)
@@ -1,3 +1,13 @@
+2013-02-27  James Simonsen  <[email protected]>
+
+        [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  <[email protected]>
 
         Rebaseline 2 SVG tests after WK108429

Added: trunk/LayoutTests/http/tests/loading/promote-img-preload-priority-expected.txt (0 => 144248)


--- trunk/LayoutTests/http/tests/loading/promote-img-preload-priority-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/loading/promote-img-preload-priority-expected.txt	2013-02-27 23:47:52 UTC (rev 144248)
@@ -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
+

Added: trunk/LayoutTests/http/tests/loading/promote-img-preload-priority.html (0 => 144248)


--- trunk/LayoutTests/http/tests/loading/promote-img-preload-priority.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/loading/promote-img-preload-priority.html	2013-02-27 23:47:52 UTC (rev 144248)
@@ -0,0 +1,15 @@
+<html>
+    <head>
+        <script>
+            if (window.testRunner) {
+                testRunner.dumpResourceRequestPriorities();
+                testRunner.dumpAsText();
+            }
+        </script>
+        <script src=""
+    </head>
+    <body>
+        <img src=""
+        <script src=""
+    </body>
+</html>

Modified: trunk/LayoutTests/platform/efl/TestExpectations (144247 => 144248)


--- trunk/LayoutTests/platform/efl/TestExpectations	2013-02-27 23:25:14 UTC (rev 144247)
+++ trunk/LayoutTests/platform/efl/TestExpectations	2013-02-27 23:47:52 UTC (rev 144248)
@@ -1874,3 +1874,6 @@
 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 ]

Modified: trunk/LayoutTests/platform/gtk/TestExpectations (144247 => 144248)


--- trunk/LayoutTests/platform/gtk/TestExpectations	2013-02-27 23:25:14 UTC (rev 144247)
+++ trunk/LayoutTests/platform/gtk/TestExpectations	2013-02-27 23:47:52 UTC (rev 144248)
@@ -1403,6 +1403,9 @@
 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
 #////////////////////////////////////////////////////////////////////////////////////////

Modified: trunk/LayoutTests/platform/mac/TestExpectations (144247 => 144248)


--- trunk/LayoutTests/platform/mac/TestExpectations	2013-02-27 23:25:14 UTC (rev 144247)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2013-02-27 23:47:52 UTC (rev 144248)
@@ -1449,3 +1449,6 @@
 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 ]

Modified: trunk/LayoutTests/platform/qt/TestExpectations (144247 => 144248)


--- trunk/LayoutTests/platform/qt/TestExpectations	2013-02-27 23:25:14 UTC (rev 144247)
+++ trunk/LayoutTests/platform/qt/TestExpectations	2013-02-27 23:47:52 UTC (rev 144248)
@@ -2673,3 +2673,6 @@
 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 ]

Modified: trunk/LayoutTests/platform/win/TestExpectations (144247 => 144248)


--- trunk/LayoutTests/platform/win/TestExpectations	2013-02-27 23:25:14 UTC (rev 144247)
+++ trunk/LayoutTests/platform/win/TestExpectations	2013-02-27 23:47:52 UTC (rev 144248)
@@ -2654,3 +2654,6 @@
 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 ]

Modified: trunk/LayoutTests/platform/wincairo/TestExpectations (144247 => 144248)


--- trunk/LayoutTests/platform/wincairo/TestExpectations	2013-02-27 23:25:14 UTC (rev 144247)
+++ trunk/LayoutTests/platform/wincairo/TestExpectations	2013-02-27 23:47:52 UTC (rev 144248)
@@ -2998,3 +2998,6 @@
 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 ]

Modified: trunk/Source/WebCore/ChangeLog (144247 => 144248)


--- trunk/Source/WebCore/ChangeLog	2013-02-27 23:25:14 UTC (rev 144247)
+++ trunk/Source/WebCore/ChangeLog	2013-02-27 23:47:52 UTC (rev 144248)
@@ -1,3 +1,24 @@
+2013-02-27  James Simonsen  <[email protected]>
+
+        [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  <[email protected]>
 
         Unreviewed trivial buildfix after r144190.

Modified: trunk/Source/WebCore/loader/FrameLoaderClient.h (144247 => 144248)


--- trunk/Source/WebCore/loader/FrameLoaderClient.h	2013-02-27 23:25:14 UTC (rev 144247)
+++ trunk/Source/WebCore/loader/FrameLoaderClient.h	2013-02-27 23:47:52 UTC (rev 144248)
@@ -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 @@
 
         // 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

Modified: trunk/Source/WebCore/loader/ResourceLoader.cpp (144247 => 144248)


--- trunk/Source/WebCore/loader/ResourceLoader.cpp	2013-02-27 23:25:14 UTC (rev 144247)
+++ trunk/Source/WebCore/loader/ResourceLoader.cpp	2013-02-27 23:47:52 UTC (rev 144248)
@@ -364,6 +364,14 @@
     releaseResources();
 }
 
+void ResourceLoader::didChangePriority(ResourceLoadPriority loadPriority)
+{
+    if (handle()) {
+        frameLoader()->client()->dispatchDidChangeResourcePriority(identifier(), loadPriority);
+        handle()->didChangePriority(loadPriority);
+    }
+}
+
 void ResourceLoader::cancel()
 {
     cancel(ResourceError());

Modified: trunk/Source/WebCore/loader/ResourceLoader.h (144247 => 144248)


--- trunk/Source/WebCore/loader/ResourceLoader.h	2013-02-27 23:25:14 UTC (rev 144247)
+++ trunk/Source/WebCore/loader/ResourceLoader.h	2013-02-27 23:47:52 UTC (rev 144248)
@@ -88,6 +88,7 @@
 #if USE(NETWORK_CFDATA_ARRAY_CALLBACK)
     virtual void didReceiveDataArray(CFArrayRef dataArray);
 #endif
+    void didChangePriority(ResourceLoadPriority);
 
     virtual bool shouldUseCredentialStorage();
     virtual void didReceiveAuthenticationChallenge(const AuthenticationChallenge&);

Modified: trunk/Source/WebCore/loader/cache/CachedResource.cpp (144247 => 144248)


--- trunk/Source/WebCore/loader/cache/CachedResource.cpp	2013-02-27 23:25:14 UTC (rev 144247)
+++ trunk/Source/WebCore/loader/cache/CachedResource.cpp	2013-02-27 23:47:52 UTC (rev 144248)
@@ -916,8 +916,8 @@
     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);
 }
 
 

Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp (144247 => 144248)


--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp	2013-02-27 23:25:14 UTC (rev 144247)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp	2013-02-27 23:47:52 UTC (rev 144248)
@@ -833,6 +833,11 @@
 #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;

Modified: trunk/Source/WebKit/chromium/ChangeLog (144247 => 144248)


--- trunk/Source/WebKit/chromium/ChangeLog	2013-02-27 23:25:14 UTC (rev 144247)
+++ trunk/Source/WebKit/chromium/ChangeLog	2013-02-27 23:47:52 UTC (rev 144248)
@@ -1,3 +1,22 @@
+2013-02-27  James Simonsen  <[email protected]>
+
+        [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  <[email protected]>
 
         Unlock partially decoded images after passing them to the ImageDecodingStore

Modified: trunk/Source/WebKit/chromium/public/WebFrameClient.h (144247 => 144248)


--- trunk/Source/WebKit/chromium/public/WebFrameClient.h	2013-02-27 23:25:14 UTC (rev 144247)
+++ trunk/Source/WebKit/chromium/public/WebFrameClient.h	2013-02-27 23:47:52 UTC (rev 144248)
@@ -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 WebString;
 class WebURL;
 class WebURLLoader;
-class WebURLRequest;
 class WebURLResponse;
 class WebWorker;
 struct WebPluginParams;
@@ -272,6 +272,9 @@
     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) { }

Modified: trunk/Source/WebKit/chromium/src/FrameLoaderClientImpl.cpp (144247 => 144248)


--- trunk/Source/WebKit/chromium/src/FrameLoaderClientImpl.cpp	2013-02-27 23:25:14 UTC (rev 144247)
+++ trunk/Source/WebKit/chromium/src/FrameLoaderClientImpl.cpp	2013-02-27 23:47:52 UTC (rev 144248)
@@ -438,6 +438,13 @@
 {
 }
 
+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)

Modified: trunk/Source/WebKit/chromium/src/FrameLoaderClientImpl.h (144247 => 144248)


--- trunk/Source/WebKit/chromium/src/FrameLoaderClientImpl.h	2013-02-27 23:25:14 UTC (rev 144247)
+++ trunk/Source/WebKit/chromium/src/FrameLoaderClientImpl.h	2013-02-27 23:47:52 UTC (rev 144248)
@@ -88,6 +88,7 @@
     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);

Modified: trunk/Tools/ChangeLog (144247 => 144248)


--- trunk/Tools/ChangeLog	2013-02-27 23:25:14 UTC (rev 144247)
+++ trunk/Tools/ChangeLog	2013-02-27 23:47:52 UTC (rev 144248)
@@ -1,3 +1,29 @@
+2013-02-27  James Simonsen  <[email protected]>
+
+        [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  <[email protected]>
 
         AX: Mac platform should support ability to scroll an element into visible

Modified: trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestProxy.h (144247 => 144248)


--- trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestProxy.h	2013-02-27 23:25:14 UTC (rev 144247)
+++ trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestProxy.h	2013-02-27 23:47:52 UTC (rev 144248)
@@ -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 WebSpellCheckClient;
 class WebString;
 class WebURL;
-class WebURLRequest;
 class WebURLResponse;
 class WebUserMediaClient;
 class WebView;
@@ -183,6 +183,7 @@
     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 @@
     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 @@
         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);

Modified: trunk/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp (144247 => 144248)


--- trunk/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp	2013-02-27 23:25:14 UTC (rev 144247)
+++ trunk/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp	2013-02-27 23:47:52 UTC (rev 144248)
@@ -266,6 +266,7 @@
     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 @@
 #else
     m_selectTrailingWhitespaceEnabled = false;
 #endif
+    m_shouldDumpResourcePriorities = false;
 
     m_httpHeadersToClear.clear();
 
@@ -683,6 +685,11 @@
     return m_selectTrailingWhitespaceEnabled;
 }
 
+bool TestRunner::shouldDumpResourcePriorities() const
+{
+    return m_shouldDumpResourcePriorities;
+}
+
 #if ENABLE_NOTIFICATIONS
 WebNotificationPresenter* TestRunner::notificationPresenter() const
 {
@@ -1507,6 +1514,12 @@
     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) {

Modified: trunk/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.h (144247 => 144248)


--- trunk/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.h	2013-02-27 23:25:14 UTC (rev 144247)
+++ trunk/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.h	2013-02-27 23:47:52 UTC (rev 144248)
@@ -120,6 +120,7 @@
     bool shouldInterceptPostMessage() const;
     bool isSmartInsertDeleteEnabled() const;
     bool isSelectTrailingWhitespaceEnabled() const;
+    bool shouldDumpResourcePriorities() const;
 #if ENABLE_NOTIFICATIONS
     WebKit::WebNotificationPresenter* notificationPresenter() const;
 #endif
@@ -420,6 +421,11 @@
     // 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 @@
 
     bool m_selectTrailingWhitespaceEnabled;
 
+    bool m_shouldDumpResourcePriorities;
+
     std::set<std::string> m_httpHeadersToClear;
 
     // WAV audio data is stored here.

Modified: trunk/Tools/DumpRenderTree/chromium/TestRunner/src/WebTestProxy.cpp (144247 => 144248)


--- trunk/Tools/DumpRenderTree/chromium/TestRunner/src/WebTestProxy.cpp	2013-02-27 23:25:14 UTC (rev 144247)
+++ trunk/Tools/DumpRenderTree/chromium/TestRunner/src/WebTestProxy.cpp	2013-02-27 23:47:52 UTC (rev 144248)
@@ -197,6 +197,25 @@
     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::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 @@
         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::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()) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to