diff --git a/build/patches/Partition-Blink-memory-cache.patch b/build/patches/Partition-Blink-memory-cache.patch index 011b30be..49f2070c 100644 --- a/build/patches/Partition-Blink-memory-cache.patch +++ b/build/patches/Partition-Blink-memory-cache.patch @@ -16,13 +16,14 @@ License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html --- .../core/html/parser/html_srcset_parser.cc | 2 +- .../core/inspector/inspector_network_agent.cc | 2 +- - .../core/inspector/inspector_page_agent.cc | 4 +-- - .../renderer/core/loader/image_loader.cc | 3 ++- - .../platform/loader/fetch/memory_cache.cc | 8 ++---- - .../platform/loader/fetch/memory_cache.h | 5 ++-- - .../platform/loader/fetch/resource_fetcher.cc | 27 ++++++++++++++----- - .../platform/loader/fetch/resource_fetcher.h | 5 +++- - 8 files changed, 35 insertions(+), 21 deletions(-) + .../core/inspector/inspector_page_agent.cc | 4 +- + .../renderer/core/loader/image_loader.cc | 3 +- + .../core/loader/worker_fetch_context.cc | 3 ++ + .../platform/loader/fetch/memory_cache.cc | 8 +--- + .../platform/loader/fetch/memory_cache.h | 5 +-- + .../platform/loader/fetch/resource_fetcher.cc | 41 ++++++++++++++++--- + .../platform/loader/fetch/resource_fetcher.h | 7 +++- + 9 files changed, 54 insertions(+), 21 deletions(-) diff --git a/third_party/blink/renderer/core/html/parser/html_srcset_parser.cc b/third_party/blink/renderer/core/html/parser/html_srcset_parser.cc --- a/third_party/blink/renderer/core/html/parser/html_srcset_parser.cc @@ -76,6 +77,19 @@ diff --git a/third_party/blink/renderer/core/loader/image_loader.cc b/third_part if (resource && !resource->ErrorOccurred() && CanReuseFromListOfAvailableImages( +diff --git a/third_party/blink/renderer/core/loader/worker_fetch_context.cc b/third_party/blink/renderer/core/loader/worker_fetch_context.cc +--- a/third_party/blink/renderer/core/loader/worker_fetch_context.cc ++++ b/third_party/blink/renderer/core/loader/worker_fetch_context.cc +@@ -268,6 +268,9 @@ void WorkerFetchContext::PopulateResourceRequestBeforeCacheAccess( + DCHECK(RuntimeEnabledFeatures:: + MinimimalResourceRequestPrepBeforeCacheLookupEnabled()); + ++ if (!request.TopFrameOrigin()) ++ request.SetTopFrameOrigin(GetTopFrameOrigin()); ++ + MixedContentChecker::UpgradeInsecureRequest( + request, &GetResourceFetcherProperties().GetFetchClientSettingsObject(), + global_scope_, mojom::RequestContextFrameType::kNone, diff --git a/third_party/blink/renderer/platform/loader/fetch/memory_cache.cc b/third_party/blink/renderer/platform/loader/fetch/memory_cache.cc --- a/third_party/blink/renderer/platform/loader/fetch/memory_cache.cc +++ b/third_party/blink/renderer/platform/loader/fetch/memory_cache.cc @@ -158,7 +172,7 @@ diff --git a/third_party/blink/renderer/platform/loader/fetch/resource_fetcher.c DCHECK(!IsMainThread() || params.IsStaleRevalidation() || !MemoryCache::Get()->ResourceForURL(params.GetResourceRequest().Url(), cache_identifier)); -@@ -2788,10 +2790,23 @@ void ResourceFetcher::UpdateAllImageResourcePriorities() { +@@ -2788,10 +2790,37 @@ void ResourceFetcher::UpdateAllImageResourcePriorities() { to_be_removed.clear(); } @@ -166,17 +180,31 @@ diff --git a/third_party/blink/renderer/platform/loader/fetch/resource_fetcher.c +String ResourceFetcher::GetCacheIdentifier(const KURL& url, + const ResourceRequest& resource_request) const { + if (const scoped_refptr top_origin = resource_request.TopFrameOrigin()) { -+ return ResourceFetcher::GetCacheIdentifier(url, top_origin); -+ } else if (const scoped_refptr requestor_origin = resource_request.RequestorOrigin()) { -+ return ResourceFetcher::GetCacheIdentifier(url, requestor_origin); ++ String origin_url = top_origin ? top_origin->ToRawString() : ""; ++ String cache_identifier = ResourceFetcher::GetCacheIdentifier(url, origin_url); ++ // LOG(INFO) << "---t (" << cache_identifier << ") " << url.GetString() << "='" << origin_url << "'"; ++ return cache_identifier; + } -+ NOTREACHED(); ++ // service workers cannot use the memory cache ++ // } else if (resource_request.GetRequestContext() == ++ // mojom::blink::RequestContextType::SERVICE_WORKER) { ++ // const scoped_refptr requestor_origin = resource_request.RequestorOrigin(); ++ // String origin_url = requestor_origin ? requestor_origin->ToRawString() : ""; //context_.Url()->ToRawString(); ++ // String cache_identifier = ResourceFetcher::GetCacheIdentifier(url, origin_url); ++ // // LOG(INFO) << "---o (" << cache_identifier << ") " << url.GetString() << "='" << origin_url << "'"; ++ // return cache_identifier; ++ // } ++ return MemoryCache::DefaultCacheIdentifier(); +} + +String ResourceFetcher::GetCacheIdentifier(const KURL& url, + scoped_refptr origin) const { + String origin_url = origin ? origin->ToRawString() : ""; ++ return ResourceFetcher::GetCacheIdentifier(url, origin_url); ++} + ++String ResourceFetcher::GetCacheIdentifier(const KURL& url, ++ const String origin_url) const { if (properties_->GetControllerServiceWorkerMode() != mojom::ControllerServiceWorkerMode::kNoController) { - return String::Number(properties_->ServiceWorkerId()); @@ -184,7 +212,7 @@ diff --git a/third_party/blink/renderer/platform/loader/fetch/resource_fetcher.c } // Requests that can be satisfied via `archive_` (i.e. MHTML) or -@@ -2804,7 +2819,7 @@ String ResourceFetcher::GetCacheIdentifier(const KURL& url) const { +@@ -2804,7 +2833,7 @@ String ResourceFetcher::GetCacheIdentifier(const KURL& url) const { if (bundle) return bundle->GetCacheIdentifier(); @@ -196,7 +224,7 @@ diff --git a/third_party/blink/renderer/platform/loader/fetch/resource_fetcher.c diff --git a/third_party/blink/renderer/platform/loader/fetch/resource_fetcher.h b/third_party/blink/renderer/platform/loader/fetch/resource_fetcher.h --- a/third_party/blink/renderer/platform/loader/fetch/resource_fetcher.h +++ b/third_party/blink/renderer/platform/loader/fetch/resource_fetcher.h -@@ -278,7 +278,10 @@ class PLATFORM_EXPORT ResourceFetcher +@@ -278,7 +278,12 @@ class PLATFORM_EXPORT ResourceFetcher uint32_t inflight_keepalive_bytes); blink::mojom::ControllerServiceWorkerMode IsControlledByServiceWorker() const; @@ -205,6 +233,8 @@ diff --git a/third_party/blink/renderer/platform/loader/fetch/resource_fetcher.h + const ResourceRequest& resource_request) const; + String GetCacheIdentifier(const KURL& url, + scoped_refptr origin) const; ++ String GetCacheIdentifier(const KURL& url, ++ const String origin_url) const; // If `url` exists as a resource in a subresource bundle in this frame, // returns its UnguessableToken; otherwise, returns std::nullopt.