| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 // It is because the CORS preflight logic is implemented in the renderer. So | 765 // It is because the CORS preflight logic is implemented in the renderer. So |
| 766 // we return a fall_back_required response to the renderer. | 766 // we return a fall_back_required response to the renderer. |
| 767 // If fetch_type is |FOREIGN_FETCH| any required CORS checks will have already | 767 // If fetch_type is |FOREIGN_FETCH| any required CORS checks will have already |
| 768 // been done in the renderer (and if a preflight was necesary the request | 768 // been done in the renderer (and if a preflight was necesary the request |
| 769 // would never have reached foreign fetch), so such requests can always | 769 // would never have reached foreign fetch), so such requests can always |
| 770 // fallback to the network directly. | 770 // fallback to the network directly. |
| 771 return !IsMainResourceLoad() && | 771 return !IsMainResourceLoad() && |
| 772 fetch_type_ != ServiceWorkerFetchType::FOREIGN_FETCH && | 772 fetch_type_ != ServiceWorkerFetchType::FOREIGN_FETCH && |
| 773 (request_mode_ == FETCH_REQUEST_MODE_CORS || | 773 (request_mode_ == FETCH_REQUEST_MODE_CORS || |
| 774 request_mode_ == FETCH_REQUEST_MODE_CORS_WITH_FORCED_PREFLIGHT) && | 774 request_mode_ == FETCH_REQUEST_MODE_CORS_WITH_FORCED_PREFLIGHT) && |
| 775 !request()->initiator().IsSameOriginWith( | 775 (!request()->initiator() || |
| 776 url::Origin(request()->url())); | 776 !request()->initiator()->IsSameOriginWith( |
| 777 url::Origin(request()->url()))); |
| 777 } | 778 } |
| 778 | 779 |
| 779 void ServiceWorkerURLRequestJob::SetResponseBodyType(ResponseBodyType type) { | 780 void ServiceWorkerURLRequestJob::SetResponseBodyType(ResponseBodyType type) { |
| 780 DCHECK_EQ(response_body_type_, UNKNOWN); | 781 DCHECK_EQ(response_body_type_, UNKNOWN); |
| 781 DCHECK_NE(type, UNKNOWN); | 782 DCHECK_NE(type, UNKNOWN); |
| 782 response_body_type_ = type; | 783 response_body_type_ = type; |
| 783 } | 784 } |
| 784 | 785 |
| 785 bool ServiceWorkerURLRequestJob::ShouldRecordResult() { | 786 bool ServiceWorkerURLRequestJob::ShouldRecordResult() { |
| 786 return !did_record_result_ && is_started_ && | 787 return !did_record_result_ && is_started_ && |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 CreateFetchRequest(), active_worker, resource_type_, request()->net_log(), | 887 CreateFetchRequest(), active_worker, resource_type_, request()->net_log(), |
| 887 base::Bind(&ServiceWorkerURLRequestJob::DidPrepareFetchEvent, | 888 base::Bind(&ServiceWorkerURLRequestJob::DidPrepareFetchEvent, |
| 888 weak_factory_.GetWeakPtr(), active_worker), | 889 weak_factory_.GetWeakPtr(), active_worker), |
| 889 base::Bind(&ServiceWorkerURLRequestJob::DidDispatchFetchEvent, | 890 base::Bind(&ServiceWorkerURLRequestJob::DidDispatchFetchEvent, |
| 890 weak_factory_.GetWeakPtr()))); | 891 weak_factory_.GetWeakPtr()))); |
| 891 worker_start_time_ = base::TimeTicks::Now(); | 892 worker_start_time_ = base::TimeTicks::Now(); |
| 892 fetch_dispatcher_->Run(); | 893 fetch_dispatcher_->Run(); |
| 893 } | 894 } |
| 894 | 895 |
| 895 } // namespace content | 896 } // namespace content |
| OLD | NEW |