Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(497)

Side by Side Diff: content/renderer/service_worker/service_worker_context_client.cc

Issue 2804843005: Implement the infrastructure of creating WorkerFetchContext in worker global scope. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 20 matching lines...) Expand all
31 #include "content/child/thread_safe_sender.h" 31 #include "content/child/thread_safe_sender.h"
32 #include "content/child/web_data_consumer_handle_impl.h" 32 #include "content/child/web_data_consumer_handle_impl.h"
33 #include "content/child/web_url_loader_impl.h" 33 #include "content/child/web_url_loader_impl.h"
34 #include "content/child/webmessageportchannel_impl.h" 34 #include "content/child/webmessageportchannel_impl.h"
35 #include "content/common/devtools_messages.h" 35 #include "content/common/devtools_messages.h"
36 #include "content/common/service_worker/embedded_worker_messages.h" 36 #include "content/common/service_worker/embedded_worker_messages.h"
37 #include "content/common/service_worker/service_worker_event_dispatcher.mojom.h" 37 #include "content/common/service_worker/service_worker_event_dispatcher.mojom.h"
38 #include "content/common/service_worker/service_worker_messages.h" 38 #include "content/common/service_worker/service_worker_messages.h"
39 #include "content/common/service_worker/service_worker_status_code.h" 39 #include "content/common/service_worker/service_worker_status_code.h"
40 #include "content/common/service_worker/service_worker_utils.h" 40 #include "content/common/service_worker/service_worker_utils.h"
41 #include "content/common/worker_fetch_context_factory.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_dispatcher.h" 51 #include "content/renderer/service_worker/embedded_worker_dispatcher.h"
49 #include "content/renderer/service_worker/embedded_worker_instance_client_impl.h " 52 #include "content/renderer/service_worker/embedded_worker_instance_client_impl.h "
53 #include "content/renderer/service_worker/service_worker_fetch_context_info_impl .h"
50 #include "content/renderer/service_worker/service_worker_type_converters.h" 54 #include "content/renderer/service_worker/service_worker_type_converters.h"
51 #include "content/renderer/service_worker/service_worker_type_util.h" 55 #include "content/renderer/service_worker/service_worker_type_util.h"
52 #include "ipc/ipc_message.h" 56 #include "ipc/ipc_message.h"
53 #include "ipc/ipc_message_macros.h" 57 #include "ipc/ipc_message_macros.h"
54 #include "net/base/net_errors.h" 58 #include "net/base/net_errors.h"
55 #include "net/http/http_response_headers.h" 59 #include "net/http/http_response_headers.h"
60 #include "third_party/WebKit/public/platform/InterfaceProvider.h"
56 #include "third_party/WebKit/public/platform/URLConversion.h" 61 #include "third_party/WebKit/public/platform/URLConversion.h"
57 #include "third_party/WebKit/public/platform/WebMessagePortChannel.h" 62 #include "third_party/WebKit/public/platform/WebMessagePortChannel.h"
58 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" 63 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h"
59 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" 64 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
60 #include "third_party/WebKit/public/platform/WebString.h" 65 #include "third_party/WebKit/public/platform/WebString.h"
61 #include "third_party/WebKit/public/platform/WebURLResponse.h" 66 #include "third_party/WebKit/public/platform/WebURLResponse.h"
62 #include "third_party/WebKit/public/platform/modules/background_fetch/WebBackgro undFetchSettledFetch.h" 67 #include "third_party/WebKit/public/platform/modules/background_fetch/WebBackgro undFetchSettledFetch.h"
63 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati onData.h" 68 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati onData.h"
64 #include "third_party/WebKit/public/platform/modules/payments/WebPaymentAppReque st.h" 69 #include "third_party/WebKit/public/platform/modules/payments/WebPaymentAppReque st.h"
65 #include "third_party/WebKit/public/platform/modules/payments/WebPaymentAppRespo nse.h" 70 #include "third_party/WebKit/public/platform/modules/payments/WebPaymentAppRespo nse.h"
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 ServiceWorkerContextClient::CreateServiceWorkerNetworkProvider() { 994 ServiceWorkerContextClient::CreateServiceWorkerNetworkProvider() {
990 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); 995 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread());
991 996
992 // Create a content::ServiceWorkerNetworkProvider for this data source so 997 // Create a content::ServiceWorkerNetworkProvider for this data source so
993 // we can observe its requests. 998 // we can observe its requests.
994 std::unique_ptr<ServiceWorkerNetworkProvider> provider = 999 std::unique_ptr<ServiceWorkerNetworkProvider> provider =
995 base::MakeUnique<ServiceWorkerNetworkProvider>( 1000 base::MakeUnique<ServiceWorkerNetworkProvider>(
996 MSG_ROUTING_NONE, SERVICE_WORKER_PROVIDER_FOR_CONTROLLER, 1001 MSG_ROUTING_NONE, SERVICE_WORKER_PROVIDER_FOR_CONTROLLER,
997 true /* is_parent_frame_secure */); 1002 true /* is_parent_frame_secure */);
998 provider_context_ = provider->context(); 1003 provider_context_ = provider->context();
1004 network_provider_id_ = provider->provider_id();
999 1005
1000 // Tell the network provider about which version to load. 1006 // Tell the network provider about which version to load.
1001 provider->SetServiceWorkerVersionId(service_worker_version_id_, 1007 provider->SetServiceWorkerVersionId(service_worker_version_id_,
1002 embedded_worker_id_); 1008 embedded_worker_id_);
1003 1009
1004 // Blink is responsible for deleting the returned object. 1010 // Blink is responsible for deleting the returned object.
1005 return new WebServiceWorkerNetworkProviderImpl(std::move(provider)); 1011 return new WebServiceWorkerNetworkProviderImpl(std::move(provider));
1006 } 1012 }
1007 1013
1014 blink::WebWorkerFetchContextInfo*
1015 ServiceWorkerContextClient::CreateServiceWorkerFetchContextInfo() {
1016 if (!base::FeatureList::IsEnabled(features::kOffMainThreadFetch))
1017 return nullptr;
1018 mojom::WorkerFetchContextFactoryPtr worker_fetch_context_factory;
1019 RenderThreadImpl::current()
1020 ->blink_platform_impl()
1021 ->GetInterfaceProvider()
1022 ->GetInterface(mojo::MakeRequest(&worker_fetch_context_factory));
1023
1024 // Blink is responsible for deleting the returned object.
1025 return new ServiceWorkerFetchContextInfoImpl(
1026 worker_fetch_context_factory.PassInterface(), network_provider_id_);
1027 }
1028
1008 blink::WebServiceWorkerProvider* 1029 blink::WebServiceWorkerProvider*
1009 ServiceWorkerContextClient::CreateServiceWorkerProvider() { 1030 ServiceWorkerContextClient::CreateServiceWorkerProvider() {
1010 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); 1031 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread());
1011 DCHECK(provider_context_); 1032 DCHECK(provider_context_);
1012 1033
1013 // Blink is responsible for deleting the returned object. 1034 // Blink is responsible for deleting the returned object.
1014 return new WebServiceWorkerProviderImpl( 1035 return new WebServiceWorkerProviderImpl(
1015 sender_.get(), provider_context_.get()); 1036 sender_.get(), provider_context_.get());
1016 } 1037 }
1017 1038
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
1542 } 1563 }
1543 1564
1544 base::WeakPtr<ServiceWorkerContextClient> 1565 base::WeakPtr<ServiceWorkerContextClient>
1545 ServiceWorkerContextClient::GetWeakPtr() { 1566 ServiceWorkerContextClient::GetWeakPtr() {
1546 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); 1567 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread());
1547 DCHECK(context_); 1568 DCHECK(context_);
1548 return context_->weak_factory.GetWeakPtr(); 1569 return context_->weak_factory.GetWeakPtr();
1549 } 1570 }
1550 1571
1551 } // namespace content 1572 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698