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