| 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/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
| 11 #include "content/child/appcache/appcache_dispatcher.h" | 11 #include "content/child/appcache/appcache_dispatcher.h" |
| 12 #include "content/child/appcache/web_application_cache_host_impl.h" | 12 #include "content/child/appcache/web_application_cache_host_impl.h" |
| 13 #include "content/child/request_extra_data.h" | 13 #include "content/child/request_extra_data.h" |
| 14 #include "content/child/scoped_child_process_reference.h" | 14 #include "content/child/scoped_child_process_reference.h" |
| 15 #include "content/child/service_worker/service_worker_handle_reference.h" | 15 #include "content/child/service_worker/service_worker_handle_reference.h" |
| 16 #include "content/child/service_worker/service_worker_network_provider.h" | 16 #include "content/child/service_worker/service_worker_network_provider.h" |
| 17 #include "content/child/service_worker/service_worker_provider_context.h" | 17 #include "content/child/service_worker/service_worker_provider_context.h" |
| 18 #include "content/child/shared_worker_devtools_agent.h" | 18 #include "content/child/shared_worker_devtools_agent.h" |
| 19 #include "content/child/webmessageportchannel_impl.h" | 19 #include "content/child/webmessageportchannel_impl.h" |
| 20 #include "content/common/worker_messages.h" | 20 #include "content/common/worker_messages.h" |
| 21 #include "content/renderer/render_thread_impl.h" | 21 #include "content/renderer/render_thread_impl.h" |
| 22 #include "content/renderer/shared_worker/embedded_shared_worker_content_settings
_client_proxy.h" | 22 #include "content/renderer/shared_worker/embedded_shared_worker_content_settings
_client_proxy.h" |
| 23 #include "ipc/ipc_message_macros.h" | 23 #include "ipc/ipc_message_macros.h" |
| 24 #include "third_party/WebKit/public/platform/URLConversion.h" | 24 #include "third_party/WebKit/public/platform/URLConversion.h" |
| 25 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 25 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
| 26 #include "third_party/WebKit/public/platform/WebURLRequest.h" | |
| 27 #include "third_party/WebKit/public/web/WebDataSource.h" | 26 #include "third_party/WebKit/public/web/WebDataSource.h" |
| 28 #include "third_party/WebKit/public/web/WebSharedWorker.h" | 27 #include "third_party/WebKit/public/web/WebSharedWorker.h" |
| 29 #include "third_party/WebKit/public/web/WebSharedWorkerClient.h" | 28 #include "third_party/WebKit/public/web/WebSharedWorkerClient.h" |
| 30 #include "third_party/WebKit/public/web/modules/serviceworker/WebServiceWorkerNe
tworkProvider.h" | 29 #include "third_party/WebKit/public/web/modules/serviceworker/WebServiceWorkerNe
tworkProvider.h" |
| 31 | 30 |
| 32 namespace content { | 31 namespace content { |
| 33 | 32 |
| 34 namespace { | 33 namespace { |
| 35 | 34 |
| 36 class SharedWorkerWebApplicationCacheHostImpl | 35 class SharedWorkerWebApplicationCacheHostImpl |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 } | 117 } |
| 119 }; | 118 }; |
| 120 | 119 |
| 121 } // namespace | 120 } // namespace |
| 122 | 121 |
| 123 EmbeddedSharedWorkerStub::EmbeddedSharedWorkerStub( | 122 EmbeddedSharedWorkerStub::EmbeddedSharedWorkerStub( |
| 124 const GURL& url, | 123 const GURL& url, |
| 125 const base::string16& name, | 124 const base::string16& name, |
| 126 const base::string16& content_security_policy, | 125 const base::string16& content_security_policy, |
| 127 blink::WebContentSecurityPolicyType security_policy_type, | 126 blink::WebContentSecurityPolicyType security_policy_type, |
| 127 blink::WebAddressSpace creation_address_space, |
| 128 bool pause_on_start, | 128 bool pause_on_start, |
| 129 int route_id) | 129 int route_id) |
| 130 : route_id_(route_id), | 130 : route_id_(route_id), name_(name), url_(url) { |
| 131 name_(name), | |
| 132 url_(url) { | |
| 133 RenderThreadImpl::current()->AddEmbeddedWorkerRoute(route_id_, this); | 131 RenderThreadImpl::current()->AddEmbeddedWorkerRoute(route_id_, this); |
| 134 impl_ = blink::WebSharedWorker::create(this); | 132 impl_ = blink::WebSharedWorker::create(this); |
| 135 if (pause_on_start) { | 133 if (pause_on_start) { |
| 136 // Pause worker context when it starts and wait until either DevTools client | 134 // Pause worker context when it starts and wait until either DevTools client |
| 137 // is attached or explicit resume notification is received. | 135 // is attached or explicit resume notification is received. |
| 138 impl_->pauseWorkerContextOnStart(); | 136 impl_->pauseWorkerContextOnStart(); |
| 139 } | 137 } |
| 140 worker_devtools_agent_.reset( | 138 worker_devtools_agent_.reset( |
| 141 new SharedWorkerDevToolsAgent(route_id, impl_)); | 139 new SharedWorkerDevToolsAgent(route_id, impl_)); |
| 142 impl_->startWorkerContext(url, name_, | 140 impl_->startWorkerContext(url, name_, content_security_policy, |
| 143 content_security_policy, security_policy_type); | 141 security_policy_type, creation_address_space); |
| 144 } | 142 } |
| 145 | 143 |
| 146 EmbeddedSharedWorkerStub::~EmbeddedSharedWorkerStub() { | 144 EmbeddedSharedWorkerStub::~EmbeddedSharedWorkerStub() { |
| 147 RenderThreadImpl::current()->RemoveEmbeddedWorkerRoute(route_id_); | 145 RenderThreadImpl::current()->RemoveEmbeddedWorkerRoute(route_id_); |
| 148 DCHECK(!impl_); | 146 DCHECK(!impl_); |
| 149 } | 147 } |
| 150 | 148 |
| 151 bool EmbeddedSharedWorkerStub::OnMessageReceived( | 149 bool EmbeddedSharedWorkerStub::OnMessageReceived( |
| 152 const IPC::Message& message) { | 150 const IPC::Message& message) { |
| 153 if (worker_devtools_agent_->OnMessageReceived(message)) | 151 if (worker_devtools_agent_->OnMessageReceived(message)) |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 } | 298 } |
| 301 } | 299 } |
| 302 | 300 |
| 303 void EmbeddedSharedWorkerStub::OnTerminateWorkerContext() { | 301 void EmbeddedSharedWorkerStub::OnTerminateWorkerContext() { |
| 304 // After this we wouldn't get any IPC for this stub. | 302 // After this we wouldn't get any IPC for this stub. |
| 305 running_ = false; | 303 running_ = false; |
| 306 impl_->terminateWorkerContext(); | 304 impl_->terminateWorkerContext(); |
| 307 } | 305 } |
| 308 | 306 |
| 309 } // namespace content | 307 } // namespace content |
| OLD | NEW |