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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 MaybeStartRequest(); | 76 MaybeStartRequest(); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void ServiceWorkerURLRequestJob::Start() { | 79 void ServiceWorkerURLRequestJob::Start() { |
| 80 is_started_ = true; | 80 is_started_ = true; |
| 81 MaybeStartRequest(); | 81 MaybeStartRequest(); |
| 82 } | 82 } |
| 83 | 83 |
| 84 void ServiceWorkerURLRequestJob::Kill() { | 84 void ServiceWorkerURLRequestJob::Kill() { |
| 85 net::URLRequestJob::Kill(); | 85 net::URLRequestJob::Kill(); |
| 86 if (stream_ || !waiting_stream_url_.is_empty()) { | |
| 87 if (ServiceWorkerVersion* active_version = provider_host_->active_version()) | |
|
michaeln
2015/01/07 21:48:46
couple of things i wonder about?
provider_host_ i
horo
2015/01/08 04:04:02
ServiceWorkerURLRequestJob::Kill() must be called
| |
| 88 active_version->RemoveStreamingURLRequestJob(this); | |
| 89 } | |
| 86 if (stream_) { | 90 if (stream_) { |
| 87 stream_->RemoveReadObserver(this); | 91 stream_->RemoveReadObserver(this); |
| 88 stream_->Abort(); | 92 stream_->Abort(); |
| 89 stream_ = nullptr; | 93 stream_ = nullptr; |
| 90 } | 94 } |
| 91 if (!waiting_stream_url_.is_empty()) { | 95 if (!waiting_stream_url_.is_empty()) { |
| 92 StreamRegistry* stream_registry = | 96 StreamRegistry* stream_registry = |
| 93 GetStreamContextForResourceContext(resource_context_)->registry(); | 97 GetStreamContextForResourceContext(resource_context_)->registry(); |
| 94 stream_registry->RemoveRegisterObserver(waiting_stream_url_); | 98 stream_registry->RemoveRegisterObserver(waiting_stream_url_); |
| 95 stream_registry->AbortPendingStream(waiting_stream_url_); | 99 stream_registry->AbortPendingStream(waiting_stream_url_); |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 527 net::URLRequestStatus(net::URLRequestStatus::FAILED, net::ERR_FAILED)); | 531 net::URLRequestStatus(net::URLRequestStatus::FAILED, net::ERR_FAILED)); |
| 528 return; | 532 return; |
| 529 } | 533 } |
| 530 | 534 |
| 531 fetch_end_time_ = base::TimeTicks::Now(); | 535 fetch_end_time_ = base::TimeTicks::Now(); |
| 532 load_timing_info_.send_end = fetch_end_time_; | 536 load_timing_info_.send_end = fetch_end_time_; |
| 533 | 537 |
| 534 // Set up a request for reading the stream. | 538 // Set up a request for reading the stream. |
| 535 if (response.stream_url.is_valid()) { | 539 if (response.stream_url.is_valid()) { |
| 536 DCHECK(response.blob_uuid.empty()); | 540 DCHECK(response.blob_uuid.empty()); |
| 541 DCHECK(provider_host_->active_version()); | |
| 542 provider_host_->active_version()->AddStreamingURLRequestJob(this); | |
|
kinuko
2015/01/05 08:26:04
Should we just always keep alive the version while
horo
2015/01/05 08:31:32
We don't need to keep alive the version if Service
kinuko
2015/01/05 14:08:21
Ok. I just thought it might be simpler and ok enou
| |
| 537 response_url_ = response.url; | 543 response_url_ = response.url; |
| 538 service_worker_response_type_ = response.response_type; | 544 service_worker_response_type_ = response.response_type; |
| 539 CreateResponseHeader( | 545 CreateResponseHeader( |
| 540 response.status_code, response.status_text, response.headers); | 546 response.status_code, response.status_text, response.headers); |
| 541 load_timing_info_.receive_headers_end = base::TimeTicks::Now(); | 547 load_timing_info_.receive_headers_end = base::TimeTicks::Now(); |
| 542 StreamContext* stream_context = | 548 StreamContext* stream_context = |
| 543 GetStreamContextForResourceContext(resource_context_); | 549 GetStreamContextForResourceContext(resource_context_); |
| 544 stream_ = | 550 stream_ = |
| 545 stream_context->registry()->GetStream(response.stream_url); | 551 stream_context->registry()->GetStream(response.stream_url); |
| 546 if (!stream_.get()) { | 552 if (!stream_.get()) { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 607 | 613 |
| 608 void ServiceWorkerURLRequestJob::DeliverErrorResponse() { | 614 void ServiceWorkerURLRequestJob::DeliverErrorResponse() { |
| 609 // TODO(falken): Print an error to the console of the ServiceWorker and of | 615 // TODO(falken): Print an error to the console of the ServiceWorker and of |
| 610 // the requesting page. | 616 // the requesting page. |
| 611 CreateResponseHeader( | 617 CreateResponseHeader( |
| 612 500, "Service Worker Response Error", ServiceWorkerHeaderMap()); | 618 500, "Service Worker Response Error", ServiceWorkerHeaderMap()); |
| 613 CommitResponseHeader(); | 619 CommitResponseHeader(); |
| 614 } | 620 } |
| 615 | 621 |
| 616 } // namespace content | 622 } // namespace content |
| OLD | NEW |