Title: [177499] trunk/Source/WebCore
Revision
177499
Author
[email protected]
Date
2014-12-18 09:21:03 -0800 (Thu, 18 Dec 2014)

Log Message

[iOS] Log why cached resources are being revalidated using FeatureCounter API
https://bugs.webkit.org/show_bug.cgi?id=139759
<rdar://problem/19288177>

Reviewed by Antti Koivisto.

Log why cached resources are being revalidated using FeatureCounter API.
Also log if revalidation is successful or not.

No new tests, no behavior change.

* loader/SubresourceLoader.cpp:
(WebCore::SubresourceLoader::willSendRequest):
(WebCore::SubresourceLoader::didReceiveResponse):
* loader/cache/CachedImage.cpp:
(WebCore::CachedImage::mustRevalidateDueToCacheHeaders):
* loader/cache/CachedImage.h:
* loader/cache/CachedResource.cpp:
(WebCore::CachedResource::failBeforeStarting):
(WebCore::CachedResource::mustRevalidateDueToCacheHeaders):
* loader/cache/CachedResource.h:
(WebCore::CachedResource::loader):
* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::determineRevalidationPolicy):
* platform/FeatureCounterKeys.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (177498 => 177499)


--- trunk/Source/WebCore/ChangeLog	2014-12-18 16:33:56 UTC (rev 177498)
+++ trunk/Source/WebCore/ChangeLog	2014-12-18 17:21:03 UTC (rev 177499)
@@ -1,3 +1,31 @@
+2014-12-18  Chris Dumez  <[email protected]>
+
+        [iOS] Log why cached resources are being revalidated using FeatureCounter API
+        https://bugs.webkit.org/show_bug.cgi?id=139759
+        <rdar://problem/19288177>
+
+        Reviewed by Antti Koivisto.
+
+        Log why cached resources are being revalidated using FeatureCounter API.
+        Also log if revalidation is successful or not.
+
+        No new tests, no behavior change.
+
+        * loader/SubresourceLoader.cpp:
+        (WebCore::SubresourceLoader::willSendRequest):
+        (WebCore::SubresourceLoader::didReceiveResponse):
+        * loader/cache/CachedImage.cpp:
+        (WebCore::CachedImage::mustRevalidateDueToCacheHeaders):
+        * loader/cache/CachedImage.h:
+        * loader/cache/CachedResource.cpp:
+        (WebCore::CachedResource::failBeforeStarting):
+        (WebCore::CachedResource::mustRevalidateDueToCacheHeaders):
+        * loader/cache/CachedResource.h:
+        (WebCore::CachedResource::loader):
+        * loader/cache/CachedResourceLoader.cpp:
+        (WebCore::CachedResourceLoader::determineRevalidationPolicy):
+        * platform/FeatureCounterKeys.h:
+
 2014-12-18  Antti Koivisto  <[email protected]>
 
         Remove alwaysUseBaselineOfPrimaryFont setting

Modified: trunk/Source/WebCore/loader/SubresourceLoader.cpp (177498 => 177499)


--- trunk/Source/WebCore/loader/SubresourceLoader.cpp	2014-12-18 16:33:56 UTC (rev 177498)
+++ trunk/Source/WebCore/loader/SubresourceLoader.cpp	2014-12-18 17:21:03 UTC (rev 177499)
@@ -32,6 +32,7 @@
 #include "CachedResourceLoader.h"
 #include "Document.h"
 #include "DocumentLoader.h"
+#include "FeatureCounter.h"
 #include "Frame.h"
 #include "FrameLoader.h"
 #include "Logging.h"
@@ -156,6 +157,7 @@
         if (newRequest.isConditional() && m_resource->resourceToRevalidate() && newRequest.url() != m_resource->resourceToRevalidate()->response().url()) {
             newRequest.makeUnconditional();
             memoryCache().revalidationFailed(m_resource);
+            FEATURE_COUNTER_INCREMENT_KEY(m_frame ? m_frame->page() : nullptr, FeatureCounterCachedResourceRevalidationFailureKey);
         }
         
         if (!m_documentLoader->cachedResourceLoader().canRequest(m_resource->type(), newRequest.url(), options())) {
@@ -202,12 +204,14 @@
             // Existing resource is ok, just use it updating the expiration time.
             m_resource->setResponse(response);
             memoryCache().revalidationSucceeded(m_resource, response);
+            FEATURE_COUNTER_INCREMENT_KEY(m_frame ? m_frame->page() : nullptr, FeatureCounterCachedResourceRevalidationSuccessKey);
             if (!reachedTerminalState())
                 ResourceLoader::didReceiveResponse(response);
             return;
         }
         // Did not get 304 response, continue as a regular resource load.
         memoryCache().revalidationFailed(m_resource);
