| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/renderer/service_worker/worker_fetch_context_impl.h" | 5 #include "content/renderer/service_worker/worker_fetch_context_impl.h" |
| 6 | 6 |
| 7 #include "content/child/child_thread_impl.h" |
| 7 #include "content/child/request_extra_data.h" | 8 #include "content/child/request_extra_data.h" |
| 8 #include "content/child/resource_dispatcher.h" | 9 #include "content/child/resource_dispatcher.h" |
| 10 #include "content/child/thread_safe_sender.h" |
| 9 #include "content/child/web_url_loader_impl.h" | 11 #include "content/child/web_url_loader_impl.h" |
| 12 #include "content/common/frame_messages.h" |
| 10 #include "mojo/public/cpp/bindings/associated_binding.h" | 13 #include "mojo/public/cpp/bindings/associated_binding.h" |
| 11 | 14 |
| 12 namespace content { | 15 namespace content { |
| 13 | 16 |
| 14 WorkerFetchContextImpl::WorkerFetchContextImpl( | 17 WorkerFetchContextImpl::WorkerFetchContextImpl( |
| 15 mojom::WorkerURLLoaderFactoryProviderPtrInfo provider_info) | 18 mojom::WorkerURLLoaderFactoryProviderPtrInfo provider_info) |
| 16 : provider_info_(std::move(provider_info)) {} | 19 : provider_info_(std::move(provider_info)), |
| 20 thread_safe_sender_(ChildThreadImpl::current()->thread_safe_sender()) {} |
| 17 | 21 |
| 18 WorkerFetchContextImpl::~WorkerFetchContextImpl() {} | 22 WorkerFetchContextImpl::~WorkerFetchContextImpl() {} |
| 19 | 23 |
| 20 void WorkerFetchContextImpl::InitializeOnWorkerThread( | 24 void WorkerFetchContextImpl::InitializeOnWorkerThread( |
| 21 base::SingleThreadTaskRunner* loading_task_runner) { | 25 base::SingleThreadTaskRunner* loading_task_runner) { |
| 22 DCHECK(loading_task_runner->RunsTasksInCurrentSequence()); | 26 DCHECK(loading_task_runner->RunsTasksInCurrentSequence()); |
| 23 DCHECK(!resource_dispatcher_); | 27 DCHECK(!resource_dispatcher_); |
| 24 DCHECK(!binding_); | 28 DCHECK(!binding_); |
| 25 resource_dispatcher_ = | 29 resource_dispatcher_ = |
| 26 base::MakeUnique<ResourceDispatcher>(nullptr, loading_task_runner); | 30 base::MakeUnique<ResourceDispatcher>(nullptr, loading_task_runner); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 } | 68 } |
| 65 | 69 |
| 66 bool WorkerFetchContextImpl::IsDataSaverEnabled() const { | 70 bool WorkerFetchContextImpl::IsDataSaverEnabled() const { |
| 67 return is_data_saver_enabled_; | 71 return is_data_saver_enabled_; |
| 68 } | 72 } |
| 69 | 73 |
| 70 blink::WebURL WorkerFetchContextImpl::FirstPartyForCookies() const { | 74 blink::WebURL WorkerFetchContextImpl::FirstPartyForCookies() const { |
| 71 return first_party_for_cookies_; | 75 return first_party_for_cookies_; |
| 72 } | 76 } |
| 73 | 77 |
| 78 void WorkerFetchContextImpl::DidRunContentWithCertificateErrors( |
| 79 const blink::WebURL& url) { |
| 80 Send(new FrameHostMsg_DidRunContentWithCertificateErrors(parent_frame_id_, |
| 81 url)); |
| 82 } |
| 83 |
| 84 void WorkerFetchContextImpl::DidDisplayContentWithCertificateErrors( |
| 85 const blink::WebURL& url) { |
| 86 Send(new FrameHostMsg_DidDisplayContentWithCertificateErrors(parent_frame_id_, |
| 87 url)); |
| 88 } |
| 89 |
| 74 void WorkerFetchContextImpl::set_service_worker_provider_id(int id) { | 90 void WorkerFetchContextImpl::set_service_worker_provider_id(int id) { |
| 75 service_worker_provider_id_ = id; | 91 service_worker_provider_id_ = id; |
| 76 } | 92 } |
| 77 | 93 |
| 78 void WorkerFetchContextImpl::set_is_controlled_by_service_worker(bool flag) { | 94 void WorkerFetchContextImpl::set_is_controlled_by_service_worker(bool flag) { |
| 79 is_controlled_by_service_worker_ = flag; | 95 is_controlled_by_service_worker_ = flag; |
| 80 } | 96 } |
| 81 | 97 |
| 82 void WorkerFetchContextImpl::set_parent_frame_id(int id) { | 98 void WorkerFetchContextImpl::set_parent_frame_id(int id) { |
| 83 parent_frame_id_ = id; | 99 parent_frame_id_ = id; |
| 84 } | 100 } |
| 85 | 101 |
| 86 void WorkerFetchContextImpl::set_first_party_for_cookies( | 102 void WorkerFetchContextImpl::set_first_party_for_cookies( |
| 87 const blink::WebURL& first_party_for_cookies) { | 103 const blink::WebURL& first_party_for_cookies) { |
| 88 first_party_for_cookies_ = first_party_for_cookies; | 104 first_party_for_cookies_ = first_party_for_cookies; |
| 89 } | 105 } |
| 90 | 106 |
| 91 void WorkerFetchContextImpl::SetControllerServiceWorker( | 107 void WorkerFetchContextImpl::SetControllerServiceWorker( |
| 92 int64_t controller_version_id) { | 108 int64_t controller_version_id) { |
| 93 controller_version_id_ = controller_version_id; | 109 controller_version_id_ = controller_version_id; |
| 94 } | 110 } |
| 95 | 111 |
| 112 bool WorkerFetchContextImpl::Send(IPC::Message* message) { |
| 113 return thread_safe_sender_->Send(message); |
| 114 } |
| 115 |
| 96 } // namespace content | 116 } // namespace content |
| OLD | NEW |