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