| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/shared_worker/embedded_shared_worker_stub.h" | 5 #include "content/renderer/shared_worker/embedded_shared_worker_stub.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/feature_list.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 11 #include "base/threading/thread_task_runner_handle.h" |
| 11 #include "content/child/appcache/appcache_dispatcher.h" | 12 #include "content/child/appcache/appcache_dispatcher.h" |
| 12 #include "content/child/appcache/web_application_cache_host_impl.h" | 13 #include "content/child/appcache/web_application_cache_host_impl.h" |
| 13 #include "content/child/request_extra_data.h" | 14 #include "content/child/request_extra_data.h" |
| 14 #include "content/child/scoped_child_process_reference.h" | 15 #include "content/child/scoped_child_process_reference.h" |
| 15 #include "content/child/service_worker/service_worker_handle_reference.h" | 16 #include "content/child/service_worker/service_worker_handle_reference.h" |
| 16 #include "content/child/service_worker/service_worker_network_provider.h" | 17 #include "content/child/service_worker/service_worker_network_provider.h" |
| 17 #include "content/child/service_worker/service_worker_provider_context.h" | 18 #include "content/child/service_worker/service_worker_provider_context.h" |
| 18 #include "content/child/shared_worker_devtools_agent.h" | 19 #include "content/child/shared_worker_devtools_agent.h" |
| 19 #include "content/child/webmessageportchannel_impl.h" | 20 #include "content/child/webmessageportchannel_impl.h" |
| 20 #include "content/common/worker_messages.h" | 21 #include "content/common/worker_messages.h" |
| 22 #include "content/common/worker_url_loader_factory_provider.mojom.h" |
| 21 #include "content/public/common/appcache_info.h" | 23 #include "content/public/common/appcache_info.h" |
| 24 #include "content/public/common/content_features.h" |
| 22 #include "content/public/common/origin_util.h" | 25 #include "content/public/common/origin_util.h" |
| 23 #include "content/renderer/devtools/devtools_agent.h" | 26 #include "content/renderer/devtools/devtools_agent.h" |
| 24 #include "content/renderer/render_thread_impl.h" | 27 #include "content/renderer/render_thread_impl.h" |
| 28 #include "content/renderer/renderer_blink_platform_impl.h" |
| 29 #include "content/renderer/service_worker/worker_fetch_context_impl.h" |
| 25 #include "content/renderer/shared_worker/embedded_shared_worker_content_settings
_client_proxy.h" | 30 #include "content/renderer/shared_worker/embedded_shared_worker_content_settings
_client_proxy.h" |
| 26 #include "ipc/ipc_message_macros.h" | 31 #include "ipc/ipc_message_macros.h" |
| 32 #include "third_party/WebKit/public/platform/InterfaceProvider.h" |
| 27 #include "third_party/WebKit/public/platform/URLConversion.h" | 33 #include "third_party/WebKit/public/platform/URLConversion.h" |
| 28 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 34 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
| 29 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerNetworkProvider.h" | 35 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerNetworkProvider.h" |
| 30 #include "third_party/WebKit/public/web/WebSharedWorker.h" | 36 #include "third_party/WebKit/public/web/WebSharedWorker.h" |
| 31 #include "third_party/WebKit/public/web/WebSharedWorkerClient.h" | 37 #include "third_party/WebKit/public/web/WebSharedWorkerClient.h" |
| 32 #include "url/origin.h" | 38 #include "url/origin.h" |
| 33 | 39 |
| 34 namespace content { | 40 namespace content { |
| 35 | 41 |
| 36 namespace { | 42 namespace { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 bool IsControlledByServiceWorker() override { | 106 bool IsControlledByServiceWorker() override { |
| 101 return provider_->IsControlledByServiceWorker(); | 107 return provider_->IsControlledByServiceWorker(); |
| 102 } | 108 } |
| 103 | 109 |
| 104 int64_t ServiceWorkerID() override { | 110 int64_t ServiceWorkerID() override { |
| 105 if (provider_->context()->controller()) | 111 if (provider_->context()->controller()) |
| 106 return provider_->context()->controller()->version_id(); | 112 return provider_->context()->controller()->version_id(); |
| 107 return kInvalidServiceWorkerVersionId; | 113 return kInvalidServiceWorkerVersionId; |
| 108 } | 114 } |
| 109 | 115 |
| 116 int GetID() override { return provider_->provider_id(); } |
| 117 |
| 110 private: | 118 private: |
| 111 std::unique_ptr<ServiceWorkerNetworkProvider> provider_; | 119 std::unique_ptr<ServiceWorkerNetworkProvider> provider_; |
| 112 const bool is_secure_context_; | 120 const bool is_secure_context_; |
| 113 }; | 121 }; |
| 114 | 122 |
| 115 } // namespace | 123 } // namespace |
| 116 | 124 |
| 117 EmbeddedSharedWorkerStub::EmbeddedSharedWorkerStub( | 125 EmbeddedSharedWorkerStub::EmbeddedSharedWorkerStub( |
| 118 const GURL& url, | 126 const GURL& url, |
| 119 const base::string16& name, | 127 const base::string16& name, |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 const blink::WebString& state) { | 253 const blink::WebString& state) { |
| 246 worker_devtools_agent_->SendDevToolsMessage( | 254 worker_devtools_agent_->SendDevToolsMessage( |
| 247 session_id, call_id, message, state); | 255 session_id, call_id, message, state); |
| 248 } | 256 } |
| 249 | 257 |
| 250 blink::WebDevToolsAgentClient::WebKitClientMessageLoop* | 258 blink::WebDevToolsAgentClient::WebKitClientMessageLoop* |
| 251 EmbeddedSharedWorkerStub::CreateDevToolsMessageLoop() { | 259 EmbeddedSharedWorkerStub::CreateDevToolsMessageLoop() { |
| 252 return DevToolsAgent::createMessageLoopWrapper(); | 260 return DevToolsAgent::createMessageLoopWrapper(); |
| 253 } | 261 } |
| 254 | 262 |
| 263 blink::WebWorkerFetchContext* |
| 264 EmbeddedSharedWorkerStub::CreateWorkerFetchContext() { |
| 265 if (!base::FeatureList::IsEnabled(features::kOffMainThreadFetch)) |
| 266 return nullptr; |
| 267 mojom::WorkerURLLoaderFactoryProviderPtr worker_url_loader_factory_provider; |
| 268 RenderThreadImpl::current() |
| 269 ->blink_platform_impl() |
| 270 ->GetInterfaceProvider() |
| 271 ->GetInterface(mojo::MakeRequest(&worker_url_loader_factory_provider)); |
| 272 WorkerFetchContextImpl* worker_fetch_context = new WorkerFetchContextImpl( |
| 273 worker_url_loader_factory_provider.PassInterface()); |
| 274 worker_fetch_context->SetIsSecureContext(IsOriginSecure(url_)); |
| 275 blink::WebServiceWorkerNetworkProvider* web_provider = |
| 276 impl_->GetServiceWorkerNetworkProvider(); |
| 277 if (web_provider) { |
| 278 ServiceWorkerNetworkProvider* provider = |
| 279 ServiceWorkerNetworkProvider::FromWebServiceWorkerNetworkProvider( |
| 280 web_provider); |
| 281 worker_fetch_context->SetServiceWorkerProviderID(provider->provider_id()); |
| 282 worker_fetch_context->SetIsControlledByServiceWorker( |
| 283 provider->IsControlledByServiceWorker()); |
| 284 } |
| 285 return worker_fetch_context; |
| 286 } |
| 287 |
| 255 void EmbeddedSharedWorkerStub::Shutdown() { | 288 void EmbeddedSharedWorkerStub::Shutdown() { |
| 256 // WebSharedWorker must be already deleted in the blink side | 289 // WebSharedWorker must be already deleted in the blink side |
| 257 // when this is called. | 290 // when this is called. |
| 258 impl_ = nullptr; | 291 impl_ = nullptr; |
| 259 delete this; | 292 delete this; |
| 260 } | 293 } |
| 261 | 294 |
| 262 bool EmbeddedSharedWorkerStub::Send(IPC::Message* message) { | 295 bool EmbeddedSharedWorkerStub::Send(IPC::Message* message) { |
| 263 return RenderThreadImpl::current()->Send(message); | 296 return RenderThreadImpl::current()->Send(message); |
| 264 } | 297 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 285 } | 318 } |
| 286 } | 319 } |
| 287 | 320 |
| 288 void EmbeddedSharedWorkerStub::OnTerminateWorkerContext() { | 321 void EmbeddedSharedWorkerStub::OnTerminateWorkerContext() { |
| 289 // After this we wouldn't get any IPC for this stub. | 322 // After this we wouldn't get any IPC for this stub. |
| 290 running_ = false; | 323 running_ = false; |
| 291 impl_->TerminateWorkerContext(); | 324 impl_->TerminateWorkerContext(); |
| 292 } | 325 } |
| 293 | 326 |
| 294 } // namespace content | 327 } // namespace content |
| OLD | NEW |