Prevent throttling while resources are being loaded
authoroliver@apple.com <oliver@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Jun 2013 01:21:45 +0000 (01:21 +0000)
committeroliver@apple.com <oliver@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Jun 2013 01:21:45 +0000 (01:21 +0000)
https://bugs.webkit.org/show_bug.cgi?id=117218

Reviewed by Gavin Barraclough.

Make use of the page activity assertion infrastructure to delay
throttling while we are waiting on resource loads.

* loader/FrameLoader.cpp:
(WebCore::FrameLoader::completed):
(WebCore::FrameLoader::started):
* loader/FrameLoader.h:
* loader/SubresourceLoader.cpp:
(WebCore::SubresourceLoader::init):
(WebCore::SubresourceLoader::checkForHTTPStatusCodeError):
(WebCore::SubresourceLoader::didFinishLoading):
(WebCore::SubresourceLoader::didFail):
(WebCore::SubresourceLoader::willCancel):
* loader/SubresourceLoader.h:

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

Source/WebCore/ChangeLog
Source/WebCore/loader/FrameLoader.cpp
Source/WebCore/loader/FrameLoader.h
Source/WebCore/loader/SubresourceLoader.cpp
Source/WebCore/loader/SubresourceLoader.h

index 9d3dbf2..bc54dcd 100644 (file)
@@ -1,3 +1,25 @@
+2013-06-04  Oliver Hunt  <oliver@apple.com>
+
+        Prevent throttling while resources are being loaded
+        https://bugs.webkit.org/show_bug.cgi?id=117218
+
+        Reviewed by Gavin Barraclough.
+
+        Make use of the page activity assertion infrastructure to delay
+        throttling while we are waiting on resource loads.
+
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::completed):
+        (WebCore::FrameLoader::started):
+        * loader/FrameLoader.h:
+        * loader/SubresourceLoader.cpp:
+        (WebCore::SubresourceLoader::init):
+        (WebCore::SubresourceLoader::checkForHTTPStatusCodeError):
+        (WebCore::SubresourceLoader::didFinishLoading):
+        (WebCore::SubresourceLoader::didFail):
+        (WebCore::SubresourceLoader::willCancel):
+        * loader/SubresourceLoader.h:
+
 2013-06-04  Christophe Dumez  <ch.dumez@sisa.samsung.com>
 
         Remove [NoInterfaceObject] from XPathExpression and NodeIterator
index 2a9f5f2..f26cce5 100644 (file)
@@ -83,6 +83,7 @@
 #include "MIMETypeRegistry.h"
 #include "MemoryCache.h"
 #include "Page.h"
+#include "PageActivityAssertionToken.h"
 #include "PageCache.h"
 #include "PageTransitionEvent.h"
 #include "PlatformStrategies.h"
@@ -1092,10 +1093,13 @@ void FrameLoader::completed()
 
     if (m_frame->view())
         m_frame->view()->maintainScrollPositionAtAnchor(0);
+    m_activityAssertion.clear();
 }
 
 void FrameLoader::started()
 {
+    if (m_frame && m_frame->page())
+        m_activityAssertion = m_frame->page()->createActivityToken();
     for (Frame* frame = m_frame; frame; frame = frame->tree()->parent())
         frame->loader()->m_isComplete = false;
 }
index d90d03a..64901cd 100644 (file)
@@ -66,6 +66,7 @@ class IconController;
 class NavigationAction;
 class NetworkingContext;
 class Page;
+class PageActivityAssertionToken;
 class PolicyChecker;
 class ResourceError;
 class ResourceRequest;
@@ -446,6 +447,7 @@ private:
 
     KURL m_previousURL;
     RefPtr<HistoryItem> m_requestedHistoryItem;
+    OwnPtr<PageActivityAssertionToken> m_activityAssertion;
 };
 
 // This function is called by createWindow() in JSDOMWindowBase.cpp, for example, for
index 24bc637..9e841bc 100644 (file)
@@ -36,6 +36,8 @@
 #include "FrameLoader.h"
 #include "Logging.h"
 #include "MemoryCache.h"
+#include "Page.h"
+#include "PageActivityAssertionToken.h"
 #include "ResourceBuffer.h"
 #include <wtf/RefCountedLeakCounter.h>
 #include <wtf/StdLibExtras.h>
@@ -106,6 +108,8 @@ bool SubresourceLoader::init(const ResourceRequest& request)
 
     ASSERT(!reachedTerminalState());
     m_state = Initialized;
+    if (m_frame && m_frame->page() && !m_activityAssertion)
+        m_activityAssertion = m_frame->page()->createActivityToken();
     m_documentLoader->addSubresourceLoader(this);
     return true;
 }
@@ -246,6 +250,7 @@ bool SubresourceLoader::checkForHTTPStatusCodeError()
         return false;
 
     m_state = Finishing;
+    m_activityAssertion.clear();
     m_resource->error(CachedResource::LoadError);
     cancel();
     return true;
@@ -278,6 +283,7 @@ void SubresourceLoader::didFinishLoading(double finishTime)
     RefPtr<SubresourceLoader> protect(this);
     CachedResourceHandle<CachedResource> protectResource(m_resource);
     m_state = Finishing;
+    m_activityAssertion.clear();
     m_resource->setLoadFinishTime(finishTime);
     m_resource->data(resourceData(), true);
 
@@ -302,6 +308,7 @@ void SubresourceLoader::didFail(const ResourceError& error)
     RefPtr<SubresourceLoader> protect(this);
     CachedResourceHandle<CachedResource> protectResource(m_resource);
     m_state = Finishing;
+    m_activityAssertion.clear();
     if (m_resource->resourceToRevalidate())
         memoryCache()->revalidationFailed(m_resource);
     m_resource->setResourceError(error);
@@ -324,6 +331,7 @@ void SubresourceLoader::willCancel(const ResourceError& error)
 
     RefPtr<SubresourceLoader> protect(this);
     m_state = Finishing;
+    m_activityAssertion.clear();
     if (m_resource->resourceToRevalidate())
         memoryCache()->revalidationFailed(m_resource);
     m_resource->setResourceError(error);
index 4e5ecdc..1cc4cae 100644 (file)
@@ -39,6 +39,7 @@ namespace WebCore {
 class CachedResource;
 class CachedResourceLoader;
 class Document;
+class PageActivityAssertionToken;
 class ResourceRequest;
 
 class SubresourceLoader : public ResourceLoader {
@@ -98,6 +99,7 @@ private:
     bool m_loadingMultipartContent;
     SubresourceLoaderState m_state;
     OwnPtr<RequestCountTracker> m_requestCountTracker;
+    OwnPtr<PageActivityAssertionToken> m_activityAssertion;
 };
 
 }