Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 97 RequestContextType request_context_type, | 97 RequestContextType request_context_type, |
| 98 RequestContextFrameType frame_type, | 98 RequestContextFrameType frame_type, |
| 99 scoped_refptr<ResourceRequestBodyImpl> body, | 99 scoped_refptr<ResourceRequestBodyImpl> body, |
| 100 ServiceWorkerFetchType fetch_type, | 100 ServiceWorkerFetchType fetch_type, |
| 101 Delegate* delegate); | 101 Delegate* delegate); |
| 102 | 102 |
| 103 ~ServiceWorkerURLRequestJob() override; | 103 ~ServiceWorkerURLRequestJob() override; |
| 104 | 104 |
| 105 // Sets the response type. | 105 // Sets the response type. |
| 106 void FallbackToNetwork(); | 106 void FallbackToNetwork(); |
| 107 void FallbackToNetworkOrRenderer(); | |
|
falken
2016/07/04 08:23:02
Please document why the caller should use ToNetwor
shimazu
2016/07/05 03:33:57
Done.
| |
| 107 void ForwardToServiceWorker(); | 108 void ForwardToServiceWorker(); |
| 108 | 109 |
| 109 bool ShouldFallbackToNetwork() const { | 110 bool ShouldFallbackToNetwork() const { |
| 110 return response_type_ == FALLBACK_TO_NETWORK; | 111 return response_type_ == FALLBACK_TO_NETWORK; |
| 111 } | 112 } |
| 112 bool ShouldForwardToServiceWorker() const { | 113 bool ShouldForwardToServiceWorker() const { |
| 113 return response_type_ == FORWARD_TO_SERVICE_WORKER; | 114 return response_type_ == FORWARD_TO_SERVICE_WORKER; |
| 114 } | 115 } |
| 115 | 116 |
| 116 // net::URLRequestJob overrides: | 117 // net::URLRequestJob overrides: |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 149 void OnStreamRegistered(Stream* stream) override; | 150 void OnStreamRegistered(Stream* stream) override; |
| 150 | 151 |
| 151 base::WeakPtr<ServiceWorkerURLRequestJob> GetWeakPtr(); | 152 base::WeakPtr<ServiceWorkerURLRequestJob> GetWeakPtr(); |
| 152 | 153 |
| 153 private: | 154 private: |
| 154 class BlobConstructionWaiter; | 155 class BlobConstructionWaiter; |
| 155 | 156 |
| 156 enum ResponseType { | 157 enum ResponseType { |
| 157 NOT_DETERMINED, | 158 NOT_DETERMINED, |
| 158 FALLBACK_TO_NETWORK, | 159 FALLBACK_TO_NETWORK, |
| 160 FALLBACK_TO_RENDERER, // Use this when falling back with CORS check | |
| 159 FORWARD_TO_SERVICE_WORKER, | 161 FORWARD_TO_SERVICE_WORKER, |
| 160 }; | 162 }; |
| 161 | 163 |
| 162 enum ResponseBodyType { | 164 enum ResponseBodyType { |
| 163 UNKNOWN, | 165 UNKNOWN, |
| 164 BLOB, | 166 BLOB, |
| 165 STREAM, | 167 STREAM, |
| 166 }; | 168 }; |
| 167 | 169 |
| 168 // We start processing the request if Start() is called AND response_type_ | 170 // We start processing the request if Start() is called AND response_type_ |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 192 const std::string& status_text, | 194 const std::string& status_text, |
| 193 const ServiceWorkerHeaderMap& headers); | 195 const ServiceWorkerHeaderMap& headers); |
| 194 | 196 |
| 195 // Creates |http_response_info_| using |http_response_headers_| and calls | 197 // Creates |http_response_info_| using |http_response_headers_| and calls |
| 196 // NotifyHeadersComplete. | 198 // NotifyHeadersComplete. |
| 197 void CommitResponseHeader(); | 199 void CommitResponseHeader(); |
| 198 | 200 |
| 199 // Creates and commits a response header indicating error. | 201 // Creates and commits a response header indicating error. |
| 200 void DeliverErrorResponse(); | 202 void DeliverErrorResponse(); |
| 201 | 203 |
| 204 // Restarts this job to fallback to network. | |
| 205 // This can be called after StartRequest. | |
| 206 void FinalizeToFallbackToNetwork(); | |
|
falken
2016/07/04 08:23:02
"FinalizeTo" is a bit strange grammar. "FinalizeTo
shimazu
2016/07/05 03:33:57
Sorry, what do you mean for the latter sentence?
falken
2016/07/05 06:49:28
Hm, OK. Either one is OK. Finalize means the same
shimazu
2016/07/06 06:27:35
Done.
| |
| 207 | |
| 208 // Sends back a response with fall_back_required set as true to trigger | |
| 209 // subsequent network requests with CORS checking. | |
| 210 // This can be called after StartRequest. | |
| 211 void FinalizeToFallbackToRenderer(); | |
| 212 | |
| 213 // true if need to send back a response with fall_back_required set as true to | |
|
falken
2016/07/04 08:23:02
super nit: First letter should be capitalized (see
shimazu
2016/07/05 03:33:57
Done.
| |
| 214 // trigger subsequent network requests with CORS checking. | |
| 215 bool IsNeedToFallbackToRenderer() const; | |
|
falken
2016/07/04 08:23:02
"IsNeedTo" -> "Is*Needed" (see git gs "IsNeedTo" v
shimazu
2016/07/05 03:33:57
Done.
| |
| 216 | |
| 202 // For UMA. | 217 // For UMA. |
| 203 void SetResponseBodyType(ResponseBodyType type); | 218 void SetResponseBodyType(ResponseBodyType type); |
| 204 bool ShouldRecordResult(); | 219 bool ShouldRecordResult(); |
| 205 void RecordResult(ServiceWorkerMetrics::URLRequestJobResult result); | 220 void RecordResult(ServiceWorkerMetrics::URLRequestJobResult result); |
| 206 void RecordStatusZeroResponseError( | 221 void RecordStatusZeroResponseError( |
| 207 blink::WebServiceWorkerResponseError error); | 222 blink::WebServiceWorkerResponseError error); |
| 208 | 223 |
| 209 // Releases the resources for streaming. | 224 // Releases the resources for streaming. |
| 210 void ClearStream(); | 225 void ClearStream(); |
| 211 | 226 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 285 EmbeddedWorkerStatus initial_worker_status_ = EmbeddedWorkerStatus::STOPPED; | 300 EmbeddedWorkerStatus initial_worker_status_ = EmbeddedWorkerStatus::STOPPED; |
| 286 | 301 |
| 287 base::WeakPtrFactory<ServiceWorkerURLRequestJob> weak_factory_; | 302 base::WeakPtrFactory<ServiceWorkerURLRequestJob> weak_factory_; |
| 288 | 303 |
| 289 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerURLRequestJob); | 304 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerURLRequestJob); |
| 290 }; | 305 }; |
| 291 | 306 |
| 292 } // namespace content | 307 } // namespace content |
| 293 | 308 |
| 294 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_ | 309 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_ |
| OLD | NEW |