OnDidLoadResourceFromMemoryCache notifies network service cache correctly
OnDidLoadResourceFromMemoryCache calls new NotifyExternalCacheHit
when network service is active as to properly update the cache with an external hit.
Bug: 893323
Change-Id: Ia21b3441122a55d8eb5a8c7e508b4243ab500cda
Reviewed-on: https://chromium-review.googlesource.com/c/1366435
Commit-Queue: Steven Bingler <[email protected]>
Reviewed-by: John Abd-El-Malek <[email protected]>
Reviewed-by: Tom Sepez <[email protected]>
Reviewed-by: Bence Béky <[email protected]>
Cr-Commit-Position: refs/heads/master@{#615956}
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index ef41fbd..9723917 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -4385,17 +4385,22 @@
for (auto& observer : observers_)
observer.DidLoadResourceFromMemoryCache(url, mime_type, resource_type);
- if (url.is_valid() && url.SchemeIsHTTPOrHTTPS() &&
- // http://crbug.com/893323: get this working with network service.
- !base::FeatureList::IsEnabled(network::features::kNetworkService)) {
+ if (url.is_valid() && url.SchemeIsHTTPOrHTTPS()) {
StoragePartition* partition = source->GetProcess()->GetStoragePartition();
- scoped_refptr<net::URLRequestContextGetter> request_context(
- resource_type == RESOURCE_TYPE_MEDIA
- ? partition->GetMediaURLRequestContext()
- : partition->GetURLRequestContext());
- base::PostTaskWithTraits(
- FROM_HERE, {BrowserThread::IO},
- base::BindOnce(&NotifyCacheOnIO, request_context, url, http_method));
+
+ // We require different paths here because there is no NetworkContext
+ // for media cache.
+ if (base::FeatureList::IsEnabled(network::features::kNetworkService)) {
+ partition->GetNetworkContext()->NotifyExternalCacheHit(url, http_method);
+ } else {
+ scoped_refptr<net::URLRequestContextGetter> request_context(
+ resource_type == RESOURCE_TYPE_MEDIA
+ ? partition->GetMediaURLRequestContext()
+ : partition->GetURLRequestContext());
+ base::PostTaskWithTraits(
+ FROM_HERE, {BrowserThread::IO},
+ base::BindOnce(&NotifyCacheOnIO, request_context, url, http_method));
+ }
}
}