Commit e816a9ac authored by Matt Falkenhagen's avatar Matt Falkenhagen Committed by Commit Bot

service worker: Remove SetSiteForCookies().

Make callers use UpdateURLs instead.

Bug: 908311
Change-Id: I1689c8670dc2c03f325500be24dcdde9a88586a0
Reviewed-on: https://chromium-review.googlesource.com/c/1350419
Commit-Queue: Matt Falkenhagen <falken@chromium.org>
Reviewed-by: default avatarMakoto Shimazu <shimazu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610780}
parent ecfee12e
......@@ -89,8 +89,7 @@ class ServiceWorkerURLTrackingRequestHandler
if (!provider_host_)
return nullptr;
const GURL stripped_url = net::SimplifyUrlForRequest(request->url());
provider_host_->SetDocumentUrl(stripped_url);
provider_host_->SetSiteForCookies(request->site_for_cookies());
provider_host_->UpdateURLs(stripped_url, request->site_for_cookies());
return nullptr;
}
......@@ -104,9 +103,8 @@ class ServiceWorkerURLTrackingRequestHandler
return;
const GURL stripped_url =
net::SimplifyUrlForRequest(tentative_resource_request.url);
provider_host_->SetDocumentUrl(stripped_url);
provider_host_->SetSiteForCookies(
tentative_resource_request.site_for_cookies);
provider_host_->UpdateURLs(stripped_url,
tentative_resource_request.site_for_cookies);
// Fall back to network.
std::move(callback).Run({});
}
......@@ -460,9 +458,10 @@ ServiceWorkerProviderHost::GetControllerServiceWorkerPtr() {
void ServiceWorkerProviderHost::UpdateURLs(const GURL& document_url,
const GURL& site_for_cookies) {
DCHECK(IsProviderForClient());
GURL previous_url = document_url_;
SetDocumentUrl(document_url);
SetSiteForCookies(site_for_cookies);
site_for_cookies_ = site_for_cookies;
auto current_origin = url::Origin::Create(previous_url);
auto new_origin = url::Origin::Create(document_url_);
// Update client id on cross origin redirects. This corresponds to the HTML
......@@ -507,11 +506,6 @@ void ServiceWorkerProviderHost::SetDocumentUrl(const GURL& url) {
SyncMatchingRegistrations();
}
void ServiceWorkerProviderHost::SetSiteForCookies(const GURL& url) {
DCHECK(IsProviderForClient());
site_for_cookies_ = url;
}
const GURL& ServiceWorkerProviderHost::site_for_cookies() const {
if (IsProviderForClient())
return site_for_cookies_;
......
......@@ -290,10 +290,8 @@ class CONTENT_EXPORT ServiceWorkerProviderHost
// The URL representing the first-party site for this context. See
// |network::ResourceRequest::site_for_cookies| for details.
// SetSiteForCookies() can only be called if |this| is for a service worker
// client. For service worker execution contexts, site_for_cookies() always
// For service worker execution contexts, site_for_cookies() always
// returns the service worker script URL.
void SetSiteForCookies(const GURL& url);
const GURL& site_for_cookies() const;
blink::mojom::ServiceWorkerProviderType provider_type() const {
......
......@@ -173,8 +173,8 @@ class ServiceWorkerProviderHostTest : public testing::TestWithParam<bool> {
void FinishNavigation(ServiceWorkerProviderHost* host,
mojom::ServiceWorkerProviderHostInfoPtr info) {
// In production code, the loader/request handler does this.
host->SetDocumentUrl(GURL("https://www.example.com/page"));
host->SetSiteForCookies(GURL("https://www.example.com/page"));
const GURL url("https://www.example.com/page");
host->UpdateURLs(url, url);
// In production code, the OnProviderCreated IPC is received which
// does this.
......@@ -308,8 +308,7 @@ class ServiceWorkerProviderHostTest : public testing::TestWithParam<bool> {
host->CompleteNavigationInitialized(helper_->mock_render_process_id(),
std::move(info));
host->SetDocumentUrl(document_url);
host->SetSiteForCookies(site_for_cookies);
host->UpdateURLs(document_url, site_for_cookies);
return host.get();
}
......@@ -884,7 +883,7 @@ TEST_P(ServiceWorkerProviderHostTest,
context_->AsWeakPtr(), helper_->mock_render_process_id(),
&provider_info);
const GURL url("https://www.example.com/shared_worker.js");
host->SetSiteForCookies(url);
host->UpdateURLs(url, url);
EXPECT_FALSE(CanFindClientProviderHost(host.get()));
host->CompleteSharedWorkerPreparation();
EXPECT_TRUE(CanFindClientProviderHost(host.get()));
......
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