| 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> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 17 #include "content/browser/service_worker/service_worker_metrics.h" | 17 #include "content/browser/service_worker/service_worker_metrics.h" |
| 18 #include "content/browser/streams/stream_read_observer.h" | 18 #include "content/browser/streams/stream_read_observer.h" |
| 19 #include "content/browser/streams/stream_register_observer.h" | 19 #include "content/browser/streams/stream_register_observer.h" |
| 20 #include "content/common/content_export.h" | 20 #include "content/common/content_export.h" |
| 21 #include "content/common/service_worker/service_worker_status_code.h" | 21 #include "content/common/service_worker/service_worker_status_code.h" |
| 22 #include "content/common/service_worker/service_worker_types.h" | 22 #include "content/common/service_worker/service_worker_types.h" |
| 23 #include "content/public/common/request_context_frame_type.h" | 23 #include "content/public/common/request_context_frame_type.h" |
| 24 #include "content/public/common/request_context_type.h" | 24 #include "content/public/common/request_context_type.h" |
| 25 #include "content/public/common/resource_type.h" | 25 #include "content/public/common/resource_type.h" |
| 26 #include "net/http/http_byte_range.h" | 26 #include "net/http/http_byte_range.h" |
| 27 #include "net/url_request/url_request.h" | 27 #include "net/url_request/url_request.h" |
| 28 #include "net/url_request/url_request_job.h" | 28 #include "net/url_request/url_request_job.h" |
| 29 #include "net/url_request/url_request_status.h" | 29 #include "net/url_request/url_request_status.h" |
| 30 #include "storage/common/blob_storage/blob_storage_constants.h" |
| 30 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerResponseType.h" | 31 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerResponseType.h" |
| 31 #include "url/gurl.h" | 32 #include "url/gurl.h" |
| 32 | 33 |
| 33 namespace net { | 34 namespace net { |
| 34 class IOBuffer; | 35 class IOBuffer; |
| 35 } | 36 } |
| 36 | 37 |
| 37 namespace storage { | 38 namespace storage { |
| 38 class BlobDataHandle; | 39 class BlobDataHandle; |
| 39 class BlobStorageContext; | 40 class BlobStorageContext; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 UNKNOWN, | 160 UNKNOWN, |
| 160 BLOB, | 161 BLOB, |
| 161 STREAM, | 162 STREAM, |
| 162 }; | 163 }; |
| 163 | 164 |
| 164 // We start processing the request if Start() is called AND response_type_ | 165 // We start processing the request if Start() is called AND response_type_ |
| 165 // is determined. | 166 // is determined. |
| 166 void MaybeStartRequest(); | 167 void MaybeStartRequest(); |
| 167 void StartRequest(); | 168 void StartRequest(); |
| 168 | 169 |
| 170 void DispatchToWorker(); |
| 171 |
| 169 // Creates ServiceWorkerFetchRequest from |request_| and |body_|. | 172 // Creates ServiceWorkerFetchRequest from |request_| and |body_|. |
| 170 std::unique_ptr<ServiceWorkerFetchRequest> CreateFetchRequest(); | 173 std::unique_ptr<ServiceWorkerFetchRequest> CreateFetchRequest(); |
| 171 | 174 |
| 172 // Creates BlobDataHandle of the request body from |body_|. This handle | 175 // Creates BlobDataHandle of the request body from |body_|. This handle |
| 173 // |request_body_blob_data_handle_| will be deleted when | 176 // |request_body_blob_data_handle_| will be deleted when |
| 174 // ServiceWorkerURLRequestJob is deleted. | 177 // ServiceWorkerURLRequestJob is deleted. |
| 178 // This must not be called until all blobs in |body_| finished construction. |
| 175 bool CreateRequestBodyBlob(std::string* blob_uuid, uint64_t* blob_size); | 179 bool CreateRequestBodyBlob(std::string* blob_uuid, uint64_t* blob_size); |
| 176 | 180 |
| 177 // For FORWARD_TO_SERVICE_WORKER case. | 181 // For FORWARD_TO_SERVICE_WORKER case. |
| 178 void DidPrepareFetchEvent(); | 182 void DidPrepareFetchEvent(); |
| 179 void DidDispatchFetchEvent( | 183 void DidDispatchFetchEvent( |
| 180 ServiceWorkerStatusCode status, | 184 ServiceWorkerStatusCode status, |
| 181 ServiceWorkerFetchEventResult fetch_result, | 185 ServiceWorkerFetchEventResult fetch_result, |
| 182 const ServiceWorkerResponse& response, | 186 const ServiceWorkerResponse& response, |
| 183 const scoped_refptr<ServiceWorkerVersion>& version); | 187 const scoped_refptr<ServiceWorkerVersion>& version); |
| 184 | 188 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 210 void NotifyHeadersComplete(); | 214 void NotifyHeadersComplete(); |
| 211 void NotifyStartError(net::URLRequestStatus status); | 215 void NotifyStartError(net::URLRequestStatus status); |
| 212 void NotifyRestartRequired(); | 216 void NotifyRestartRequired(); |
| 213 | 217 |
| 214 // Wrapper that gathers parameters to |on_start_completed_callback_| and then | 218 // Wrapper that gathers parameters to |on_start_completed_callback_| and then |
| 215 // calls it. | 219 // calls it. |
| 216 void OnStartCompleted() const; | 220 void OnStartCompleted() const; |
| 217 | 221 |
| 218 bool IsMainResourceLoad() const; | 222 bool IsMainResourceLoad() const; |
| 219 | 223 |
| 224 // For waiting for request body blobs to finish construction. |
| 225 bool HasRequestBody(); |
| 226 void WaitForRequestBobyBlobsToComplete(); |
| 227 void OneRequestBodyBlobCompleted( |
| 228 bool success, |
| 229 storage::IPCBlobCreationCancelCode cancel_code); |
| 230 void RequestBodyBlobsCompleted( |
| 231 bool success, |
| 232 storage::IPCBlobCreationCancelCode cancel_code); |
| 233 |
| 220 // Not owned. | 234 // Not owned. |
| 221 Delegate* delegate_; | 235 Delegate* delegate_; |
| 222 | 236 |
| 223 // Timing info to show on the popup in Devtools' Network tab. | 237 // Timing info to show on the popup in Devtools' Network tab. |
| 224 net::LoadTimingInfo load_timing_info_; | 238 net::LoadTimingInfo load_timing_info_; |
| 225 base::TimeTicks worker_start_time_; | 239 base::TimeTicks worker_start_time_; |
| 226 base::TimeTicks worker_ready_time_; | 240 base::TimeTicks worker_ready_time_; |
| 227 base::Time response_time_; | 241 base::Time response_time_; |
| 228 | 242 |
| 229 ResponseType response_type_; | 243 ResponseType response_type_; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 std::unique_ptr<storage::BlobDataHandle> request_body_blob_data_handle_; | 275 std::unique_ptr<storage::BlobDataHandle> request_body_blob_data_handle_; |
| 262 scoped_refptr<ServiceWorkerVersion> streaming_version_; | 276 scoped_refptr<ServiceWorkerVersion> streaming_version_; |
| 263 ServiceWorkerFetchType fetch_type_; | 277 ServiceWorkerFetchType fetch_type_; |
| 264 | 278 |
| 265 ResponseBodyType response_body_type_ = UNKNOWN; | 279 ResponseBodyType response_body_type_ = UNKNOWN; |
| 266 bool did_record_result_ = false; | 280 bool did_record_result_ = false; |
| 267 | 281 |
| 268 bool response_is_in_cache_storage_ = false; | 282 bool response_is_in_cache_storage_ = false; |
| 269 std::string response_cache_storage_cache_name_; | 283 std::string response_cache_storage_cache_name_; |
| 270 | 284 |
| 285 size_t num_pending_request_body_blobs_ = 0; |
| 286 |
| 271 base::WeakPtrFactory<ServiceWorkerURLRequestJob> weak_factory_; | 287 base::WeakPtrFactory<ServiceWorkerURLRequestJob> weak_factory_; |
| 272 | 288 |
| 273 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerURLRequestJob); | 289 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerURLRequestJob); |
| 274 }; | 290 }; |
| 275 | 291 |
| 276 } // namespace content | 292 } // namespace content |
| 277 | 293 |
| 278 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_ | 294 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_ |
| OLD | NEW |