| 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 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 scoped_refptr<ServiceWorkerVersion> version) { | 582 scoped_refptr<ServiceWorkerVersion> version) { |
| 583 fetch_dispatcher_.reset(); | 583 fetch_dispatcher_.reset(); |
| 584 ServiceWorkerMetrics::RecordFetchEventStatus(is_main_resource_load_, status); | 584 ServiceWorkerMetrics::RecordFetchEventStatus(is_main_resource_load_, status); |
| 585 | 585 |
| 586 // Check if we're not orphaned. | 586 // Check if we're not orphaned. |
| 587 if (!request()) { | 587 if (!request()) { |
| 588 RecordResult(ServiceWorkerMetrics::REQUEST_JOB_ERROR_NO_REQUEST); | 588 RecordResult(ServiceWorkerMetrics::REQUEST_JOB_ERROR_NO_REQUEST); |
| 589 return; | 589 return; |
| 590 } | 590 } |
| 591 | 591 |
| 592 // A null |provider_host_| probably means the tab was closed. The null value |
| 593 // would cause problems down the line, so bail out. |
| 594 if (!provider_host_) { |
| 595 RecordResult(ServiceWorkerMetrics::REQUEST_JOB_ERROR_NO_PROVIDER_HOST); |
| 596 DeliverErrorResponse(); |
| 597 return; |
| 598 } |
| 599 |
| 592 if (status != SERVICE_WORKER_OK) { | 600 if (status != SERVICE_WORKER_OK) { |
| 593 RecordResult(ServiceWorkerMetrics::REQUEST_JOB_ERROR_FETCH_EVENT_DISPATCH); | 601 RecordResult(ServiceWorkerMetrics::REQUEST_JOB_ERROR_FETCH_EVENT_DISPATCH); |
| 594 if (is_main_resource_load_) { | 602 if (is_main_resource_load_) { |
| 595 // Using the service worker failed, so fallback to network. Detach the | 603 // Using the service worker failed, so fallback to network. Detach the |
| 596 // controller so subresource requests also skip the worker. | 604 // controller so subresource requests also skip the worker. |
| 597 provider_host_->NotifyControllerLost(); | 605 provider_host_->NotifyControllerLost(); |
| 598 response_type_ = FALLBACK_TO_NETWORK; | 606 response_type_ = FALLBACK_TO_NETWORK; |
| 599 NotifyRestartRequired(); | 607 NotifyRestartRequired(); |
| 600 } else { | 608 } else { |
| 601 DeliverErrorResponse(); | 609 DeliverErrorResponse(); |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 } | 812 } |
| 805 if (!waiting_stream_url_.is_empty()) { | 813 if (!waiting_stream_url_.is_empty()) { |
| 806 StreamRegistry* stream_registry = | 814 StreamRegistry* stream_registry = |
| 807 GetStreamContextForResourceContext(resource_context_)->registry(); | 815 GetStreamContextForResourceContext(resource_context_)->registry(); |
| 808 stream_registry->RemoveRegisterObserver(waiting_stream_url_); | 816 stream_registry->RemoveRegisterObserver(waiting_stream_url_); |
| 809 stream_registry->AbortPendingStream(waiting_stream_url_); | 817 stream_registry->AbortPendingStream(waiting_stream_url_); |
| 810 } | 818 } |
| 811 } | 819 } |
| 812 | 820 |
| 813 } // namespace content | 821 } // namespace content |
| OLD | NEW |