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

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

Issue 588153002: [ServiceWorker] Plumbing the request mode from the renderer to the ServiceWorker. [2/2 chromium] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix compile error 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/resource_messages.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"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "content/child/ftp_directory_listing_response_delegate.h" 15 #include "content/child/ftp_directory_listing_response_delegate.h"
16 #include "content/child/multipart_response_delegate.h" 16 #include "content/child/multipart_response_delegate.h"
17 #include "content/child/request_extra_data.h" 17 #include "content/child/request_extra_data.h"
18 #include "content/child/request_info.h" 18 #include "content/child/request_info.h"
19 #include "content/child/resource_dispatcher.h" 19 #include "content/child/resource_dispatcher.h"
20 #include "content/child/resource_loader_bridge.h" 20 #include "content/child/resource_loader_bridge.h"
21 #include "content/child/sync_load_response.h" 21 #include "content/child/sync_load_response.h"
22 #include "content/child/web_url_request_util.h" 22 #include "content/child/web_url_request_util.h"
23 #include "content/child/weburlresponse_extradata_impl.h" 23 #include "content/child/weburlresponse_extradata_impl.h"
24 #include "content/common/resource_request_body.h" 24 #include "content/common/resource_request_body.h"
25 #include "content/common/service_worker/service_worker_types.h"
25 #include "content/public/child/request_peer.h" 26 #include "content/public/child/request_peer.h"
26 #include "net/base/data_url.h" 27 #include "net/base/data_url.h"
27 #include "net/base/filename_util.h" 28 #include "net/base/filename_util.h"
28 #include "net/base/load_flags.h" 29 #include "net/base/load_flags.h"
29 #include "net/base/mime_util.h" 30 #include "net/base/mime_util.h"
30 #include "net/base/net_errors.h" 31 #include "net/base/net_errors.h"
31 #include "net/http/http_response_headers.h" 32 #include "net/http/http_response_headers.h"
32 #include "net/http/http_util.h" 33 #include "net/http/http_util.h"
33 #include "net/url_request/redirect_info.h" 34 #include "net/url_request/redirect_info.h"
34 #include "net/url_request/url_request_data_job.h" 35 #include "net/url_request/url_request_data_job.h"
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 info->headers = headers; 193 info->headers = headers;
193 info->mime_type.swap(mime_type); 194 info->mime_type.swap(mime_type);
194 info->charset.swap(charset); 195 info->charset.swap(charset);
195 info->security_info.clear(); 196 info->security_info.clear();
196 info->content_length = data->length(); 197 info->content_length = data->length();
197 info->encoded_data_length = 0; 198 info->encoded_data_length = 0;
198 199
199 return net::OK; 200 return net::OK;
200 } 201 }
201 202
203 #define COMPILE_ASSERT_MATCHING_ENUMS(content_name, blink_name) \
204 COMPILE_ASSERT( \
205 static_cast<int>(content_name) == static_cast<int>(blink_name), \
206 mismatching_enums)
207
208 COMPILE_ASSERT_MATCHING_ENUMS(FETCH_REQUEST_MODE_SAME_ORIGIN,
209 WebURLRequest::FetchRequestModeSameOrigin);
210 COMPILE_ASSERT_MATCHING_ENUMS(FETCH_REQUEST_MODE_NO_CORS,
211 WebURLRequest::FetchRequestModeNoCORS);
212 COMPILE_ASSERT_MATCHING_ENUMS(FETCH_REQUEST_MODE_CORS,
213 WebURLRequest::FetchRequestModeCORS);
214 COMPILE_ASSERT_MATCHING_ENUMS(
215 FETCH_REQUEST_MODE_CORS_WITH_FORCED_PREFLIGHT,
216 WebURLRequest::FetchRequestModeCORSWithForcedPreflight);
217
218 FetchRequestMode GetFetchRequestMode(const WebURLRequest& request) {
219 return static_cast<FetchRequestMode>(request.fetchRequestMode());
220 }
221
202 } // namespace 222 } // namespace
203 223
204 // WebURLLoaderImpl::Context -------------------------------------------------- 224 // WebURLLoaderImpl::Context --------------------------------------------------
205 225
206 // This inner class exists since the WebURLLoader may be deleted while inside a 226 // This inner class exists since the WebURLLoader may be deleted while inside a
207 // call to WebURLLoaderClient. Refcounting is to keep the context from being 227 // call to WebURLLoaderClient. Refcounting is to keep the context from being
208 // deleted if it may have work to do after calling into the client. 228 // deleted if it may have work to do after calling into the client.
209 class WebURLLoaderImpl::Context : public base::RefCounted<Context>, 229 class WebURLLoaderImpl::Context : public base::RefCounted<Context>,
210 public RequestPeer { 230 public RequestPeer {
211 public: 231 public:
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 // from in-process plugins. 410 // from in-process plugins.
391 request_info.requestor_pid = request.requestorProcessID(); 411 request_info.requestor_pid = request.requestorProcessID();
392 request_info.request_type = WebURLRequestToResourceType(request); 412 request_info.request_type = WebURLRequestToResourceType(request);
393 request_info.priority = 413 request_info.priority =
394 ConvertWebKitPriorityToNetPriority(request.priority()); 414 ConvertWebKitPriorityToNetPriority(request.priority());
395 request_info.appcache_host_id = request.appCacheHostID(); 415 request_info.appcache_host_id = request.appCacheHostID();
396 request_info.routing_id = request.requestorID(); 416 request_info.routing_id = request.requestorID();
397 request_info.download_to_file = request.downloadToFile(); 417 request_info.download_to_file = request.downloadToFile();
398 request_info.has_user_gesture = request.hasUserGesture(); 418 request_info.has_user_gesture = request.hasUserGesture();
399 request_info.skip_service_worker = request.skipServiceWorker(); 419 request_info.skip_service_worker = request.skipServiceWorker();
420 request_info.fetch_request_mode = GetFetchRequestMode(request);
400 request_info.extra_data = request.extraData(); 421 request_info.extra_data = request.extraData();
401 referrer_policy_ = request.referrerPolicy(); 422 referrer_policy_ = request.referrerPolicy();
402 request_info.referrer_policy = request.referrerPolicy(); 423 request_info.referrer_policy = request.referrerPolicy();
403 bridge_.reset(resource_dispatcher_->CreateBridge(request_info)); 424 bridge_.reset(resource_dispatcher_->CreateBridge(request_info));
404 425
405 if (!request.httpBody().isNull()) { 426 if (!request.httpBody().isNull()) {
406 // GET and HEAD requests shouldn't have http bodies. 427 // GET and HEAD requests shouldn't have http bodies.
407 DCHECK(method != "GET" && method != "HEAD"); 428 DCHECK(method != "GET" && method != "HEAD");
408 const WebHTTPBody& httpBody = request.httpBody(); 429 const WebHTTPBody& httpBody = request.httpBody();
409 size_t i = 0; 430 size_t i = 0;
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 int intra_priority_value) { 926 int intra_priority_value) {
906 context_->DidChangePriority(new_priority, intra_priority_value); 927 context_->DidChangePriority(new_priority, intra_priority_value);
907 } 928 }
908 929
909 bool WebURLLoaderImpl::attachThreadedDataReceiver( 930 bool WebURLLoaderImpl::attachThreadedDataReceiver(
910 blink::WebThreadedDataReceiver* threaded_data_receiver) { 931 blink::WebThreadedDataReceiver* threaded_data_receiver) {
911 return context_->AttachThreadedDataReceiver(threaded_data_receiver); 932 return context_->AttachThreadedDataReceiver(threaded_data_receiver);
912 } 933 }
913 934
914 } // namespace content 935 } // namespace content
OLDNEW
« no previous file with comments | « content/child/resource_dispatcher.cc ('k') | content/common/resource_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698