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 #include "content/browser/service_worker/service_worker_url_request_job.h" | 5 #include "content/browser/service_worker/service_worker_url_request_job.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/guid.h" | 12 #include "base/guid.h" |
13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "content/browser/service_worker/service_worker_fetch_dispatcher.h" | 15 #include "content/browser/service_worker/service_worker_fetch_dispatcher.h" |
16 #include "content/browser/service_worker/service_worker_provider_host.h" | 16 #include "content/browser/service_worker/service_worker_provider_host.h" |
17 #include "content/common/resource_request_body.h" | 17 #include "content/common/resource_request_body.h" |
18 #include "content/common/service_worker/service_worker_types.h" | 18 #include "content/common/service_worker/service_worker_types.h" |
19 #include "content/public/browser/blob_handle.h" | 19 #include "content/public/browser/blob_handle.h" |
20 #include "content/public/browser/resource_request_info.h" | 20 #include "content/public/browser/resource_request_info.h" |
21 #include "content/public/common/page_transition_types.h" | |
22 #include "net/http/http_request_headers.h" | 21 #include "net/http/http_request_headers.h" |
23 #include "net/http/http_response_headers.h" | 22 #include "net/http/http_response_headers.h" |
24 #include "net/http/http_response_info.h" | 23 #include "net/http/http_response_info.h" |
25 #include "net/http/http_util.h" | 24 #include "net/http/http_util.h" |
26 #include "storage/browser/blob/blob_data_handle.h" | 25 #include "storage/browser/blob/blob_data_handle.h" |
27 #include "storage/browser/blob/blob_storage_context.h" | 26 #include "storage/browser/blob/blob_storage_context.h" |
28 #include "storage/browser/blob/blob_url_request_job_factory.h" | 27 #include "storage/browser/blob/blob_url_request_job_factory.h" |
| 28 #include "ui/base/page_transition_types.h" |
29 | 29 |
30 namespace content { | 30 namespace content { |
31 | 31 |
32 ServiceWorkerURLRequestJob::ServiceWorkerURLRequestJob( | 32 ServiceWorkerURLRequestJob::ServiceWorkerURLRequestJob( |
33 net::URLRequest* request, | 33 net::URLRequest* request, |
34 net::NetworkDelegate* network_delegate, | 34 net::NetworkDelegate* network_delegate, |
35 base::WeakPtr<ServiceWorkerProviderHost> provider_host, | 35 base::WeakPtr<ServiceWorkerProviderHost> provider_host, |
36 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, | 36 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, |
37 scoped_refptr<ResourceRequestBody> body) | 37 scoped_refptr<ResourceRequestBody> body) |
38 : net::URLRequestJob(request, network_delegate), | 38 : net::URLRequestJob(request, network_delegate), |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 request->url = request_->url(); | 267 request->url = request_->url(); |
268 request->method = request_->method(); | 268 request->method = request_->method(); |
269 const net::HttpRequestHeaders& headers = request_->extra_request_headers(); | 269 const net::HttpRequestHeaders& headers = request_->extra_request_headers(); |
270 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext();) | 270 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext();) |
271 request->headers[it.name()] = it.value(); | 271 request->headers[it.name()] = it.value(); |
272 request->blob_uuid = blob_uuid; | 272 request->blob_uuid = blob_uuid; |
273 request->blob_size = blob_size; | 273 request->blob_size = blob_size; |
274 request->referrer = GURL(request_->referrer()); | 274 request->referrer = GURL(request_->referrer()); |
275 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request_); | 275 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request_); |
276 if (info) { | 276 if (info) { |
277 request->is_reload = PageTransitionCoreTypeIs(info->GetPageTransition(), | 277 request->is_reload = ui::PageTransitionCoreTypeIs( |
278 PAGE_TRANSITION_RELOAD); | 278 info->GetPageTransition(), ui::PAGE_TRANSITION_RELOAD); |
279 } | 279 } |
280 return request.Pass(); | 280 return request.Pass(); |
281 } | 281 } |
282 | 282 |
283 bool ServiceWorkerURLRequestJob::CreateRequestBodyBlob(std::string* blob_uuid, | 283 bool ServiceWorkerURLRequestJob::CreateRequestBodyBlob(std::string* blob_uuid, |
284 uint64* blob_size) { | 284 uint64* blob_size) { |
285 if (!body_.get() || !blob_storage_context_) | 285 if (!body_.get() || !blob_storage_context_) |
286 return false; | 286 return false; |
287 | 287 |
288 std::vector<const ResourceRequestBody::Element*> resolved_elements; | 288 std::vector<const ResourceRequestBody::Element*> resolved_elements; |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 void ServiceWorkerURLRequestJob::DeliverErrorResponse() { | 442 void ServiceWorkerURLRequestJob::DeliverErrorResponse() { |
443 // TODO(falken): Print an error to the console of the ServiceWorker and of | 443 // TODO(falken): Print an error to the console of the ServiceWorker and of |
444 // the requesting page. | 444 // the requesting page. |
445 CreateResponseHeader(500, | 445 CreateResponseHeader(500, |
446 "Service Worker Response Error", | 446 "Service Worker Response Error", |
447 std::map<std::string, std::string>()); | 447 std::map<std::string, std::string>()); |
448 CommitResponseHeader(); | 448 CommitResponseHeader(); |
449 } | 449 } |
450 | 450 |
451 } // namespace content | 451 } // namespace content |
OLD | NEW |