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

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

Issue 2941883003: [ServiceWorker] Fetch event should return integrity value (Closed)
Patch Set: Rebase and address shimazu and yhirano's comments Created 3 years, 5 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/service_worker_request_handler.h" 5 #include "content/browser/service_worker/service_worker_request_handler.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 93
94 // Initialize the SWProviderHost. 94 // Initialize the SWProviderHost.
95 std::unique_ptr<ServiceWorkerProviderHost> provider_host = 95 std::unique_ptr<ServiceWorkerProviderHost> provider_host =
96 ServiceWorkerProviderHost::PreCreateNavigationHost( 96 ServiceWorkerProviderHost::PreCreateNavigationHost(
97 navigation_handle_core->context_wrapper()->context()->AsWeakPtr(), 97 navigation_handle_core->context_wrapper()->context()->AsWeakPtr(),
98 is_parent_frame_secure, web_contents_getter); 98 is_parent_frame_secure, web_contents_getter);
99 99
100 std::unique_ptr<ServiceWorkerRequestHandler> handler( 100 std::unique_ptr<ServiceWorkerRequestHandler> handler(
101 provider_host->CreateRequestHandler( 101 provider_host->CreateRequestHandler(
102 FETCH_REQUEST_MODE_NAVIGATE, FETCH_CREDENTIALS_MODE_INCLUDE, 102 FETCH_REQUEST_MODE_NAVIGATE, FETCH_CREDENTIALS_MODE_INCLUDE,
103 FetchRedirectMode::MANUAL_MODE, resource_type, request_context_type, 103 FetchRedirectMode::MANUAL_MODE, "" /*integrity*/, resource_type,
shimazu 2017/07/06 07:47:06 Just confirmation; Is this okay to pass a blank st
xiaofengzhang 2017/07/06 08:00:25 maybe its safe to use std::string()?
shimazu 2017/07/06 08:14:23 Ah, sorry, my question was to confirm if just pass
104 frame_type, blob_storage_context->AsWeakPtr(), body, 104 request_context_type, frame_type, blob_storage_context->AsWeakPtr(),
105 skip_service_worker)); 105 body, skip_service_worker));
106 if (handler) 106 if (handler)
107 request->SetUserData(&kUserDataKey, std::move(handler)); 107 request->SetUserData(&kUserDataKey, std::move(handler));
108 108
109 // Transfer ownership to the ServiceWorkerNavigationHandleCore. 109 // Transfer ownership to the ServiceWorkerNavigationHandleCore.
110 // In the case of a successful navigation, the SWProviderHost will be 110 // In the case of a successful navigation, the SWProviderHost will be
111 // transferred to its "final" destination in the OnProviderCreated handler. If 111 // transferred to its "final" destination in the OnProviderCreated handler. If
112 // the navigation fails, it will be destroyed along with the 112 // the navigation fails, it will be destroyed along with the
113 // ServiceWorkerNavigationHandleCore. 113 // ServiceWorkerNavigationHandleCore.
114 navigation_handle_core->DidPreCreateProviderHost(std::move(provider_host)); 114 navigation_handle_core->DidPreCreateProviderHost(std::move(provider_host));
115 } 115 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 148
149 // Initialize the SWProviderHost. 149 // Initialize the SWProviderHost.
150 std::unique_ptr<ServiceWorkerProviderHost> provider_host = 150 std::unique_ptr<ServiceWorkerProviderHost> provider_host =
151 ServiceWorkerProviderHost::PreCreateNavigationHost( 151 ServiceWorkerProviderHost::PreCreateNavigationHost(
152 navigation_handle_core->context_wrapper()->context()->AsWeakPtr(), 152 navigation_handle_core->context_wrapper()->context()->AsWeakPtr(),
153 is_parent_frame_secure, web_contents_getter); 153 is_parent_frame_secure, web_contents_getter);
154 154
155 std::unique_ptr<ServiceWorkerRequestHandler> handler( 155 std::unique_ptr<ServiceWorkerRequestHandler> handler(
156 provider_host->CreateRequestHandler( 156 provider_host->CreateRequestHandler(
157 FETCH_REQUEST_MODE_NAVIGATE, FETCH_CREDENTIALS_MODE_INCLUDE, 157 FETCH_REQUEST_MODE_NAVIGATE, FETCH_CREDENTIALS_MODE_INCLUDE,
158 FetchRedirectMode::MANUAL_MODE, resource_type, request_context_type, 158 FetchRedirectMode::MANUAL_MODE, "" /*integrity*/, resource_type,
159 frame_type, blob_storage_context->AsWeakPtr(), body, 159 request_context_type, frame_type, blob_storage_context->AsWeakPtr(),
160 skip_service_worker)); 160 body, skip_service_worker));
161 161
162 // Transfer ownership to the ServiceWorkerNavigationHandleCore. 162 // Transfer ownership to the ServiceWorkerNavigationHandleCore.
163 // In the case of a successful navigation, the SWProviderHost will be 163 // In the case of a successful navigation, the SWProviderHost will be
164 // transferred to its "final" destination in the OnProviderCreated handler. If 164 // transferred to its "final" destination in the OnProviderCreated handler. If
165 // the navigation fails, it will be destroyed along with the 165 // the navigation fails, it will be destroyed along with the
166 // ServiceWorkerNavigationHandleCore. 166 // ServiceWorkerNavigationHandleCore.
167 navigation_handle_core->DidPreCreateProviderHost(std::move(provider_host)); 167 navigation_handle_core->DidPreCreateProviderHost(std::move(provider_host));
168 168
169 return base::WrapUnique<URLLoaderRequestHandler>(handler.release()); 169 return base::WrapUnique<URLLoaderRequestHandler>(handler.release());
170 } 170 }
171 171
172 void ServiceWorkerRequestHandler::InitializeHandler( 172 void ServiceWorkerRequestHandler::InitializeHandler(
173 net::URLRequest* request, 173 net::URLRequest* request,
174 ServiceWorkerContextWrapper* context_wrapper, 174 ServiceWorkerContextWrapper* context_wrapper,
175 storage::BlobStorageContext* blob_storage_context, 175 storage::BlobStorageContext* blob_storage_context,
176 int process_id, 176 int process_id,
177 int provider_id, 177 int provider_id,
178 bool skip_service_worker, 178 bool skip_service_worker,
179 FetchRequestMode request_mode, 179 FetchRequestMode request_mode,
180 FetchCredentialsMode credentials_mode, 180 FetchCredentialsMode credentials_mode,
181 FetchRedirectMode redirect_mode, 181 FetchRedirectMode redirect_mode,
182 const std::string& integrity,
182 ResourceType resource_type, 183 ResourceType resource_type,
183 RequestContextType request_context_type, 184 RequestContextType request_context_type,
184 RequestContextFrameType frame_type, 185 RequestContextFrameType frame_type,
185 scoped_refptr<ResourceRequestBodyImpl> body) { 186 scoped_refptr<ResourceRequestBodyImpl> body) {
186 // Create the handler even for insecure HTTP since it's used in the 187 // Create the handler even for insecure HTTP since it's used in the
187 // case of redirect to HTTPS. 188 // case of redirect to HTTPS.
188 if (!request->url().SchemeIsHTTPOrHTTPS() && 189 if (!request->url().SchemeIsHTTPOrHTTPS() &&
189 !OriginCanAccessServiceWorkers(request->url())) { 190 !OriginCanAccessServiceWorkers(request->url())) {
190 return; 191 return;
191 } 192 }
192 193
193 if (!context_wrapper || !context_wrapper->context() || 194 if (!context_wrapper || !context_wrapper->context() ||
194 provider_id == kInvalidServiceWorkerProviderId) { 195 provider_id == kInvalidServiceWorkerProviderId) {
195 return; 196 return;
196 } 197 }
197 198
198 ServiceWorkerProviderHost* provider_host = 199 ServiceWorkerProviderHost* provider_host =
199 context_wrapper->context()->GetProviderHost(process_id, provider_id); 200 context_wrapper->context()->GetProviderHost(process_id, provider_id);
200 if (!provider_host || !provider_host->IsContextAlive()) 201 if (!provider_host || !provider_host->IsContextAlive())
201 return; 202 return;
202 203
203 std::unique_ptr<ServiceWorkerRequestHandler> handler( 204 std::unique_ptr<ServiceWorkerRequestHandler> handler(
204 provider_host->CreateRequestHandler( 205 provider_host->CreateRequestHandler(
205 request_mode, credentials_mode, redirect_mode, resource_type, 206 request_mode, credentials_mode, redirect_mode, integrity,
206 request_context_type, frame_type, blob_storage_context->AsWeakPtr(), 207 resource_type, request_context_type, frame_type,
207 body, skip_service_worker)); 208 blob_storage_context->AsWeakPtr(), body, skip_service_worker));
208 if (handler) 209 if (handler)
209 request->SetUserData(&kUserDataKey, std::move(handler)); 210 request->SetUserData(&kUserDataKey, std::move(handler));
210 } 211 }
211 212
212 ServiceWorkerRequestHandler* ServiceWorkerRequestHandler::GetHandler( 213 ServiceWorkerRequestHandler* ServiceWorkerRequestHandler::GetHandler(
213 const net::URLRequest* request) { 214 const net::URLRequest* request) {
214 return static_cast<ServiceWorkerRequestHandler*>( 215 return static_cast<ServiceWorkerRequestHandler*>(
215 request->GetUserData(&kUserDataKey)); 216 request->GetUserData(&kUserDataKey));
216 } 217 }
217 218
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 ResourceType resource_type) 296 ResourceType resource_type)
296 : context_(context), 297 : context_(context),
297 provider_host_(provider_host), 298 provider_host_(provider_host),
298 blob_storage_context_(blob_storage_context), 299 blob_storage_context_(blob_storage_context),
299 resource_type_(resource_type), 300 resource_type_(resource_type),
300 old_process_id_(0), 301 old_process_id_(0),
301 old_provider_id_(kInvalidServiceWorkerProviderId) { 302 old_provider_id_(kInvalidServiceWorkerProviderId) {
302 } 303 }
303 304
304 } // namespace content 305 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698