| 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/profiler/scoped_tracker.h" |
| 13 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 14 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 15 #include "content/browser/service_worker/service_worker_fetch_dispatcher.h" | 16 #include "content/browser/service_worker/service_worker_fetch_dispatcher.h" |
| 16 #include "content/browser/service_worker/service_worker_provider_host.h" | 17 #include "content/browser/service_worker/service_worker_provider_host.h" |
| 17 #include "content/common/resource_request_body.h" | 18 #include "content/common/resource_request_body.h" |
| 18 #include "content/common/service_worker/service_worker_types.h" | 19 #include "content/common/service_worker/service_worker_types.h" |
| 19 #include "content/public/browser/blob_handle.h" | 20 #include "content/public/browser/blob_handle.h" |
| 20 #include "content/public/browser/resource_request_info.h" | 21 #include "content/public/browser/resource_request_info.h" |
| 21 #include "content/public/browser/service_worker_context.h" | 22 #include "content/public/browser/service_worker_context.h" |
| 22 #include "net/base/net_errors.h" | 23 #include "net/base/net_errors.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 bool fatal) { | 170 bool fatal) { |
| 170 NOTREACHED(); | 171 NOTREACHED(); |
| 171 } | 172 } |
| 172 | 173 |
| 173 void ServiceWorkerURLRequestJob::OnBeforeNetworkStart(net::URLRequest* request, | 174 void ServiceWorkerURLRequestJob::OnBeforeNetworkStart(net::URLRequest* request, |
| 174 bool* defer) { | 175 bool* defer) { |
| 175 NOTREACHED(); | 176 NOTREACHED(); |
| 176 } | 177 } |
| 177 | 178 |
| 178 void ServiceWorkerURLRequestJob::OnResponseStarted(net::URLRequest* request) { | 179 void ServiceWorkerURLRequestJob::OnResponseStarted(net::URLRequest* request) { |
| 180 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed. |
| 181 tracked_objects::ScopedTracker tracking_profile( |
| 182 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 183 "423948 ServiceWorkerURLRequestJob::OnResponseStarted")); |
| 184 |
| 179 // TODO(falken): Add Content-Length, Content-Type if they were not provided in | 185 // TODO(falken): Add Content-Length, Content-Type if they were not provided in |
| 180 // the ServiceWorkerResponse. | 186 // the ServiceWorkerResponse. |
| 181 response_time_ = base::Time::Now(); | 187 response_time_ = base::Time::Now(); |
| 182 CommitResponseHeader(); | 188 CommitResponseHeader(); |
| 183 } | 189 } |
| 184 | 190 |
| 185 void ServiceWorkerURLRequestJob::OnReadCompleted(net::URLRequest* request, | 191 void ServiceWorkerURLRequestJob::OnReadCompleted(net::URLRequest* request, |
| 186 int bytes_read) { | 192 int bytes_read) { |
| 193 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed. |
| 194 tracked_objects::ScopedTracker tracking_profile( |
| 195 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 196 "423948 ServiceWorkerURLRequestJob::OnReadCompleted")); |
| 197 |
| 187 SetStatus(request->status()); | 198 SetStatus(request->status()); |
| 188 if (!request->status().is_success()) { | 199 if (!request->status().is_success()) { |
| 189 NotifyDone(request->status()); | 200 NotifyDone(request->status()); |
| 190 return; | 201 return; |
| 191 } | 202 } |
| 192 NotifyReadComplete(bytes_read); | 203 NotifyReadComplete(bytes_read); |
| 193 if (bytes_read == 0) | 204 if (bytes_read == 0) |
| 194 NotifyDone(request->status()); | 205 NotifyDone(request->status()); |
| 195 } | 206 } |
| 196 | 207 |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 | 491 |
| 481 void ServiceWorkerURLRequestJob::DeliverErrorResponse() { | 492 void ServiceWorkerURLRequestJob::DeliverErrorResponse() { |
| 482 // TODO(falken): Print an error to the console of the ServiceWorker and of | 493 // TODO(falken): Print an error to the console of the ServiceWorker and of |
| 483 // the requesting page. | 494 // the requesting page. |
| 484 CreateResponseHeader( | 495 CreateResponseHeader( |
| 485 500, "Service Worker Response Error", ServiceWorkerHeaderMap()); | 496 500, "Service Worker Response Error", ServiceWorkerHeaderMap()); |
| 486 CommitResponseHeader(); | 497 CommitResponseHeader(); |
| 487 } | 498 } |
| 488 | 499 |
| 489 } // namespace content | 500 } // namespace content |
| OLD | NEW |