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

Side by Side Diff: content/child/web_url_loader_impl.cc

Issue 623663002: [ServiceWorker] pipe RequestContext and FrameType to ServiceWorker. [2/2 chromium] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: request_info.cc Created 6 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 unified diff | Download patch
« no previous file with comments | « content/child/resource_dispatcher.cc ('k') | content/common/content_param_traits_macros.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // An implementation of WebURLLoader in terms of ResourceLoaderBridge. 5 // An implementation of WebURLLoader in terms of ResourceLoaderBridge.
6 6
7 #include "content/child/web_url_loader_impl.h" 7 #include "content/child/web_url_loader_impl.h"
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 WebURLRequest::FetchCredentialsModeOmit); 223 WebURLRequest::FetchCredentialsModeOmit);
224 COMPILE_ASSERT_MATCHING_ENUMS(FETCH_CREDENTIALS_MODE_SAME_ORIGIN, 224 COMPILE_ASSERT_MATCHING_ENUMS(FETCH_CREDENTIALS_MODE_SAME_ORIGIN,
225 WebURLRequest::FetchCredentialsModeSameOrigin); 225 WebURLRequest::FetchCredentialsModeSameOrigin);
226 COMPILE_ASSERT_MATCHING_ENUMS(FETCH_CREDENTIALS_MODE_INCLUDE, 226 COMPILE_ASSERT_MATCHING_ENUMS(FETCH_CREDENTIALS_MODE_INCLUDE,
227 WebURLRequest::FetchCredentialsModeInclude); 227 WebURLRequest::FetchCredentialsModeInclude);
228 228
229 FetchCredentialsMode GetFetchCredentialsMode(const WebURLRequest& request) { 229 FetchCredentialsMode GetFetchCredentialsMode(const WebURLRequest& request) {
230 return static_cast<FetchCredentialsMode>(request.fetchCredentialsMode()); 230 return static_cast<FetchCredentialsMode>(request.fetchCredentialsMode());
231 } 231 }
232 232
233 COMPILE_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_FRAME_TYPE_AUXILIARY,
234 WebURLRequest::FrameTypeAuxiliary);
235 COMPILE_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_FRAME_TYPE_NESTED,
236 WebURLRequest::FrameTypeNested);
237 COMPILE_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_FRAME_TYPE_NONE,
238 WebURLRequest::FrameTypeNone);
239 COMPILE_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL,
240 WebURLRequest::FrameTypeTopLevel);
241
242 RequestContextFrameType GetRequestContextFrameType(
243 const WebURLRequest& request) {
244 return static_cast<RequestContextFrameType>(request.frameType());
245 }
246
247 COMPILE_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_UNSPECIFIED,
248 WebURLRequest::RequestContextUnspecified);
249 COMPILE_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_AUDIO,
250 WebURLRequest::RequestContextAudio);
251 COMPILE_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_BEACON,
252 WebURLRequest::RequestContextBeacon);
253 COMPILE_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_CSP_REPORT,
254 WebURLRequest::RequestContextCSPReport);
255 COMPILE_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_DOWNLOAD,
256 WebURLRequest::RequestContextDownload);
257 COMPILE_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_EMBED,
258 WebURLRequest::RequestContextEmbed);
259 COMPILE_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_EVENT_SOURCE,
260 WebURLRequest::RequestContextEventSource);
261 COMPILE_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_FAVICON,
262 WebURLRequest::RequestContextFavicon);
263 COMPILE_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_FETCH,
264 WebURLRequest::RequestContextFetch);
265 COMPILE_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_FONT,
266 WebURLRequest::RequestContextFont);
267 COMPILE_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_FORM,
268 WebURLRequest::RequestContextForm);
269 COMPILE_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_FRAME,
270 WebURLRequest::RequestContextFrame);
271 COMPILE_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_HYPERLINK,
272 WebURLRequest::RequestContextHyperlink);
273 COMPILE_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_IFRAME,
274 WebURLRequest::RequestContextIframe);
275 COMPILE_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_IMAGE,
276 WebURLRequest::RequestContextImage);
277 COMPILE_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_IMAGE_SET,
278 WebURLRequest::RequestContextImageSet);
279 COMPILE_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_IMPORT,
280 WebURLRequest::RequestContextImport);
281 COMPILE_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_INTERNAL,
282 WebURLRequest::RequestContextInternal);
283 COMPILE_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_LOCATION,
284 WebURLRequest::RequestContextLocation);
285 COMPILE_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_MANIFEST,
286 WebURLRequest::RequestContextManifest);
287 COMPILE_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_OBJECT,
288 WebURLRequest::RequestContextObject);
289 COMPILE_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_PING,
290 WebURLRequest::RequestContextPing);
291 COMPILE_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_PLUGIN,
292 WebURLRequest::RequestContextPlugin);
293 COMPILE_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_PREFETCH,
294 WebURLRequest::RequestContextPrefetch);
295 COMPILE_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_SCRIPT,
296 WebURLRequest::RequestContextScript);
297 COMPILE_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_SERVICE_WORKER,
298 WebURLRequest::RequestContextServiceWorker);
299 COMPILE_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_SHARED_WORKER,
300 WebURLRequest::RequestContextSharedWorker);
301 COMPILE_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_SUBRESOURCE,
302 WebURLRequest::RequestContextSubresource);
303 COMPILE_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_STYLE,
304 WebURLRequest::RequestContextStyle);
305 COMPILE_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_TRACK,
306 WebURLRequest::RequestContextTrack);
307 COMPILE_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_VIDEO,
308 WebURLRequest::RequestContextVideo);
309 COMPILE_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_WORKER,
310 WebURLRequest::RequestContextWorker);
311 COMPILE_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_XML_HTTP_REQUEST,
312 WebURLRequest::RequestContextXMLHttpRequest);
313 COMPILE_ASSERT_MATCHING_ENUMS(REQUEST_CONTEXT_TYPE_XSLT,
314 WebURLRequest::RequestContextXSLT);
315
316 RequestContextType GetRequestContextType(const WebURLRequest& request) {
317 return static_cast<RequestContextType>(request.requestContext());
318 }
319
233 } // namespace 320 } // namespace
234 321
235 // WebURLLoaderImpl::Context -------------------------------------------------- 322 // WebURLLoaderImpl::Context --------------------------------------------------
236 323
237 // This inner class exists since the WebURLLoader may be deleted while inside a 324 // This inner class exists since the WebURLLoader may be deleted while inside a
238 // call to WebURLLoaderClient. Refcounting is to keep the context from being 325 // call to WebURLLoaderClient. Refcounting is to keep the context from being
239 // deleted if it may have work to do after calling into the client. 326 // deleted if it may have work to do after calling into the client.
240 class WebURLLoaderImpl::Context : public base::RefCounted<Context>, 327 class WebURLLoaderImpl::Context : public base::RefCounted<Context>,
241 public RequestPeer { 328 public RequestPeer {
242 public: 329 public:
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 request_info.request_type = WebURLRequestToResourceType(request); 513 request_info.request_type = WebURLRequestToResourceType(request);
427 request_info.priority = 514 request_info.priority =
428 ConvertWebKitPriorityToNetPriority(request.priority()); 515 ConvertWebKitPriorityToNetPriority(request.priority());
429 request_info.appcache_host_id = request.appCacheHostID(); 516 request_info.appcache_host_id = request.appCacheHostID();
430 request_info.routing_id = request.requestorID(); 517 request_info.routing_id = request.requestorID();
431 request_info.download_to_file = request.downloadToFile(); 518 request_info.download_to_file = request.downloadToFile();
432 request_info.has_user_gesture = request.hasUserGesture(); 519 request_info.has_user_gesture = request.hasUserGesture();
433 request_info.skip_service_worker = request.skipServiceWorker(); 520 request_info.skip_service_worker = request.skipServiceWorker();
434 request_info.fetch_request_mode = GetFetchRequestMode(request); 521 request_info.fetch_request_mode = GetFetchRequestMode(request);
435 request_info.fetch_credentials_mode = GetFetchCredentialsMode(request); 522 request_info.fetch_credentials_mode = GetFetchCredentialsMode(request);
523 request_info.fetch_request_context_type = GetRequestContextType(request);
524 request_info.fetch_frame_type = GetRequestContextFrameType(request);
436 request_info.extra_data = request.extraData(); 525 request_info.extra_data = request.extraData();
437 referrer_policy_ = request.referrerPolicy(); 526 referrer_policy_ = request.referrerPolicy();
438 request_info.referrer_policy = request.referrerPolicy(); 527 request_info.referrer_policy = request.referrerPolicy();
439 bridge_.reset(resource_dispatcher_->CreateBridge(request_info)); 528 bridge_.reset(resource_dispatcher_->CreateBridge(request_info));
440 529
441 if (!request.httpBody().isNull()) { 530 if (!request.httpBody().isNull()) {
442 // GET and HEAD requests shouldn't have http bodies. 531 // GET and HEAD requests shouldn't have http bodies.
443 DCHECK(method != "GET" && method != "HEAD"); 532 DCHECK(method != "GET" && method != "HEAD");
444 const WebHTTPBody& httpBody = request.httpBody(); 533 const WebHTTPBody& httpBody = request.httpBody();
445 size_t i = 0; 534 size_t i = 0;
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 int intra_priority_value) { 1032 int intra_priority_value) {
944 context_->DidChangePriority(new_priority, intra_priority_value); 1033 context_->DidChangePriority(new_priority, intra_priority_value);
945 } 1034 }
946 1035
947 bool WebURLLoaderImpl::attachThreadedDataReceiver( 1036 bool WebURLLoaderImpl::attachThreadedDataReceiver(
948 blink::WebThreadedDataReceiver* threaded_data_receiver) { 1037 blink::WebThreadedDataReceiver* threaded_data_receiver) {
949 return context_->AttachThreadedDataReceiver(threaded_data_receiver); 1038 return context_->AttachThreadedDataReceiver(threaded_data_receiver);
950 } 1039 }
951 1040
952 } // namespace content 1041 } // namespace content
OLDNEW
« no previous file with comments | « content/child/resource_dispatcher.cc ('k') | content/common/content_param_traits_macros.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698