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 985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1050 ServiceWorkerContextClient::CreateServiceWorkerNetworkProvider() { | 1055 ServiceWorkerContextClient::CreateServiceWorkerNetworkProvider() { |
1051 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); | 1056 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); |
1052 | 1057 |
1053 // Create a content::ServiceWorkerNetworkProvider for this data source so | 1058 // Create a content::ServiceWorkerNetworkProvider for this data source so |
1054 // we can observe its requests. | 1059 // we can observe its requests. |
1055 std::unique_ptr<ServiceWorkerNetworkProvider> provider = | 1060 std::unique_ptr<ServiceWorkerNetworkProvider> provider = |
1056 base::MakeUnique<ServiceWorkerNetworkProvider>( | 1061 base::MakeUnique<ServiceWorkerNetworkProvider>( |
1057 MSG_ROUTING_NONE, SERVICE_WORKER_PROVIDER_FOR_CONTROLLER, | 1062 MSG_ROUTING_NONE, SERVICE_WORKER_PROVIDER_FOR_CONTROLLER, |
1058 true /* is_parent_frame_secure */); | 1063 true /* is_parent_frame_secure */); |
1059 provider_context_ = provider->context(); | 1064 provider_context_ = provider->context(); |
| 1065 network_provider_id_ = provider->provider_id(); |
1060 | 1066 |
1061 // Tell the network provider about which version to load. | 1067 // Tell the network provider about which version to load. |
1062 provider->SetServiceWorkerVersionId(service_worker_version_id_, | 1068 provider->SetServiceWorkerVersionId(service_worker_version_id_, |
1063 embedded_worker_id_); | 1069 embedded_worker_id_); |
1064 | 1070 |
1065 // Blink is responsible for deleting the returned object. | 1071 // Blink is responsible for deleting the returned object. |
1066 return new WebServiceWorkerNetworkProviderImpl(std::move(provider)); | 1072 return new WebServiceWorkerNetworkProviderImpl(std::move(provider)); |
1067 } | 1073 } |
1068 | 1074 |
| 1075 std::unique_ptr<blink::WebWorkerFetchContext> |
| 1076 ServiceWorkerContextClient::CreateServiceWorkerFetchContext() { |
| 1077 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); |
| 1078 DCHECK(base::FeatureList::IsEnabled(features::kOffMainThreadFetch)); |
| 1079 mojom::WorkerURLLoaderFactoryProviderPtr worker_url_loader_factory_provider; |
| 1080 RenderThreadImpl::current() |
| 1081 ->blink_platform_impl() |
| 1082 ->GetInterfaceProvider() |
| 1083 ->GetInterface(mojo::MakeRequest(&worker_url_loader_factory_provider)); |
| 1084 |
| 1085 // Blink is responsible for deleting the returned object. |
| 1086 return base::MakeUnique<ServiceWorkerFetchContextImpl>( |
| 1087 worker_url_loader_factory_provider.PassInterface(), network_provider_id_); |
| 1088 } |
| 1089 |
1069 blink::WebServiceWorkerProvider* | 1090 blink::WebServiceWorkerProvider* |
1070 ServiceWorkerContextClient::CreateServiceWorkerProvider() { | 1091 ServiceWorkerContextClient::CreateServiceWorkerProvider() { |
1071 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); | 1092 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); |
1072 DCHECK(provider_context_); | 1093 DCHECK(provider_context_); |
1073 | 1094 |
1074 // Blink is responsible for deleting the returned object. | 1095 // Blink is responsible for deleting the returned object. |
1075 return new WebServiceWorkerProviderImpl( | 1096 return new WebServiceWorkerProviderImpl( |
1076 sender_.get(), provider_context_.get()); | 1097 sender_.get(), provider_context_.get()); |
1077 } | 1098 } |
1078 | 1099 |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1606 } | 1627 } |
1607 | 1628 |
1608 base::WeakPtr<ServiceWorkerContextClient> | 1629 base::WeakPtr<ServiceWorkerContextClient> |
1609 ServiceWorkerContextClient::GetWeakPtr() { | 1630 ServiceWorkerContextClient::GetWeakPtr() { |
1610 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); | 1631 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); |
1611 DCHECK(context_); | 1632 DCHECK(context_); |
1612 return context_->weak_factory.GetWeakPtr(); | 1633 return context_->weak_factory.GetWeakPtr(); |
1613 } | 1634 } |
1614 | 1635 |
1615 } // namespace content | 1636 } // namespace content |
OLD | NEW |