Commit f3ebd2f6 authored by Yutaka Hirano's avatar Yutaka Hirano Committed by Commit Bot

Drop MemoryCache support for non-GET requests

Have Resource::CanReuse return false when the request method is not GET.
This is harmless because currently all the preload requests and requests
that can be served from the MemoryCache are GET requests, given that
RawResources are not served from the MemoryCache.

This change will allow us not to store the request body in Resource,
which will be important when we introduce streaming upload because
we do not want to copy a streaming request body.

Bug: 688906
Change-Id: I5b1b01a6f003378f0ac33f528d209c610178fa29
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2024627Reviewed-by: default avatarYoav Weiss <yoavweiss@chromium.org>
Reviewed-by: default avatarHiroshige Hayashizaki <hiroshige@chromium.org>
Reviewed-by: default avatarYoichi Osato <yoichio@chromium.org>
Commit-Queue: Yutaka Hirano <yhirano@chromium.org>
Cr-Commit-Position: refs/heads/master@{#736237}
parent 28e7935e
...@@ -823,12 +823,13 @@ Resource::MatchStatus Resource::CanReuse(const FetchParameters& params) const { ...@@ -823,12 +823,13 @@ Resource::MatchStatus Resource::CanReuse(const FetchParameters& params) const {
if (resource_request_.GetKeepalive() || new_request.GetKeepalive()) if (resource_request_.GetKeepalive() || new_request.GetKeepalive())
return MatchStatus::kKeepaliveSet; return MatchStatus::kKeepaliveSet;
if (GetResourceRequest().HttpMethod() != new_request.HttpMethod()) if (GetResourceRequest().HttpMethod() != http_names::kGET ||
new_request.HttpMethod() != http_names::kGET) {
return MatchStatus::kRequestMethodDoesNotMatch; return MatchStatus::kRequestMethodDoesNotMatch;
}
if (GetResourceRequest().HttpBody() != new_request.HttpBody()) // A GET request doesn't have a request body.
return MatchStatus::kUnknownFailure; DCHECK(!new_request.HttpBody());
// Don't reuse an existing resource when the source origin is different. // Don't reuse an existing resource when the source origin is different.
if (!existing_origin->IsSameOriginWith(new_origin.get())) if (!existing_origin->IsSameOriginWith(new_origin.get()))
......
...@@ -158,24 +158,12 @@ ResourceLoadPriority TypeToPriority(ResourceType type) { ...@@ -158,24 +158,12 @@ ResourceLoadPriority TypeToPriority(ResourceType type) {
return ResourceLoadPriority::kUnresolved; return ResourceLoadPriority::kUnresolved;
} }
static bool IsCacheableHTTPMethod(const AtomicString& method) {
// Per http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.10,
// these methods always invalidate the cache entry.
return method != http_names::kPOST && method != http_names::kPUT &&
method != "DELETE";
}
bool ShouldResourceBeAddedToMemoryCache(const FetchParameters& params, bool ShouldResourceBeAddedToMemoryCache(const FetchParameters& params,
Resource* resource) { Resource* resource) {
if (!IsMainThread()) return IsMainThread() &&
return false; params.GetResourceRequest().HttpMethod() == http_names::kGET &&
if (params.Options().data_buffering_policy == kDoNotBufferData) params.Options().data_buffering_policy != kDoNotBufferData &&
return false; !IsRawResource(*resource);
if (IsRawResource(*resource))
return false;
if (!IsCacheableHTTPMethod(params.GetResourceRequest().HttpMethod()))
return false;
return true;
} }
static ResourceFetcher::ResourceFetcherSet& MainThreadFetchersSet() { static ResourceFetcher::ResourceFetcherSet& MainThreadFetchersSet() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment