Modified: trunk/Source/WebCore/ChangeLog (177580 => 177581)
--- trunk/Source/WebCore/ChangeLog 2014-12-19 19:07:41 UTC (rev 177580)
+++ trunk/Source/WebCore/ChangeLog 2014-12-19 19:15:36 UTC (rev 177581)
@@ -1,3 +1,18 @@
+2014-12-19 Chris Dumez <[email protected]>
+
+ [iOS] Log how successful the memory cache is using FeatureCounter
+ https://bugs.webkit.org/show_bug.cgi?id=139802
+
+ Reviewed by Andreas Kling.
+
+ Log how successful the memory cache is using FeatureCounter and why we
+ choose not to use the resource in the memory cache when it is present.
+
+ * loader/cache/CachedResourceLoader.cpp:
+ (WebCore::CachedResourceLoader::requestResource):
+ (WebCore::CachedResourceLoader::determineRevalidationPolicy):
+ * platform/FeatureCounterKeys.h:
+
2014-12-19 Commit Queue <[email protected]>
Unreviewed, rolling out r177574.
Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp (177580 => 177581)
--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp 2014-12-19 19:07:41 UTC (rev 177580)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp 2014-12-19 19:15:36 UTC (rev 177581)
@@ -42,6 +42,7 @@
#include "DOMWindow.h"
#include "Document.h"
#include "DocumentLoader.h"
+#include "FeatureCounter.h"
#include "Frame.h"
#include "FrameLoader.h"
#include "FrameLoaderClient.h"
@@ -469,20 +470,28 @@
resource = memoryCache().resourceForRequest(request.resourceRequest(), sessionID());
+ Page* page = frame() ? frame()->page() : nullptr;
+ FEATURE_COUNTER_INCREMENT_KEY(page, resource ? FeatureCounterResourceRequestInMemoryCacheKey : FeatureCounterResourceRequestNotInMemoryCacheKey);
+
const RevalidationPolicy policy = determineRevalidationPolicy(type, request.mutableResourceRequest(), request.forPreload(), resource.get(), request.defer());
switch (policy) {
case Reload:
memoryCache().remove(resource.get());
FALLTHROUGH;
case Load:
+ if (resource)
+ FEATURE_COUNTER_INCREMENT_KEY(page, FeatureCounterResourceRequestInMemoryCacheUnusedKey);
resource = loadResource(type, request);
break;
case Revalidate:
+ if (resource)
+ FEATURE_COUNTER_INCREMENT_KEY(page, FeatureCounterResourceRequestInMemoryCacheRevalidatingKey);
resource = revalidateResource(request, resource.get());
break;
case Use:
if (!shouldContinueAfterNotifyingLoadedFromMemoryCache(request, resource.get()))
return 0;
+ FEATURE_COUNTER_INCREMENT_KEY(page, FeatureCounterResourceRequestInMemoryCacheUsedKey);
memoryCache().resourceAccessed(resource.get());
break;
}
@@ -584,9 +593,12 @@
if (forPreload && existingResource->isPreloaded())
return Use;
+ Page* page = frame() ? frame()->page() : nullptr;
+
// If the same URL has been loaded as a different type, we need to reload.
if (existingResource->type() != type) {
LOG(ResourceLoading, "CachedResourceLoader::determineRevalidationPolicy reloading due to type mismatch.");
+ FEATURE_COUNTER_INCREMENT_KEY(page, FeatureCounterResourceRequestInMemoryCacheUnusedReasonTypeMismatchKey);
return Reload;
}
@@ -616,12 +628,14 @@
// Don't reuse resources with Cache-control: no-store.
if (existingResource->response().cacheControlContainsNoStore()) {
LOG(ResourceLoading, "CachedResourceLoader::determineRevalidationPolicy reloading due to Cache-control: no-store.");
+ FEATURE_COUNTER_INCREMENT_KEY(page, FeatureCounterResourceRequestInMemoryCacheUnusedReasonNoStoreKey);
return Reload;
}
// Validate the redirect chain
if (!existingResource->redirectChainAllowsReuse()) {
LOG(ResourceLoading, "CachedResourceLoader::determineRevalidationPolicy reloading due to not cached or expired redirections.");
+ FEATURE_COUNTER_INCREMENT_KEY(page, FeatureCounterResourceRequestInMemoryCacheUnusedReasonRedirectChainKey);
return Reload;
}
@@ -633,6 +647,7 @@
// client's requests are made without CORS and some with.
if (existingResource->resourceRequest().allowCookies() != request.allowCookies()) {
LOG(ResourceLoading, "CachedResourceLoader::determineRevalidationPolicy reloading due to difference in credentials settings.");
+ FEATURE_COUNTER_INCREMENT_KEY(page, FeatureCounterResourceRequestInMemoryCacheUnusedReasonCredentialSettingsKey);
return Reload;
}
@@ -643,12 +658,14 @@
// CachePolicyReload always reloads
if (cachePolicy(type) == CachePolicyReload) {
LOG(ResourceLoading, "CachedResourceLoader::determineRevalidationPolicy reloading due to CachePolicyReload.");
+ FEATURE_COUNTER_INCREMENT_KEY(page, FeatureCounterResourceRequestInMemoryCacheUnusedReasonReloadKey);
return Reload;
}
// We'll try to reload the resource if it failed last time.
if (existingResource->errorOccurred()) {
LOG(ResourceLoading, "CachedResourceLoader::determineRevalidationPolicye reloading due to resource being in the error state");
+ FEATURE_COUNTER_INCREMENT_KEY(page, FeatureCounterResourceRequestInMemoryCacheUnusedReasonErrorKey);
return Reload;
}
@@ -663,7 +680,8 @@
return Revalidate;
// No, must reload.
- LOG(ResourceLoading, "CachedResourceLoader::determineRevalidationPolicy reloading due to missing cache validators.");
+ LOG(ResourceLoading, "CachedResourceLoader::determineRevalidationPolicy reloading due to missing cache validators.");
+ FEATURE_COUNTER_INCREMENT_KEY(page, FeatureCounterResourceRequestInMemoryCacheUnusedReasonMustRevalidateNoValidatorKey);
return Reload;
}
Modified: trunk/Source/WebCore/platform/FeatureCounterKeys.h (177580 => 177581)
--- trunk/Source/WebCore/platform/FeatureCounterKeys.h 2014-12-19 19:07:41 UTC (rev 177580)
+++ trunk/Source/WebCore/platform/FeatureCounterKeys.h 2014-12-19 19:15:36 UTC (rev 177581)
@@ -79,6 +79,20 @@
static const char FeatureCounterNavigationSame[] = "com.apple.WebKit.navigation.same";
static const char FeatureCounterNavigationReloadFromOrigin[] = "com.apple.WebKit.navigation.reloadFromOrigin";
+// Memory cache.
+static const char FeatureCounterResourceRequestInMemoryCacheKey[] = "com.apple.WebKit.resourceRequest.inMemoryCache";
+static const char FeatureCounterResourceRequestNotInMemoryCacheKey[] = "com.apple.WebKit.resourceRequest.notInMemoryCache";
+static const char FeatureCounterResourceRequestInMemoryCacheUnusedKey[] = "com.apple.WebKit.resourceRequest.inMemoryCache.unused";
+static const char FeatureCounterResourceRequestInMemoryCacheUsedKey[] = "com.apple.WebKit.resourceRequest.inMemoryCache.used";
+static const char FeatureCounterResourceRequestInMemoryCacheRevalidatingKey[] = "com.apple.WebKit.resourceRequest.inMemoryCache.revalidating";
+static const char FeatureCounterResourceRequestInMemoryCacheUnusedReasonNoStoreKey[] = "com.apple.WebKit.resourceRequest.inMemoryCache.unused.reason.noStore";
+static const char FeatureCounterResourceRequestInMemoryCacheUnusedReasonTypeMismatchKey[] = "com.apple.WebKit.resourceRequest.inMemoryCache.unused.reason.typeMismatch";
+static const char FeatureCounterResourceRequestInMemoryCacheUnusedReasonRedirectChainKey[] = "com.apple.WebKit.resourceRequest.inMemoryCache.unused.reason.redirectChain";
+static const char FeatureCounterResourceRequestInMemoryCacheUnusedReasonCredentialSettingsKey[] = "com.apple.WebKit.resourceRequest.inMemoryCache.unused.reason.credentialSettings";
+static const char FeatureCounterResourceRequestInMemoryCacheUnusedReasonReloadKey[] = "com.apple.WebKit.resourceRequest.inMemoryCache.unused.reason.reload";
+static const char FeatureCounterResourceRequestInMemoryCacheUnusedReasonErrorKey[] = "com.apple.WebKit.resourceRequest.inMemoryCache.unused.reason.error";
+static const char FeatureCounterResourceRequestInMemoryCacheUnusedReasonMustRevalidateNoValidatorKey[] = "com.apple.WebKit.resourceRequest.inMemoryCache.unused.reason.mustRevalidateNoValidator";
+
} // namespace WebCore
#endif // FeatureCounterKeys_h