Commit 6cccac4a authored by Julie Jeongeun Kim's avatar Julie Jeongeun Kim Committed by Chromium LUCI CQ

Use RequestDestination instead of ResourceType in service worker

This CL replaces blink::mojom::ResourceType with
network::mojom::RequestDestination in
content/{common,renderer}/service_worker since
blink::mojom::ResourceType is deprecated[1].

[1] https://crbug.com/960143

Bug: 1059639
Change-Id: Ia88dc12a3a655d09419a9b9c88c9457b74abdb02
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2635999Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Julie Kim <jkim@igalia.com>
Cr-Commit-Position: refs/heads/master@{#844682}
parent ace4c119
......@@ -17,9 +17,9 @@
#include "net/url_request/redirect_util.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/resource_request_body.h"
#include "services/network/public/mojom/fetch_api.mojom-shared.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "third_party/blink/public/common/blob/blob_utils.h"
#include "third_party/blink/public/mojom/loader/resource_load_info.mojom-shared.h"
#include "ui/base/page_transition_types.h"
namespace content {
......@@ -135,8 +135,8 @@ ServiceWorkerLoaderHelpers::ComputeRedirectInfo(
// If the request is a MAIN_FRAME request, the first-party URL gets
// updated on redirects.
const net::RedirectInfo::FirstPartyURLPolicy first_party_url_policy =
original_request.resource_type ==
static_cast<int>(blink::mojom::ResourceType::kMainFrame)
original_request.destination ==
network::mojom::RequestDestination::kDocument
? net::RedirectInfo::FirstPartyURLPolicy::UPDATE_URL_ON_REDIRECT
: net::RedirectInfo::FirstPartyURLPolicy::NEVER_CHANGE_URL;
return net::RedirectInfo::ComputeRedirectInfo(
......
......@@ -44,16 +44,6 @@ bool PathContainsDisallowedCharacter(const GURL& url) {
} // namespace
// static
bool ServiceWorkerUtils::IsMainResourceType(blink::mojom::ResourceType type) {
// When PlzDedicatedWorker is enabled, a dedicated worker script is considered
// to be a main resource.
if (type == blink::mojom::ResourceType::kWorker)
return base::FeatureList::IsEnabled(blink::features::kPlzDedicatedWorker);
return blink::IsResourceTypeFrame(type) ||
type == blink::mojom::ResourceType::kSharedWorker;
}
// static
bool ServiceWorkerUtils::IsMainRequestDestination(
network::mojom::RequestDestination destination) {
......
......@@ -14,18 +14,16 @@
#include "base/macros.h"
#include "content/common/content_export.h"
#include "content/public/common/content_switches.h"
#include "services/network/public/mojom/fetch_api.mojom-shared.h"
#include "third_party/blink/public/common/fetch/fetch_api_request_headers_map.h"
#include "third_party/blink/public/common/service_worker/service_worker_status_code.h"
#include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom.h"
#include "third_party/blink/public/mojom/loader/resource_load_info.mojom-shared.h"
#include "url/gurl.h"
namespace content {
class ServiceWorkerUtils {
public:
static bool IsMainResourceType(blink::mojom::ResourceType type);
static bool IsMainRequestDestination(
network::mojom::RequestDestination destination);
......
......@@ -23,11 +23,11 @@
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "services/network/public/cpp/wrapper_shared_url_loader_factory.h"
#include "services/network/public/mojom/fetch_api.mojom-shared.h"
#include "services/network/public/mojom/url_loader_factory.mojom.h"
#include "services/network/test/test_url_loader_client.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/mojom/loader/fetch_client_settings_object.mojom.h"
#include "third_party/blink/public/mojom/loader/resource_load_info.mojom-shared.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_container.mojom.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_container_type.mojom.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_error_type.mojom.h"
......@@ -291,8 +291,7 @@ class ServiceWorkerProviderContextTest : public testing::Test {
const GURL& url) {
network::ResourceRequest request;
request.url = url;
request.resource_type =
static_cast<int>(blink::mojom::ResourceType::kSubResource);
request.destination = network::mojom::RequestDestination::kEmpty;
mojo::PendingRemote<network::mojom::URLLoader> loader;
network::TestURLLoaderClient loader_client;
factory->CreateLoaderAndStart(
......@@ -829,8 +828,7 @@ TEST_F(ServiceWorkerProviderContextTest,
network::ResourceRequest request;
request.url = GURL("https://www.example.com/random.js");
request.resource_type =
static_cast<int>(blink::mojom::ResourceType::kSubResource);
request.destination = network::mojom::RequestDestination::kEmpty;
mojo::PendingRemote<network::mojom::URLLoader> loader;
network::TestURLLoaderClient loader_client;
wrapped_loader_factory->CreateLoaderAndStart(
......
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