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

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: incorporated kinuko's comment 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 19 matching lines...) Expand all
30 #include "content/child/service_worker/web_service_worker_registration_impl.h" 30 #include "content/child/service_worker/web_service_worker_registration_impl.h"
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/worker_url_loader_factory_provider.mojom.h"
41 #include "content/public/common/content_features.h"
40 #include "content/public/common/push_event_payload.h" 42 #include "content/public/common/push_event_payload.h"
41 #include "content/public/common/referrer.h" 43 #include "content/public/common/referrer.h"
42 #include "content/public/renderer/content_renderer_client.h" 44 #include "content/public/renderer/content_renderer_client.h"
43 #include "content/public/renderer/document_state.h" 45 #include "content/public/renderer/document_state.h"
44 #include "content/renderer/devtools/devtools_agent.h" 46 #include "content/renderer/devtools/devtools_agent.h"
45 #include "content/renderer/render_thread_impl.h" 47 #include "content/renderer/render_thread_impl.h"
48 #include "content/renderer/renderer_blink_platform_impl.h"
46 #include "content/renderer/service_worker/embedded_worker_devtools_agent.h" 49 #include "content/renderer/service_worker/embedded_worker_devtools_agent.h"
47 #include "content/renderer/service_worker/embedded_worker_instance_client_impl.h " 50 #include "content/renderer/service_worker/embedded_worker_instance_client_impl.h "
51 #include "content/renderer/service_worker/service_worker_fetch_context_impl.h"
48 #include "content/renderer/service_worker/service_worker_type_converters.h" 52 #include "content/renderer/service_worker/service_worker_type_converters.h"
49 #include "content/renderer/service_worker/service_worker_type_util.h" 53 #include "content/renderer/service_worker/service_worker_type_util.h"
50 #include "ipc/ipc_message.h" 54 #include "ipc/ipc_message.h"
51 #include "ipc/ipc_message_macros.h" 55 #include "ipc/ipc_message_macros.h"
52 #include "net/base/net_errors.h" 56 #include "net/base/net_errors.h"
53 #include "net/http/http_response_headers.h" 57 #include "net/http/http_response_headers.h"
58 #include "third_party/WebKit/public/platform/InterfaceProvider.h"
54 #include "third_party/WebKit/public/platform/URLConversion.h" 59 #include "third_party/WebKit/public/platform/URLConversion.h"
55 #include "third_party/WebKit/public/platform/WebMessagePortChannel.h" 60 #include "third_party/WebKit/public/platform/WebMessagePortChannel.h"
56 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h" 61 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h"
57 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" 62 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
58 #include "third_party/WebKit/public/platform/WebString.h" 63 #include "third_party/WebKit/public/platform/WebString.h"
59 #include "third_party/WebKit/public/platform/WebURLResponse.h" 64 #include "third_party/WebKit/public/platform/WebURLResponse.h"
60 #include "third_party/WebKit/public/platform/modules/background_fetch/WebBackgro undFetchSettledFetch.h" 65 #include "third_party/WebKit/public/platform/modules/background_fetch/WebBackgro undFetchSettledFetch.h"
61 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati onData.h" 66 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati onData.h"
62 #include "third_party/WebKit/public/platform/modules/payments/WebPaymentAppReque st.h" 67 #include "third_party/WebKit/public/platform/modules/payments/WebPaymentAppReque st.h"
63 #include "third_party/WebKit/public/platform/modules/payments/WebPaymentAppRespo nse.h" 68 #include "third_party/WebKit/public/platform/modules/payments/WebPaymentAppRespo nse.h"
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 ServiceWorkerContextClient::CreateServiceWorkerNetworkProvider() { 990 ServiceWorkerContextClient::CreateServiceWorkerNetworkProvider() {
986 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); 991 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread());
987 992
988 // Create a content::ServiceWorkerNetworkProvider for this data source so 993 // Create a content::ServiceWorkerNetworkProvider for this data source so
989 // we can observe its requests. 994 // we can observe its requests.
990 std::unique_ptr<ServiceWorkerNetworkProvider> provider = 995 std::unique_ptr<ServiceWorkerNetworkProvider> provider =
991 base::MakeUnique<ServiceWorkerNetworkProvider>( 996 base::MakeUnique<ServiceWorkerNetworkProvider>(
992 MSG_ROUTING_NONE, SERVICE_WORKER_PROVIDER_FOR_CONTROLLER, 997 MSG_ROUTING_NONE, SERVICE_WORKER_PROVIDER_FOR_CONTROLLER,
993 true /* is_parent_frame_secure */); 998 true /* is_parent_frame_secure */);
994 provider_context_ = provider->context(); 999 provider_context_ = provider->context();
1000 network_provider_id_ = provider->provider_id();
995 1001
996 // Tell the network provider about which version to load. 1002 // Tell the network provider about which version to load.
997 provider->SetServiceWorkerVersionId(service_worker_version_id_, 1003 provider->SetServiceWorkerVersionId(service_worker_version_id_,
998 embedded_worker_id_); 1004 embedded_worker_id_);
999 1005
1000 // Blink is responsible for deleting the returned object. 1006 // Blink is responsible for deleting the returned object.
1001 return new WebServiceWorkerNetworkProviderImpl(std::move(provider)); 1007 return new WebServiceWorkerNetworkProviderImpl(std::move(provider));
1002 } 1008 }
1003 1009
1010 blink::WebWorkerFetchContext*
1011 ServiceWorkerContextClient::CreateServiceWorkerFetchContext() {
nhiroki 2017/04/20 04:16:06 DCHECK(main_thread_task_runner_->RunsTasksOnCurren
horo 2017/04/20 08:35:43 Done.
1012 if (!base::FeatureList::IsEnabled(features::kOffMainThreadFetch))
nhiroki 2017/04/20 04:16:06 DCHECK(base::FeatureList::IsEnabled(features::kOff
horo 2017/04/20 08:35:43 Done.
1013 return nullptr;
1014 mojom::WorkerURLLoaderFactoryProviderPtr worker_url_loader_factory_provider;
1015 RenderThreadImpl::current()
1016 ->blink_platform_impl()
1017 ->GetInterfaceProvider()
1018 ->GetInterface(mojo::MakeRequest(&worker_url_loader_factory_provider));
1019
1020 // Blink is responsible for deleting the returned object.
1021 return new ServiceWorkerFetchContextImpl(
1022 worker_url_loader_factory_provider.PassInterface(), network_provider_id_);
1023 }
1024
1004 blink::WebServiceWorkerProvider* 1025 blink::WebServiceWorkerProvider*
1005 ServiceWorkerContextClient::CreateServiceWorkerProvider() { 1026 ServiceWorkerContextClient::CreateServiceWorkerProvider() {
1006 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); 1027 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread());
1007 DCHECK(provider_context_); 1028 DCHECK(provider_context_);
1008 1029
1009 // Blink is responsible for deleting the returned object. 1030 // Blink is responsible for deleting the returned object.
1010 return new WebServiceWorkerProviderImpl( 1031 return new WebServiceWorkerProviderImpl(
1011 sender_.get(), provider_context_.get()); 1032 sender_.get(), provider_context_.get());
1012 } 1033 }
1013 1034
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
1538 } 1559 }
1539 1560
1540 base::WeakPtr<ServiceWorkerContextClient> 1561 base::WeakPtr<ServiceWorkerContextClient>
1541 ServiceWorkerContextClient::GetWeakPtr() { 1562 ServiceWorkerContextClient::GetWeakPtr() {
1542 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread()); 1563 DCHECK(worker_task_runner_->RunsTasksOnCurrentThread());
1543 DCHECK(context_); 1564 DCHECK(context_);
1544 return context_->weak_factory.GetWeakPtr(); 1565 return context_->weak_factory.GetWeakPtr();
1545 } 1566 }
1546 1567
1547 } // namespace content 1568 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698