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

Unified Diff: content/browser/service_worker/foreign_fetch_request_handler.cc

Issue 2405483002: Make the request initiator Optional (Closed)
Patch Set: Rewrite using base::Optional Created 4 years, 2 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: content/browser/service_worker/foreign_fetch_request_handler.cc
diff --git a/content/browser/service_worker/foreign_fetch_request_handler.cc b/content/browser/service_worker/foreign_fetch_request_handler.cc
index f3437802e4c54618a9d751d33adb8f3f6e4e5689..e69ef5ae29aeefbda52146a5d7f26e1ae5caf006 100644
--- a/content/browser/service_worker/foreign_fetch_request_handler.cc
+++ b/content/browser/service_worker/foreign_fetch_request_handler.cc
@@ -92,8 +92,10 @@ void ForeignFetchRequestHandler::InitializeHandler(
if (ServiceWorkerUtils::IsMainResourceType(resource_type))
return;
- if (request->initiator().IsSameOriginWith(url::Origin(request->url())))
+ if (!request->initiator().has_value() ||
+ request->initiator()->IsSameOriginWith(url::Origin(request->url()))) {
return;
+ }
if (!context_wrapper->OriginHasForeignFetchRegistrations(
request->url().GetOrigin())) {
@@ -218,7 +220,7 @@ void ForeignFetchRequestHandler::DidFindRegistration(
}
}
- const url::Origin& request_origin = job->request()->initiator();
+ const url::Origin& request_origin = job->request()->initiator().value();
bool origin_matches = active_version->foreign_fetch_origins().empty();
for (const url::Origin& origin : active_version->foreign_fetch_origins()) {
if (request_origin.IsSameOriginWith(origin))

Powered by Google App Engine
This is Rietveld 408576698