| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/service_worker_context_client.h" | 5 #include "content/renderer/service_worker/service_worker_context_client.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "content/child/service_worker/web_service_worker_registration_impl.h" | 31 #include "content/child/service_worker/web_service_worker_registration_impl.h" |
| 32 #include "content/child/thread_safe_sender.h" | 32 #include "content/child/thread_safe_sender.h" |
| 33 #include "content/child/web_data_consumer_handle_impl.h" | 33 #include "content/child/web_data_consumer_handle_impl.h" |
| 34 #include "content/child/web_url_loader_impl.h" | 34 #include "content/child/web_url_loader_impl.h" |
| 35 #include "content/child/webmessageportchannel_impl.h" | 35 #include "content/child/webmessageportchannel_impl.h" |
| 36 #include "content/common/devtools_messages.h" | 36 #include "content/common/devtools_messages.h" |
| 37 #include "content/common/service_worker/embedded_worker_messages.h" | 37 #include "content/common/service_worker/embedded_worker_messages.h" |
| 38 #include "content/common/service_worker/service_worker_event_dispatcher.mojom.h" | 38 #include "content/common/service_worker/service_worker_event_dispatcher.mojom.h" |
| 39 #include "content/common/service_worker/service_worker_messages.h" | 39 #include "content/common/service_worker/service_worker_messages.h" |
| 40 #include "content/common/service_worker/service_worker_status_code.h" | 40 #include "content/common/service_worker/service_worker_status_code.h" |
| 41 #include "content/common/worker_url_loader_factory_provider.mojom.h" |
| 42 #include "content/public/common/content_features.h" |
| 41 #include "content/public/common/push_event_payload.h" | 43 #include "content/public/common/push_event_payload.h" |
| 42 #include "content/public/common/referrer.h" | 44 #include "content/public/common/referrer.h" |
| 43 #include "content/public/renderer/content_renderer_client.h" | 45 #include "content/public/renderer/content_renderer_client.h" |
| 44 #include "content/public/renderer/document_state.h" | 46 #include "content/public/renderer/document_state.h" |
| 45 #include "content/renderer/devtools/devtools_agent.h" | 47 #include "content/renderer/devtools/devtools_agent.h" |
| 46 #include "content/renderer/render_thread_impl.h" | 48 #include "content/renderer/render_thread_impl.h" |
| 49 #include "content/renderer/renderer_blink_platform_impl.h" |
| 47 #include "content/renderer/service_worker/embedded_worker_devtools_agent.h" | 50 #include "content/renderer/service_worker/embedded_worker_devtools_agent.h" |
| 48 #include "content/renderer/service_worker/embedded_worker_instance_client_impl.h
" | 51 #include "content/renderer/service_worker/embedded_worker_instance_client_impl.h
" |
| 52 #include "content/renderer/service_worker/service_worker_fetch_context_impl.h" |
| 49 #include "content/renderer/service_worker/service_worker_type_converters.h" | 53 #include "content/renderer/service_worker/service_worker_type_converters.h" |
| 50 #include "content/renderer/service_worker/service_worker_type_util.h" | 54 #include "content/renderer/service_worker/service_worker_type_util.h" |
| 51 #include "ipc/ipc_message.h" | 55 #include "ipc/ipc_message.h" |
| 52 #include "ipc/ipc_message_macros.h" | 56 #include "ipc/ipc_message_macros.h" |
| 53 #include "net/base/net_errors.h" | 57 #include "net/base/net_errors.h" |
| 54 #include "net/http/http_response_headers.h" | 58 #include "net/http/http_response_headers.h" |
| 59 #include "third_party/WebKit/public/platform/InterfaceProvider.h" |
| 55 #include "third_party/WebKit/public/platform/URLConversion.h" | 60 #include "third_party/WebKit/public/platform/URLConversion.h" |
| 56 #include "third_party/WebKit/public/platform/WebMessagePortChannel.h" | 61 #include "third_party/WebKit/public/platform/WebMessagePortChannel.h" |
| 57 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" | 62 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" |
| 58 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 63 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
| 59 #include "third_party/WebKit/public/platform/WebString.h" | 64 #include "third_party/WebKit/public/platform/WebString.h" |
| 60 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 65 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
| 61 #include "third_party/WebKit/public/platform/modules/background_fetch/WebBackgro
undFetchSettledFetch.h" | 66 #include "third_party/WebKit/public/platform/modules/background_fetch/WebBackgro
undFetchSettledFetch.h" |
| 62 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati
onData.h" | 67 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati
onData.h" |
| 63 #include "third_party/WebKit/public/platform/modules/payments/WebPaymentAppReque
st.h" | 68 #include "third_party/WebKit/public/platform/modules/payments/WebPaymentAppReque
st.h" |
| 64 #include "third_party/WebKit/public/platform/modules/payments/WebPaymentAppRespo
nse.h" | 69 #include "third_party/WebKit/public/platform/modules/payments/WebPaymentAppRespo
nse.h" |
| (...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1057 ServiceWorkerContextClient::CreateServiceWorkerNetworkProvider() { | 1062 ServiceWorkerContextClient::CreateServiceWorkerNetworkProvider() { |
| 1058 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); | 1063 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); |
| 1059 | 1064 |
| 1060 // Create a content::ServiceWorkerNetworkProvider for this data source so | 1065 // Create a content::ServiceWorkerNetworkProvider for this data source so |
| 1061 // we can observe its requests. | 1066 // we can observe its requests. |
| 1062 std::unique_ptr<ServiceWorkerNetworkProvider> provider = | 1067 std::unique_ptr<ServiceWorkerNetworkProvider> provider = |
| 1063 base::MakeUnique<ServiceWorkerNetworkProvider>( | 1068 base::MakeUnique<ServiceWorkerNetworkProvider>( |
| 1064 MSG_ROUTING_NONE, SERVICE_WORKER_PROVIDER_FOR_CONTROLLER, | 1069 MSG_ROUTING_NONE, SERVICE_WORKER_PROVIDER_FOR_CONTROLLER, |
| 1065 true /* is_parent_frame_secure */); | 1070 true /* is_parent_frame_secure */); |
| 1066 provider_context_ = provider->context(); | 1071 provider_context_ = provider->context(); |
| 1072 network_provider_id_ = provider->provider_id(); |
| 1067 | 1073 |
| 1068 // Tell the network provider about which version to load. | 1074 // Tell the network provider about which version to load. |
| 1069 provider->SetServiceWorkerVersionId(service_worker_version_id_, | 1075 provider->SetServiceWorkerVersionId(service_worker_version_id_, |
| 1070 embedded_worker_id_); | 1076 embedded_worker_id_); |
| 1071 | 1077 |
| 1072 // Blink is responsible for deleting the returned object. | 1078 // Blink is responsible for deleting the returned object. |
| 1073 return new WebServiceWorkerNetworkProviderImpl(std::move(provider)); | 1079 return new WebServiceWorkerNetworkProviderImpl(std::move(provider)); |
| 1074 } | 1080 } |
| 1075 | 1081 |
| 1082 std::unique_ptr<blink::WebWorkerFetchContext> |
| 1083 ServiceWorkerContextClient::CreateServiceWorkerFetchContext() { |
| 1084 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); |
| 1085 DCHECK(base::FeatureList::IsEnabled(features::kOffMainThreadFetch)); |
| 1086 mojom::WorkerURLLoaderFactoryProviderPtr worker_url_loader_factory_provider; |
| 1087 RenderThreadImpl::current() |
| 1088 ->blink_platform_impl() |
| 1089 ->GetInterfaceProvider() |
| 1090 ->GetInterface(mojo::MakeRequest(&worker_url_loader_factory_provider)); |
| 1091 |
| 1092 // Blink is responsible for deleting the returned object. |
| 1093 return base::MakeUnique<ServiceWorkerFetchContextImpl>( |
| 1094 worker_url_loader_factory_provider.PassInterface(), network_provider_id_); |
| 1095 } |
| 1096 |
| 1076 blink::WebServiceWorkerProvider* | 1097 blink::WebServiceWorkerProvider* |
| 1077 ServiceWorkerContextClient::CreateServiceWorkerProvider() { | 1098 ServiceWorkerContextClient::CreateServiceWorkerProvider() { |
| 1078 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); | 1099 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); |
| 1079 DCHECK(provider_context_); | 1100 DCHECK(provider_context_); |
| 1080 | 1101 |
| 1081 // Blink is responsible for deleting the returned object. | 1102 // Blink is responsible for deleting the returned object. |
| 1082 return new WebServiceWorkerProviderImpl( | 1103 return new WebServiceWorkerProviderImpl( |
| 1083 sender_.get(), provider_context_.get()); | 1104 sender_.get(), provider_context_.get()); |
| 1084 } | 1105 } |
| 1085 | 1106 |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1620 } | 1641 } |
| 1621 | 1642 |
| 1622 base::WeakPtr<ServiceWorkerContextClient> | 1643 base::WeakPtr<ServiceWorkerContextClient> |
| 1623 ServiceWorkerContextClient::GetWeakPtr() { | 1644 ServiceWorkerContextClient::GetWeakPtr() { |
| 1624 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); | 1645 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); |
| 1625 DCHECK(context_); | 1646 DCHECK(context_); |
| 1626 return context_->weak_factory.GetWeakPtr(); | 1647 return context_->weak_factory.GetWeakPtr(); |
| 1627 } | 1648 } |
| 1628 | 1649 |
| 1629 } // namespace content | 1650 } // namespace content |
| OLD | NEW |