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

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

Issue 2038813003: Making ResourceRequestBody part of //content's public API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing... 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 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/macros.h" 10 #include "base/macros.h"
11 #include "content/browser/service_worker/service_worker_context_core.h" 11 #include "content/browser/service_worker/service_worker_context_core.h"
12 #include "content/browser/service_worker/service_worker_context_wrapper.h" 12 #include "content/browser/service_worker/service_worker_context_wrapper.h"
13 #include "content/browser/service_worker/service_worker_navigation_handle_core.h " 13 #include "content/browser/service_worker/service_worker_navigation_handle_core.h "
14 #include "content/browser/service_worker/service_worker_provider_host.h" 14 #include "content/browser/service_worker/service_worker_provider_host.h"
15 #include "content/browser/service_worker/service_worker_registration.h" 15 #include "content/browser/service_worker/service_worker_registration.h"
16 #include "content/browser/service_worker/service_worker_url_request_job.h" 16 #include "content/browser/service_worker/service_worker_url_request_job.h"
17 #include "content/common/resource_request_body.h" 17 #include "content/common/resource_request_body_impl.h"
18 #include "content/common/service_worker/service_worker_types.h" 18 #include "content/common/service_worker/service_worker_types.h"
19 #include "content/common/service_worker/service_worker_utils.h" 19 #include "content/common/service_worker/service_worker_utils.h"
20 #include "content/public/browser/resource_context.h" 20 #include "content/public/browser/resource_context.h"
21 #include "content/public/common/browser_side_navigation_policy.h" 21 #include "content/public/common/browser_side_navigation_policy.h"
22 #include "content/public/common/child_process_host.h" 22 #include "content/public/common/child_process_host.h"
23 #include "content/public/common/origin_util.h" 23 #include "content/public/common/origin_util.h"
24 #include "ipc/ipc_message.h" 24 #include "ipc/ipc_message.h"
25 #include "net/base/url_util.h" 25 #include "net/base/url_util.h"
26 #include "net/url_request/url_request.h" 26 #include "net/url_request/url_request.h"
27 #include "net/url_request/url_request_interceptor.h" 27 #include "net/url_request/url_request_interceptor.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 net::URLRequest* request, 59 net::URLRequest* request,
60 ServiceWorkerProviderHost* provider_host, 60 ServiceWorkerProviderHost* provider_host,
61 storage::BlobStorageContext* blob_storage_context, 61 storage::BlobStorageContext* blob_storage_context,
62 bool skip_service_worker, 62 bool skip_service_worker,
63 FetchRequestMode request_mode, 63 FetchRequestMode request_mode,
64 FetchCredentialsMode credentials_mode, 64 FetchCredentialsMode credentials_mode,
65 FetchRedirectMode redirect_mode, 65 FetchRedirectMode redirect_mode,
66 ResourceType resource_type, 66 ResourceType resource_type,
67 RequestContextType request_context_type, 67 RequestContextType request_context_type,
68 RequestContextFrameType frame_type, 68 RequestContextFrameType frame_type,
69 scoped_refptr<ResourceRequestBody> body) { 69 scoped_refptr<ResourceRequestBodyImpl> body) {
70 if (skip_service_worker) { 70 if (skip_service_worker) {
71 // TODO(horo): Does this work properly for PlzNavigate? 71 // TODO(horo): Does this work properly for PlzNavigate?
72 if (ServiceWorkerUtils::IsMainResourceType(resource_type)) { 72 if (ServiceWorkerUtils::IsMainResourceType(resource_type)) {
73 provider_host->SetDocumentUrl(net::SimplifyUrlForRequest(request->url())); 73 provider_host->SetDocumentUrl(net::SimplifyUrlForRequest(request->url()));
74 provider_host->SetTopmostFrameUrl(request->first_party_for_cookies()); 74 provider_host->SetTopmostFrameUrl(request->first_party_for_cookies());
75 // A page load with skip_service_worker should be triggered by 75 // A page load with skip_service_worker should be triggered by
76 // shift-reload, so retain all live matching registrations. 76 // shift-reload, so retain all live matching registrations.
77 provider_host->AddAllMatchingRegistrations(); 77 provider_host->AddAllMatchingRegistrations();
78 } 78 }
79 return; 79 return;
(...skipping 14 matching lines...) Expand all
94 94
95 // PlzNavigate 95 // PlzNavigate
96 void ServiceWorkerRequestHandler::InitializeForNavigation( 96 void ServiceWorkerRequestHandler::InitializeForNavigation(
97 net::URLRequest* request, 97 net::URLRequest* request,
98 ServiceWorkerNavigationHandleCore* navigation_handle_core, 98 ServiceWorkerNavigationHandleCore* navigation_handle_core,
99 storage::BlobStorageContext* blob_storage_context, 99 storage::BlobStorageContext* blob_storage_context,
100 bool skip_service_worker, 100 bool skip_service_worker,
101 ResourceType resource_type, 101 ResourceType resource_type,
102 RequestContextType request_context_type, 102 RequestContextType request_context_type,
103 RequestContextFrameType frame_type, 103 RequestContextFrameType frame_type,
104 scoped_refptr<ResourceRequestBody> body) { 104 scoped_refptr<ResourceRequestBodyImpl> body) {
105 CHECK(IsBrowserSideNavigationEnabled()); 105 CHECK(IsBrowserSideNavigationEnabled());
106 106
107 // Only create a handler when there is a ServiceWorkerNavigationHandlerCore 107 // Only create a handler when there is a ServiceWorkerNavigationHandlerCore
108 // to take ownership of a pre-created SeviceWorkerProviderHost. 108 // to take ownership of a pre-created SeviceWorkerProviderHost.
109 if (!navigation_handle_core) 109 if (!navigation_handle_core)
110 return; 110 return;
111 111
112 // Create the handler even for insecure HTTP since it's used in the 112 // Create the handler even for insecure HTTP since it's used in the
113 // case of redirect to HTTPS. 113 // case of redirect to HTTPS.
114 if (!request->url().SchemeIsHTTPOrHTTPS() && 114 if (!request->url().SchemeIsHTTPOrHTTPS() &&
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 storage::BlobStorageContext* blob_storage_context, 146 storage::BlobStorageContext* blob_storage_context,
147 int process_id, 147 int process_id,
148 int provider_id, 148 int provider_id,
149 bool skip_service_worker, 149 bool skip_service_worker,
150 FetchRequestMode request_mode, 150 FetchRequestMode request_mode,
151 FetchCredentialsMode credentials_mode, 151 FetchCredentialsMode credentials_mode,
152 FetchRedirectMode redirect_mode, 152 FetchRedirectMode redirect_mode,
153 ResourceType resource_type, 153 ResourceType resource_type,
154 RequestContextType request_context_type, 154 RequestContextType request_context_type,
155 RequestContextFrameType frame_type, 155 RequestContextFrameType frame_type,
156 scoped_refptr<ResourceRequestBody> body) { 156 scoped_refptr<ResourceRequestBodyImpl> body) {
157 // Create the handler even for insecure HTTP since it's used in the 157 // Create the handler even for insecure HTTP since it's used in the
158 // case of redirect to HTTPS. 158 // case of redirect to HTTPS.
159 if (!request->url().SchemeIsHTTPOrHTTPS() && 159 if (!request->url().SchemeIsHTTPOrHTTPS() &&
160 !OriginCanAccessServiceWorkers(request->url())) { 160 !OriginCanAccessServiceWorkers(request->url())) {
161 return; 161 return;
162 } 162 }
163 163
164 if (!context_wrapper || !context_wrapper->context() || 164 if (!context_wrapper || !context_wrapper->context() ||
165 provider_id == kInvalidServiceWorkerProviderId) { 165 provider_id == kInvalidServiceWorkerProviderId) {
166 return; 166 return;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 ResourceType resource_type) 249 ResourceType resource_type)
250 : context_(context), 250 : context_(context),
251 provider_host_(provider_host), 251 provider_host_(provider_host),
252 blob_storage_context_(blob_storage_context), 252 blob_storage_context_(blob_storage_context),
253 resource_type_(resource_type), 253 resource_type_(resource_type),
254 old_process_id_(0), 254 old_process_id_(0),
255 old_provider_id_(kInvalidServiceWorkerProviderId) { 255 old_provider_id_(kInvalidServiceWorkerProviderId) {
256 } 256 }
257 257
258 } // namespace content 258 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698