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

Side by Side Diff: content/browser/service_worker/service_worker_url_request_job.h

Issue 2108573002: ServiceWorker: Add an API to fallback to renderer for CORS preflight (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 void OnStreamRegistered(Stream* stream) override; 149 void OnStreamRegistered(Stream* stream) override;
150 150
151 base::WeakPtr<ServiceWorkerURLRequestJob> GetWeakPtr(); 151 base::WeakPtr<ServiceWorkerURLRequestJob> GetWeakPtr();
152 152
153 private: 153 private:
154 class BlobConstructionWaiter; 154 class BlobConstructionWaiter;
155 155
156 enum ResponseType { 156 enum ResponseType {
157 NOT_DETERMINED, 157 NOT_DETERMINED,
158 FALLBACK_TO_NETWORK, 158 FALLBACK_TO_NETWORK,
159 FALLBACK_TO_RENDERER, // Use this when falling back with CORS check
159 FORWARD_TO_SERVICE_WORKER, 160 FORWARD_TO_SERVICE_WORKER,
160 }; 161 };
161 162
162 enum ResponseBodyType { 163 enum ResponseBodyType {
163 UNKNOWN, 164 UNKNOWN,
164 BLOB, 165 BLOB,
165 STREAM, 166 STREAM,
166 }; 167 };
167 168
168 // We start processing the request if Start() is called AND response_type_ 169 // We start processing the request if Start() is called AND response_type_
(...skipping 23 matching lines...) Expand all
192 const std::string& status_text, 193 const std::string& status_text,
193 const ServiceWorkerHeaderMap& headers); 194 const ServiceWorkerHeaderMap& headers);
194 195
195 // Creates |http_response_info_| using |http_response_headers_| and calls 196 // Creates |http_response_info_| using |http_response_headers_| and calls
196 // NotifyHeadersComplete. 197 // NotifyHeadersComplete.
197 void CommitResponseHeader(); 198 void CommitResponseHeader();
198 199
199 // Creates and commits a response header indicating error. 200 // Creates and commits a response header indicating error.
200 void DeliverErrorResponse(); 201 void DeliverErrorResponse();
201 202
203 // Restarts this job to fallback to network.
204 // This can be called after StartRequest.
205 void FinalizeToFallbackToNetwork();
206
207 // Sends back a response with fall_back_required set as true to trigger
208 // subsequent network requests with CORS checking.
209 // This can be called after StartRequest.
210 void FinalizeToFallbackToRenderer();
211
212 // true if need to send back a response with fall_back_required set as true to
213 // trigger subsequent network requests with CORS checking.
214 bool IsNeedToFallbackToRenderer();
horo 2016/06/29 05:31:35 nit: const
shimazu 2016/07/04 06:31:11 Done.
215
202 // For UMA. 216 // For UMA.
203 void SetResponseBodyType(ResponseBodyType type); 217 void SetResponseBodyType(ResponseBodyType type);
204 bool ShouldRecordResult(); 218 bool ShouldRecordResult();
205 void RecordResult(ServiceWorkerMetrics::URLRequestJobResult result); 219 void RecordResult(ServiceWorkerMetrics::URLRequestJobResult result);
206 void RecordStatusZeroResponseError( 220 void RecordStatusZeroResponseError(
207 blink::WebServiceWorkerResponseError error); 221 blink::WebServiceWorkerResponseError error);
208 222
209 // Releases the resources for streaming. 223 // Releases the resources for streaming.
210 void ClearStream(); 224 void ClearStream();
211 225
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 EmbeddedWorkerStatus initial_worker_status_ = EmbeddedWorkerStatus::STOPPED; 299 EmbeddedWorkerStatus initial_worker_status_ = EmbeddedWorkerStatus::STOPPED;
286 300
287 base::WeakPtrFactory<ServiceWorkerURLRequestJob> weak_factory_; 301 base::WeakPtrFactory<ServiceWorkerURLRequestJob> weak_factory_;
288 302
289 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerURLRequestJob); 303 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerURLRequestJob);
290 }; 304 };
291 305
292 } // namespace content 306 } // namespace content
293 307
294 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_ 308 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698