+        FEATURE_COUNTER_INCREMENT_KEY(m_frame ? m_frame->page() : nullptr, FeatureCounterCachedResourceRevalidationFailureKey);
     }
 
     m_resource->responseReceived(response);

Modified: trunk/Source/WebCore/loader/cache/CachedImage.cpp (177498 => 177499)


--- trunk/Source/WebCore/loader/cache/CachedImage.cpp	2014-12-18 16:33:56 UTC (rev 177498)
+++ trunk/Source/WebCore/loader/cache/CachedImage.cpp	2014-12-18 17:21:03 UTC (rev 177499)
@@ -508,7 +508,7 @@
     return !securityOrigin->taintsCanvas(response().url());
 }
 
-bool CachedImage::mustRevalidateDueToCacheHeaders(CachePolicy policy) const
+bool CachedImage::mustRevalidateDueToCacheHeaders(const CachedResourceLoader& cachedResourceLoader, CachePolicy policy) const
 {
     if (UNLIKELY(isManuallyCached())) {
         // Do not revalidate manually cached images. This mechanism is used as a
@@ -518,7 +518,7 @@
         // incumbent on the client to only use valid resources.
         return false;
     }
-    return CachedResource::mustRevalidateDueToCacheHeaders(policy);
+    return CachedResource::mustRevalidateDueToCacheHeaders(cachedResourceLoader, policy);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/loader/cache/CachedImage.h (177498 => 177499)


--- trunk/Source/WebCore/loader/cache/CachedImage.h	2014-12-18 16:33:56 UTC (rev 177498)
+++ trunk/Source/WebCore/loader/cache/CachedImage.h	2014-12-18 17:21:03 UTC (rev 177499)
@@ -84,7 +84,7 @@
     void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio);
 
     bool isManuallyCached() const { return m_isManuallyCached; }
-    virtual bool mustRevalidateDueToCacheHeaders(CachePolicy) const override;
+    virtual bool mustRevalidateDueToCacheHeaders(const CachedResourceLoader&, CachePolicy) const override;
     virtual void load(CachedResourceLoader*, const ResourceLoaderOptions&) override;
 
     bool isOriginClean(SecurityOrigin*);

Modified: trunk/Source/WebCore/loader/cache/CachedResource.cpp (177498 => 177499)


--- trunk/Source/WebCore/loader/cache/CachedResource.cpp	2014-12-18 16:33:56 UTC (rev 177498)
+++ trunk/Source/WebCore/loader/cache/CachedResource.cpp	2014-12-18 17:21:03 UTC (rev 177499)
@@ -31,6 +31,7 @@
 #include "CrossOriginAccessControl.h"
 #include "Document.h"
 #include "DocumentLoader.h"
+#include "FeatureCounter.h"
 #include "FrameLoader.h"
 #include "FrameLoaderClient.h"
 #include "HTTPHeaderNames.h"
@@ -676,21 +677,29 @@
     return m_response.hasCacheValidatorFields();
 }
 
