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 #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 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 #include "net/http/http_response_headers.h" | 23 #include "net/http/http_response_headers.h" |
| 24 #include "net/http/http_response_info.h" | 24 #include "net/http/http_response_info.h" |
| 25 #include "net/http/http_util.h" | 25 #include "net/http/http_util.h" |
| 26 #include "storage/browser/blob/blob_data_handle.h" | 26 #include "storage/browser/blob/blob_data_handle.h" |
| 27 #include "storage/browser/blob/blob_storage_context.h" | 27 #include "storage/browser/blob/blob_storage_context.h" |
| 28 #include "storage/browser/blob/blob_url_request_job_factory.h" | 28 #include "storage/browser/blob/blob_url_request_job_factory.h" |
| 29 #include "ui/base/page_transition_types.h" | 29 #include "ui/base/page_transition_types.h" |
| 30 | 30 |
| 31 namespace content { | 31 namespace content { |
| 32 | 32 |
| 33 namespace { | |
| 34 | |
| 35 // Keep in sync with kDevToolsRequestInitiator and | |
| 36 // kDevToolsEmulateNetworkConditionsClientIddefined in | |
| 37 // devtools_network_controller.cc | |
|
falken
2014/10/02 03:54:46
It looks like they are defined in devtools_network
horo
2014/10/02 04:52:15
Done.
| |
| 38 const char kDevToolsRequestInitiator[] = "X-DevTools-Request-Initiator"; | |
| 39 const char kDevToolsEmulateNetworkConditionsClientId[] = | |
| 40 "X-DevTools-Emulate-Network-Conditions-Client-Id"; | |
| 41 | |
| 42 } // namespace | |
| 43 | |
| 33 ServiceWorkerURLRequestJob::ServiceWorkerURLRequestJob( | 44 ServiceWorkerURLRequestJob::ServiceWorkerURLRequestJob( |
| 34 net::URLRequest* request, | 45 net::URLRequest* request, |
| 35 net::NetworkDelegate* network_delegate, | 46 net::NetworkDelegate* network_delegate, |
| 36 base::WeakPtr<ServiceWorkerProviderHost> provider_host, | 47 base::WeakPtr<ServiceWorkerProviderHost> provider_host, |
| 37 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, | 48 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, |
| 38 FetchRequestMode request_mode, | 49 FetchRequestMode request_mode, |
| 39 scoped_refptr<ResourceRequestBody> body) | 50 scoped_refptr<ResourceRequestBody> body) |
| 40 : net::URLRequestJob(request, network_delegate), | 51 : net::URLRequestJob(request, network_delegate), |
| 41 provider_host_(provider_host), | 52 provider_host_(provider_host), |
| 42 response_type_(NOT_DETERMINED), | 53 response_type_(NOT_DETERMINED), |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 267 ServiceWorkerURLRequestJob::CreateFetchRequest() { | 278 ServiceWorkerURLRequestJob::CreateFetchRequest() { |
| 268 std::string blob_uuid; | 279 std::string blob_uuid; |
| 269 uint64 blob_size = 0; | 280 uint64 blob_size = 0; |
| 270 CreateRequestBodyBlob(&blob_uuid, &blob_size); | 281 CreateRequestBodyBlob(&blob_uuid, &blob_size); |
| 271 scoped_ptr<ServiceWorkerFetchRequest> request( | 282 scoped_ptr<ServiceWorkerFetchRequest> request( |
| 272 new ServiceWorkerFetchRequest()); | 283 new ServiceWorkerFetchRequest()); |
| 273 request->mode = request_mode_; | 284 request->mode = request_mode_; |
| 274 request->url = request_->url(); | 285 request->url = request_->url(); |
| 275 request->method = request_->method(); | 286 request->method = request_->method(); |
| 276 const net::HttpRequestHeaders& headers = request_->extra_request_headers(); | 287 const net::HttpRequestHeaders& headers = request_->extra_request_headers(); |
| 277 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext();) | 288 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext();) { |
| 289 if (it.name() == kDevToolsRequestInitiator || | |
| 290 it.name() == kDevToolsEmulateNetworkConditionsClientId) { | |
| 291 continue; | |
| 292 } | |
| 278 request->headers[it.name()] = it.value(); | 293 request->headers[it.name()] = it.value(); |
| 294 } | |
| 279 request->blob_uuid = blob_uuid; | 295 request->blob_uuid = blob_uuid; |
| 280 request->blob_size = blob_size; | 296 request->blob_size = blob_size; |
| 281 request->referrer = GURL(request_->referrer()); | 297 request->referrer = GURL(request_->referrer()); |
| 282 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request_); | 298 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request_); |
| 283 if (info) { | 299 if (info) { |
| 284 request->is_reload = ui::PageTransitionCoreTypeIs( | 300 request->is_reload = ui::PageTransitionCoreTypeIs( |
| 285 info->GetPageTransition(), ui::PAGE_TRANSITION_RELOAD); | 301 info->GetPageTransition(), ui::PAGE_TRANSITION_RELOAD); |
| 286 } | 302 } |
| 287 return request.Pass(); | 303 return request.Pass(); |
| 288 } | 304 } |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 461 | 477 |
| 462 void ServiceWorkerURLRequestJob::DeliverErrorResponse() { | 478 void ServiceWorkerURLRequestJob::DeliverErrorResponse() { |
| 463 // TODO(falken): Print an error to the console of the ServiceWorker and of | 479 // TODO(falken): Print an error to the console of the ServiceWorker and of |
| 464 // the requesting page. | 480 // the requesting page. |
| 465 CreateResponseHeader( | 481 CreateResponseHeader( |
| 466 500, "Service Worker Response Error", ServiceWorkerHeaderMap()); | 482 500, "Service Worker Response Error", ServiceWorkerHeaderMap()); |
| 467 CommitResponseHeader(); | 483 CommitResponseHeader(); |
| 468 } | 484 } |
| 469 | 485 |
| 470 } // namespace content | 486 } // namespace content |
| OLD | NEW |