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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 769 // It is because the CORS preflight logic is implemented in the renderer. So | 769 // It is because the CORS preflight logic is implemented in the renderer. So |
| 770 // we return a fall_back_required response to the renderer. | 770 // we return a fall_back_required response to the renderer. |
| 771 // If fetch_type is |FOREIGN_FETCH| any required CORS checks will have already | 771 // If fetch_type is |FOREIGN_FETCH| any required CORS checks will have already |
| 772 // been done in the renderer (and if a preflight was necesary the request | 772 // been done in the renderer (and if a preflight was necesary the request |
| 773 // would never have reached foreign fetch), so such requests can always | 773 // would never have reached foreign fetch), so such requests can always |
| 774 // fallback to the network directly. | 774 // fallback to the network directly. |
| 775 return !IsMainResourceLoad() && | 775 return !IsMainResourceLoad() && |
| 776 fetch_type_ != ServiceWorkerFetchType::FOREIGN_FETCH && | 776 fetch_type_ != ServiceWorkerFetchType::FOREIGN_FETCH && |
| 777 (request_mode_ == FETCH_REQUEST_MODE_CORS || | 777 (request_mode_ == FETCH_REQUEST_MODE_CORS || |
| 778 request_mode_ == FETCH_REQUEST_MODE_CORS_WITH_FORCED_PREFLIGHT) && | 778 request_mode_ == FETCH_REQUEST_MODE_CORS_WITH_FORCED_PREFLIGHT) && |
| 779 !request()->initiator().IsSameOriginWith( | 779 (!request()->initiator().has_value() || |
|
horo
2016/11/04 03:13:35
Just to confirm: The initiator must be set when th
clamy
2016/11/04 16:03:50
Yes.
| |
| 780 url::Origin(request()->url())); | 780 !request()->initiator()->IsSameOriginWith( |
| 781 url::Origin(request()->url()))); | |
| 781 } | 782 } |
| 782 | 783 |
| 783 void ServiceWorkerURLRequestJob::SetResponseBodyType(ResponseBodyType type) { | 784 void ServiceWorkerURLRequestJob::SetResponseBodyType(ResponseBodyType type) { |
| 784 DCHECK_EQ(response_body_type_, UNKNOWN); | 785 DCHECK_EQ(response_body_type_, UNKNOWN); |
| 785 DCHECK_NE(type, UNKNOWN); | 786 DCHECK_NE(type, UNKNOWN); |
| 786 response_body_type_ = type; | 787 response_body_type_ = type; |
| 787 } | 788 } |
| 788 | 789 |
| 789 bool ServiceWorkerURLRequestJob::ShouldRecordResult() { | 790 bool ServiceWorkerURLRequestJob::ShouldRecordResult() { |
| 790 return !did_record_result_ && is_started_ && | 791 return !did_record_result_ && is_started_ && |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 891 base::Bind(&ServiceWorkerURLRequestJob::DidPrepareFetchEvent, | 892 base::Bind(&ServiceWorkerURLRequestJob::DidPrepareFetchEvent, |
| 892 weak_factory_.GetWeakPtr(), active_worker), | 893 weak_factory_.GetWeakPtr(), active_worker), |
| 893 base::Bind(&ServiceWorkerURLRequestJob::DidDispatchFetchEvent, | 894 base::Bind(&ServiceWorkerURLRequestJob::DidDispatchFetchEvent, |
| 894 weak_factory_.GetWeakPtr()))); | 895 weak_factory_.GetWeakPtr()))); |
| 895 worker_start_time_ = base::TimeTicks::Now(); | 896 worker_start_time_ = base::TimeTicks::Now(); |
| 896 fetch_dispatcher_->MaybeStartNavigationPreload(request()); | 897 fetch_dispatcher_->MaybeStartNavigationPreload(request()); |
| 897 fetch_dispatcher_->Run(); | 898 fetch_dispatcher_->Run(); |
| 898 } | 899 } |
| 899 | 900 |
| 900 } // namespace content | 901 } // namespace content |
| OLD | NEW |