-bool CachedResource::mustRevalidateDueToCacheHeaders(CachePolicy cachePolicy) const
+bool CachedResource::mustRevalidateDueToCacheHeaders(const CachedResourceLoader& cachedResourceLoader, CachePolicy cachePolicy) const
 {    
     ASSERT(cachePolicy == CachePolicyRevalidate || cachePolicy == CachePolicyCache || cachePolicy == CachePolicyVerify);
 
-    if (cachePolicy == CachePolicyRevalidate)
+    if (cachePolicy == CachePolicyRevalidate) {
+        FEATURE_COUNTER_INCREMENT_KEY(cachedResourceLoader.frame()->page(), FeatureCounterCachedResourceRevalidationReasonReloadKey);
         return true;
+    }
 
     if (m_response.cacheControlContainsNoCache() || m_response.cacheControlContainsNoStore()) {
         LOG(ResourceLoading, "CachedResource %p mustRevalidate because of m_response.cacheControlContainsNoCache() || m_response.cacheControlContainsNoStore()\n", this);
+        if (m_response.cacheControlContainsNoStore())
+            FEATURE_COUNTER_INCREMENT_KEY(cachedResourceLoader.frame()->page(), FeatureCounterCachedResourceRevalidationReasonNoStoreKey);
+        else
+            FEATURE_COUNTER_INCREMENT_KEY(cachedResourceLoader.frame()->page(), FeatureCounterCachedResourceRevalidationReasonNoCacheKey);
+
         return true;
     }
 
     if (cachePolicy == CachePolicyCache) {
         if (m_response.cacheControlContainsMustRevalidate() && isExpired()) {
             LOG(ResourceLoading, "CachedResource %p mustRevalidate because of cachePolicy == CachePolicyCache and m_response.cacheControlContainsMustRevalidate() && isExpired()\n", this);
+            FEATURE_COUNTER_INCREMENT_KEY(cachedResourceLoader.frame()->page(), FeatureCounterCachedResourceRevalidationReasonMustRevalidateIsExpiredKey);
             return true;
         }
         return false;
@@ -699,6 +708,7 @@
     // CachePolicyVerify
     if (isExpired()) {
         LOG(ResourceLoading, "CachedResource %p mustRevalidate because of isExpired()\n", this);
+        FEATURE_COUNTER_INCREMENT_KEY(cachedResourceLoader.frame()->page(), FeatureCounterCachedResourceRevalidationReasonIsExpiredKey);
         return true;
     }
 

Modified: trunk/Source/WebCore/loader/cache/CachedResource.h (177498 => 177499)


--- trunk/Source/WebCore/loader/cache/CachedResource.h	2014-12-18 16:33:56 UTC (rev 177498)
+++ trunk/Source/WebCore/loader/cache/CachedResource.h	2014-12-18 17:21:03 UTC (rev 177499)
@@ -229,7 +229,7 @@
     
     bool canUseCacheValidator() const;
 
-    virtual bool mustRevalidateDueToCacheHeaders(CachePolicy) const;
+    virtual bool mustRevalidateDueToCacheHeaders(const CachedResourceLoader&, CachePolicy) const;
     bool redirectChainAllowsReuse() const;
 
     bool isCacheValidator() const { return m_resourceToRevalidate; }

Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp (177498 => 177499)


--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp	2014-12-18 16:33:56 UTC (rev 177498)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp	2014-12-18 17:21:03 UTC (rev 177499)
@@ -657,7 +657,7 @@
         return Use;
 
     // Check if the cache headers requires us to revalidate (cache expiration for example).
-    if (existingResource->mustRevalidateDueToCacheHeaders(cachePolicy(type))) {
+    if (existingResource->mustRevalidateDueToCacheHeaders(*this, cachePolicy(type))) {
         // See if the resource has usable ETag or Last-modified headers.
         if (existingResource->canUseCacheValidator())
             return Revalidate;

Modified: trunk/Source/WebCore/platform/FeatureCounterKeys.h (177498 => 177499)


--- trunk/Source/WebCore/platform/FeatureCounterKeys.h	2014-12-18 16:33:56 UTC (rev 177498)
+++ trunk/Source/WebCore/platform/FeatureCounterKeys.h	2014-12-18 17:21:03 UTC (rev 177499)
@@ -61,6 +61,15 @@
 static const char FeatureCounterPageCacheFailureKey[] = "com.apple.WebKit.pageCache.failure";
 static const char FeatureCounterPageCacheSuccessKey[] = "com.apple.WebKit.pageCache.success";
 
+// Cached resources revalidation.
+static const char FeatureCounterCachedResourceRevalidationSuccessKey[] = "com.apple.WebKit.cachedResourceRevalidation.success";
+static const char FeatureCounterCachedResourceRevalidationFailureKey[] = "com.apple.WebKit.cachedResourceRevalidation.failure";
+static const char FeatureCounterCachedResourceRevalidationReasonReloadKey[] = "com.apple.WebKit.cachedResourceRevalidation.reason.reload";
+static const char FeatureCounterCachedResourceRevalidationReasonNoCacheKey[] = "com.apple.WebKit.cachedResourceRevalidation.reason.noCache";
+static const char FeatureCounterCachedResourceRevalidationReasonNoStoreKey[] = "com.apple.WebKit.cachedResourceRevalidation.reason.noStore";
+static const char FeatureCounterCachedResourceRevalidationReasonMustRevalidateIsExpiredKey[] = "com.apple.WebKit.cachedResourceRevalidation.reason.mustRevalidateIsExpired";
+static const char FeatureCounterCachedResourceRevalidationReasonIsExpiredKey[] = "com.apple.WebKit.cachedResourceRevalidation.reason.isExpired";
+
 } // namespace WebCore
 
 #endif // FeatureCounterKeys_h
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to