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

Side by Side Diff: content/browser/service_worker/foreign_fetch_request_handler.cc

Issue 2019613003: ServiceWorker: Bypass SW when the script doesn't have fetch handler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/service_worker/foreign_fetch_request_handler.h" 5 #include "content/browser/service_worker/foreign_fetch_request_handler.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "content/browser/service_worker/service_worker_context_wrapper.h" 10 #include "content/browser/service_worker/service_worker_context_wrapper.h"
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 } 190 }
191 } 191 }
192 192
193 const url::Origin& request_origin = job->request()->initiator(); 193 const url::Origin& request_origin = job->request()->initiator();
194 bool origin_matches = active_version->foreign_fetch_origins().empty(); 194 bool origin_matches = active_version->foreign_fetch_origins().empty();
195 for (const url::Origin& origin : active_version->foreign_fetch_origins()) { 195 for (const url::Origin& origin : active_version->foreign_fetch_origins()) {
196 if (request_origin.IsSameOriginWith(origin)) 196 if (request_origin.IsSameOriginWith(origin))
197 origin_matches = true; 197 origin_matches = true;
198 } 198 }
199 199
200 if (!scope_matches || !origin_matches) { 200 if (!scope_matches || !origin_matches ||
201 !active_version->has_fetch_handler()) {
Marijn Kruisselbrink 2016/05/27 16:18:12 This is probably not correct. Foreign fetch events
shimazu 2016/05/30 05:41:59 Sorry, it's true! Done.
201 job->FallbackToNetwork(); 202 job->FallbackToNetwork();
202 return; 203 return;
203 } 204 }
204 205
205 target_worker_ = active_version; 206 target_worker_ = active_version;
206 job->ForwardToServiceWorker(); 207 job->ForwardToServiceWorker();
207 } 208 }
208 209
209 void ForeignFetchRequestHandler::OnPrepareToRestart() { 210 void ForeignFetchRequestHandler::OnPrepareToRestart() {
210 use_network_ = true; 211 use_network_ = true;
(...skipping 10 matching lines...) Expand all
221 } 222 }
222 return target_worker_.get(); 223 return target_worker_.get();
223 } 224 }
224 225
225 void ForeignFetchRequestHandler::ClearJob() { 226 void ForeignFetchRequestHandler::ClearJob() {
226 job_.reset(); 227 job_.reset();
227 target_worker_ = nullptr; 228 target_worker_ = nullptr;
228 } 229 }
229 230
230 } // namespace content 231 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698