summaryrefslogtreecommitdiff
path: root/chromium/content/common/service_worker
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/content/common/service_worker')
-rw-r--r--chromium/content/common/service_worker/service_worker_loader_helpers.cc18
-rw-r--r--chromium/content/common/service_worker/service_worker_loader_helpers.h2
-rw-r--r--chromium/content/common/service_worker/service_worker_utils.cc11
-rw-r--r--chromium/content/common/service_worker/service_worker_utils.h3
4 files changed, 30 insertions, 4 deletions
diff --git a/chromium/content/common/service_worker/service_worker_loader_helpers.cc b/chromium/content/common/service_worker/service_worker_loader_helpers.cc
index 8f2ac0aff55..b09fd3dc98b 100644
--- a/chromium/content/common/service_worker/service_worker_loader_helpers.cc
+++ b/chromium/content/common/service_worker/service_worker_loader_helpers.cc
@@ -96,10 +96,19 @@ void ServiceWorkerLoaderHelpers::SaveResponseInfo(
out_head->was_fallback_required_by_service_worker = false;
out_head->url_list_via_service_worker = response.url_list;
out_head->response_type = response.response_type;
+ if (response.mime_type.has_value()) {
+ std::string charset;
+ bool had_charset = false;
+ // The mime type set on |response| may have a charset included. The
+ // loading stack, however, expects the charset to already have been
+ // stripped. Parse out the mime type essence without any charset and
+ // store the result on |out_head|.
+ net::HttpUtil::ParseContentType(response.mime_type.value(),
+ &out_head->mime_type, &charset,
+ &had_charset, nullptr);
+ }
out_head->response_time = response.response_time;
- out_head->is_in_cache_storage =
- response.response_source ==
- network::mojom::FetchResponseSource::kCacheStorage;
+ out_head->service_worker_response_source = response.response_source;
if (response.cache_storage_cache_name)
out_head->cache_storage_cache_name = *(response.cache_storage_cache_name);
else
@@ -107,6 +116,9 @@ void ServiceWorkerLoaderHelpers::SaveResponseInfo(
out_head->cors_exposed_header_names = response.cors_exposed_header_names;
out_head->did_service_worker_navigation_preload = false;
out_head->parsed_headers = mojo::Clone(response.parsed_headers);
+ out_head->connection_info = response.connection_info;
+ out_head->alpn_negotiated_protocol = response.alpn_negotiated_protocol;
+ out_head->was_fetched_via_spdy = response.was_fetched_via_spdy;
}
// static
diff --git a/chromium/content/common/service_worker/service_worker_loader_helpers.h b/chromium/content/common/service_worker/service_worker_loader_helpers.h
index c90564e3b3a..8d82271bb85 100644
--- a/chromium/content/common/service_worker/service_worker_loader_helpers.h
+++ b/chromium/content/common/service_worker/service_worker_loader_helpers.h
@@ -21,7 +21,7 @@ struct ResourceRequest;
namespace content {
// Helper functions for service worker classes that use URLLoader
-//(e.g., ServiceWorkerNavigationLoader and ServiceWorkerSubresourceLoader).
+//(e.g., ServiceWorkerMainResourceLoader and ServiceWorkerSubresourceLoader).
class ServiceWorkerLoaderHelpers {
public:
// Populates |out_head->headers| with the given |status_code|, |status_text|,
diff --git a/chromium/content/common/service_worker/service_worker_utils.cc b/chromium/content/common/service_worker/service_worker_utils.cc
index 91f1a64250b..eb8dd0ecf59 100644
--- a/chromium/content/common/service_worker/service_worker_utils.cc
+++ b/chromium/content/common/service_worker/service_worker_utils.cc
@@ -56,6 +56,17 @@ bool ServiceWorkerUtils::IsMainResourceType(blink::mojom::ResourceType type) {
}
// static
+bool ServiceWorkerUtils::IsMainRequestDestination(
+ network::mojom::RequestDestination destination) {
+ // When PlzDedicatedWorker is enabled, a dedicated worker script is considered
+ // to be a main resource.
+ if (destination == network::mojom::RequestDestination::kWorker)
+ return base::FeatureList::IsEnabled(blink::features::kPlzDedicatedWorker);
+ return blink::IsRequestDestinationFrame(destination) ||
+ destination == network::mojom::RequestDestination::kSharedWorker;
+}
+
+// static
bool ServiceWorkerUtils::ScopeMatches(const GURL& scope, const GURL& url) {
DCHECK(!scope.has_ref());
return base::StartsWith(url.spec(), scope.spec(),
diff --git a/chromium/content/common/service_worker/service_worker_utils.h b/chromium/content/common/service_worker/service_worker_utils.h
index 36955b209cc..1ea5f93e362 100644
--- a/chromium/content/common/service_worker/service_worker_utils.h
+++ b/chromium/content/common/service_worker/service_worker_utils.h
@@ -28,6 +28,9 @@ class ServiceWorkerUtils {
public:
static bool IsMainResourceType(blink::mojom::ResourceType type);
+ static bool IsMainRequestDestination(
+ network::mojom::RequestDestination destination);
+
// Returns true if |scope| matches |url|.
CONTENT_EXPORT static bool ScopeMatches(const GURL& scope, const GURL& url);