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

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

Issue 1867293004: Set service worker response info data for foreign fetch intercepted fetches. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ff-check-origin
Patch Set: address comment Created 4 years, 8 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"
11 #include "content/browser/service_worker/service_worker_response_info.h"
11 #include "content/browser/service_worker/service_worker_url_request_job.h" 12 #include "content/browser/service_worker/service_worker_url_request_job.h"
12 #include "content/common/resource_request_body.h" 13 #include "content/common/resource_request_body.h"
13 #include "content/common/service_worker/service_worker_utils.h" 14 #include "content/common/service_worker/service_worker_utils.h"
14 #include "net/url_request/url_request.h" 15 #include "net/url_request/url_request.h"
15 #include "net/url_request/url_request_interceptor.h" 16 #include "net/url_request/url_request_interceptor.h"
16 #include "storage/browser/blob/blob_storage_context.h" 17 #include "storage/browser/blob/blob_storage_context.h"
17 18
18 namespace content { 19 namespace content {
19 20
20 namespace { 21 namespace {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 new ForeignFetchRequestInterceptor(resource_context)); 96 new ForeignFetchRequestInterceptor(resource_context));
96 } 97 }
97 98
98 ForeignFetchRequestHandler::~ForeignFetchRequestHandler() {} 99 ForeignFetchRequestHandler::~ForeignFetchRequestHandler() {}
99 100
100 net::URLRequestJob* ForeignFetchRequestHandler::MaybeCreateJob( 101 net::URLRequestJob* ForeignFetchRequestHandler::MaybeCreateJob(
101 net::URLRequest* request, 102 net::URLRequest* request,
102 net::NetworkDelegate* network_delegate, 103 net::NetworkDelegate* network_delegate,
103 ResourceContext* resource_context) { 104 ResourceContext* resource_context) {
104 ClearJob(); 105 ClearJob();
106 ServiceWorkerResponseInfo::ResetDataForRequest(request);
105 107
106 if (!context_) { 108 if (!context_) {
107 // We can't do anything other than to fall back to network. 109 // We can't do anything other than to fall back to network.
108 job_.reset(); 110 job_.reset();
109 return nullptr; 111 return nullptr;
110 } 112 }
111 113
112 // This may get called multiple times for original and redirect requests: 114 // This may get called multiple times for original and redirect requests:
113 // A. original request case: use_network_ is false, no previous location info. 115 // A. original request case: use_network_ is false, no previous location info.
114 // B. redirect or restarted request case: 116 // B. redirect or restarted request case:
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 199
198 if (!scope_matches || !origin_matches) { 200 if (!scope_matches || !origin_matches) {
199 job->FallbackToNetwork(); 201 job->FallbackToNetwork();
200 return; 202 return;
201 } 203 }
202 204
203 target_worker_ = active_version; 205 target_worker_ = active_version;
204 job->ForwardToServiceWorker(); 206 job->ForwardToServiceWorker();
205 } 207 }
206 208
207 void ForeignFetchRequestHandler::OnPrepareToRestart( 209 void ForeignFetchRequestHandler::OnPrepareToRestart() {
208 base::TimeTicks service_worker_start_time,
209 base::TimeTicks service_worker_ready_time) {
210 use_network_ = true; 210 use_network_ = true;
211 ClearJob(); 211 ClearJob();
212 } 212 }
213 213
214 void ForeignFetchRequestHandler::OnStartCompleted(
215 bool was_fetched_via_service_worker,
216 bool was_fallback_required,
217 const GURL& original_url_via_service_worker,
218 blink::WebServiceWorkerResponseType response_type_via_service_worker,
219 base::TimeTicks service_worker_start_time,
220 base::TimeTicks service_worker_ready_time,
221 bool response_is_in_cache_storage,
222 const std::string& response_cache_storage_cache_name) {}
223
224 ServiceWorkerVersion* ForeignFetchRequestHandler::GetServiceWorkerVersion( 214 ServiceWorkerVersion* ForeignFetchRequestHandler::GetServiceWorkerVersion(
225 ServiceWorkerMetrics::URLRequestJobResult* result) { 215 ServiceWorkerMetrics::URLRequestJobResult* result) {
226 // TODO(mek): Figure out what should happen if the active worker changes or 216 // TODO(mek): Figure out what should happen if the active worker changes or
227 // gets uninstalled before this point is reached. 217 // gets uninstalled before this point is reached.
228 if (!target_worker_) { 218 if (!target_worker_) {
229 *result = ServiceWorkerMetrics::REQUEST_JOB_ERROR_NO_ACTIVE_VERSION; 219 *result = ServiceWorkerMetrics::REQUEST_JOB_ERROR_NO_ACTIVE_VERSION;
230 return nullptr; 220 return nullptr;
231 } 221 }
232 return target_worker_.get(); 222 return target_worker_.get();
233 } 223 }
234 224
235 void ForeignFetchRequestHandler::ClearJob() { 225 void ForeignFetchRequestHandler::ClearJob() {
236 job_.reset(); 226 job_.reset();
237 target_worker_ = nullptr; 227 target_worker_ = nullptr;
238 } 228 }
239 229
240 } // namespace content 230 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698