Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(351)

Unified Diff: third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.cpp

Issue 2880733002: Partially implement WorkerFetchContext and WorkerThreadableLoadingContext and add virtual tests (Closed)
Patch Set: incorporated kinuko's comment Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.cpp
diff --git a/third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.cpp b/third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.cpp
index a638d74e061bf8ef0505ffac18665d74dce644d9..4ca1989f0786653063dd4dd5958df3a8e9fb5196 100644
--- a/third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.cpp
+++ b/third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.cpp
@@ -604,7 +604,7 @@ Resource* ResourceFetcher::RequestResource(
if (!resource && !is_data_url && archive_)
return nullptr;
}
- if (!resource) {
+ if (!resource && IsMainThread()) {
resource =
GetMemoryCache()->ResourceForURL(params.Url(), GetCacheIdentifier());
}
@@ -751,7 +751,8 @@ Resource* ResourceFetcher::CreateResourceForLoading(
const String& charset,
const ResourceFactory& factory) {
const String cache_identifier = GetCacheIdentifier();
- DCHECK(!GetMemoryCache()->ResourceForURL(params.GetResourceRequest().Url(),
+ DCHECK(!IsMainThread() ||
+ !GetMemoryCache()->ResourceForURL(params.GetResourceRequest().Url(),
cache_identifier));
RESOURCE_LOADING_DVLOG(1) << "Loading Resource for "
@@ -767,7 +768,7 @@ Resource* ResourceFetcher::CreateResourceForLoading(
// - Don't add main resource to cache to prevent reuse.
// - Don't add the resource if its body will not be stored.
- if (factory.GetType() != Resource::kMainResource &&
+ if (IsMainThread() && factory.GetType() != Resource::kMainResource &&
params.Options().data_buffering_policy != kDoNotBufferData) {
GetMemoryCache()->Add(resource);
}
@@ -1276,9 +1277,10 @@ bool ResourceFetcher::StartLoad(Resource* resource) {
prohibit_add_remove_client_in_scope(resource);
Resource::RevalidationStartForbiddenScope
revalidation_start_forbidden_scope(resource);
- ScriptForbiddenScope script_forbidden_scope;
+ ScriptForbiddenIfMainThreadScope script_forbidden_scope;
- if (!Context().ShouldLoadNewResource(resource->GetType())) {
+ if (!Context().ShouldLoadNewResource(resource->GetType()) &&
+ IsMainThread()) {
GetMemoryCache()->Remove(resource);
return false;
}

Powered by Google App Engine
This is Rietveld 408576698