| 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 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 provider_host_->NotifyControllerLost(); | 595 provider_host_->NotifyControllerLost(); |
| 596 response_type_ = FALLBACK_TO_NETWORK; | 596 response_type_ = FALLBACK_TO_NETWORK; |
| 597 NotifyRestartRequired(); | 597 NotifyRestartRequired(); |
| 598 } else { | 598 } else { |
| 599 DeliverErrorResponse(); | 599 DeliverErrorResponse(); |
| 600 } | 600 } |
| 601 return; | 601 return; |
| 602 } | 602 } |
| 603 | 603 |
| 604 if (fetch_result == SERVICE_WORKER_FETCH_EVENT_RESULT_FALLBACK) { | 604 if (fetch_result == SERVICE_WORKER_FETCH_EVENT_RESULT_FALLBACK) { |
| 605 // When the request_mode is |CORS| or |CORS-with-forced-preflight| and the | 605 // When the request_mode is |CORS| or |CORS-with-forced-preflight| we can't |
| 606 // origin of the request URL is different from the security origin of the | 606 // simply fallback to the network in the browser process. It is because the |
| 607 // document, we can't simply fallback to the network in the browser process. | 607 // CORS preflight logic is implemented in the renderer. So we returns a |
| 608 // It is because the CORS preflight logic is implemented in the renderer. So | 608 // fall_back_required response to the renderer. |
| 609 // we returns a fall_back_required response to the renderer. | 609 if (request_mode_ == FETCH_REQUEST_MODE_CORS || |
| 610 if ((request_mode_ == FETCH_REQUEST_MODE_CORS || | 610 request_mode_ == FETCH_REQUEST_MODE_CORS_WITH_FORCED_PREFLIGHT) { |
| 611 request_mode_ == FETCH_REQUEST_MODE_CORS_WITH_FORCED_PREFLIGHT) && | |
| 612 provider_host_->document_url().GetOrigin() != | |
| 613 request()->url().GetOrigin()) { | |
| 614 fall_back_required_ = true; | 611 fall_back_required_ = true; |
| 615 RecordResult(ServiceWorkerMetrics::REQUEST_JOB_FALLBACK_FOR_CORS); | 612 RecordResult(ServiceWorkerMetrics::REQUEST_JOB_FALLBACK_FOR_CORS); |
| 616 CreateResponseHeader( | 613 CreateResponseHeader( |
| 617 400, "Service Worker Fallback Required", ServiceWorkerHeaderMap()); | 614 400, "Service Worker Fallback Required", ServiceWorkerHeaderMap()); |
| 618 CommitResponseHeader(); | 615 CommitResponseHeader(); |
| 619 return; | 616 return; |
| 620 } | 617 } |
| 621 // Change the response type and restart the request to fallback to | 618 // Change the response type and restart the request to fallback to |
| 622 // the network. | 619 // the network. |
| 623 RecordResult(ServiceWorkerMetrics::REQUEST_JOB_FALLBACK_RESPONSE); | 620 RecordResult(ServiceWorkerMetrics::REQUEST_JOB_FALLBACK_RESPONSE); |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 801 } | 798 } |
| 802 if (!waiting_stream_url_.is_empty()) { | 799 if (!waiting_stream_url_.is_empty()) { |
| 803 StreamRegistry* stream_registry = | 800 StreamRegistry* stream_registry = |
| 804 GetStreamContextForResourceContext(resource_context_)->registry(); | 801 GetStreamContextForResourceContext(resource_context_)->registry(); |
| 805 stream_registry->RemoveRegisterObserver(waiting_stream_url_); | 802 stream_registry->RemoveRegisterObserver(waiting_stream_url_); |
| 806 stream_registry->AbortPendingStream(waiting_stream_url_); | 803 stream_registry->AbortPendingStream(waiting_stream_url_); |
| 807 } | 804 } |
| 808 } | 805 } |
| 809 | 806 |
| 810 } // namespace content | 807 } // namespace content |
| OLD | NEW |