OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 14 matching lines...) Expand all Loading... |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "web/WebSharedWorkerImpl.h" | 31 #include "web/WebSharedWorkerImpl.h" |
32 | 32 |
33 #include <memory> | 33 #include <memory> |
34 #include "core/dom/Document.h" | 34 #include "core/dom/Document.h" |
| 35 #include "core/dom/TaskRunnerHelper.h" |
35 #include "core/events/MessageEvent.h" | 36 #include "core/events/MessageEvent.h" |
36 #include "core/inspector/ConsoleMessage.h" | 37 #include "core/inspector/ConsoleMessage.h" |
37 #include "core/loader/FrameLoadRequest.h" | 38 #include "core/loader/FrameLoadRequest.h" |
38 #include "core/loader/FrameLoader.h" | 39 #include "core/loader/FrameLoader.h" |
39 #include "core/loader/ThreadableLoadingContext.h" | 40 #include "core/loader/ThreadableLoadingContext.h" |
40 #include "core/probe/CoreProbes.h" | 41 #include "core/probe/CoreProbes.h" |
41 #include "core/workers/ParentFrameTaskRunners.h" | 42 #include "core/workers/ParentFrameTaskRunners.h" |
42 #include "core/workers/SharedWorkerGlobalScope.h" | 43 #include "core/workers/SharedWorkerGlobalScope.h" |
43 #include "core/workers/SharedWorkerThread.h" | 44 #include "core/workers/SharedWorkerThread.h" |
44 #include "core/workers/WorkerClients.h" | 45 #include "core/workers/WorkerClients.h" |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 std::unique_ptr<WTF::CrossThreadClosure> task) { | 248 std::unique_ptr<WTF::CrossThreadClosure> task) { |
248 DCHECK(worker_thread_->IsCurrentThread()); | 249 DCHECK(worker_thread_->IsCurrentThread()); |
249 parent_frame_task_runners_->Get(TaskType::kNetworking) | 250 parent_frame_task_runners_->Get(TaskType::kNetworking) |
250 ->PostTask(FROM_HERE, std::move(task)); | 251 ->PostTask(FROM_HERE, std::move(task)); |
251 } | 252 } |
252 | 253 |
253 void WebSharedWorkerImpl::PostTaskToWorkerGlobalScope( | 254 void WebSharedWorkerImpl::PostTaskToWorkerGlobalScope( |
254 const WebTraceLocation& location, | 255 const WebTraceLocation& location, |
255 std::unique_ptr<WTF::CrossThreadClosure> task) { | 256 std::unique_ptr<WTF::CrossThreadClosure> task) { |
256 DCHECK(IsMainThread()); | 257 DCHECK(IsMainThread()); |
257 worker_thread_->PostTask(location, std::move(task)); | 258 TaskRunnerHelper::Get(TaskType::kNetworking, GetWorkerThread()) |
| 259 ->PostTask(location, std::move(task)); |
258 } | 260 } |
259 | 261 |
260 ThreadableLoadingContext* WebSharedWorkerImpl::GetThreadableLoadingContext() { | 262 ThreadableLoadingContext* WebSharedWorkerImpl::GetThreadableLoadingContext() { |
261 if (!loading_context_) { | 263 if (!loading_context_) { |
262 loading_context_ = | 264 loading_context_ = |
263 ThreadableLoadingContext::Create(*ToDocument(loading_document_.Get())); | 265 ThreadableLoadingContext::Create(*ToDocument(loading_document_.Get())); |
264 } | 266 } |
265 return loading_context_; | 267 return loading_context_; |
266 } | 268 } |
267 | 269 |
268 void WebSharedWorkerImpl::Connect( | 270 void WebSharedWorkerImpl::Connect( |
269 std::unique_ptr<WebMessagePortChannel> web_channel) { | 271 std::unique_ptr<WebMessagePortChannel> web_channel) { |
270 DCHECK(IsMainThread()); | 272 DCHECK(IsMainThread()); |
271 GetWorkerThread()->PostTask( | 273 TaskRunnerHelper::Get(TaskType::kDOMManipulation, GetWorkerThread()) |
272 BLINK_FROM_HERE, | 274 ->PostTask( |
273 CrossThreadBind(&WebSharedWorkerImpl::ConnectTaskOnWorkerThread, | 275 BLINK_FROM_HERE, |
274 WTF::CrossThreadUnretained(this), | 276 CrossThreadBind(&WebSharedWorkerImpl::ConnectTaskOnWorkerThread, |
275 WTF::Passed(std::move(web_channel)))); | 277 WTF::CrossThreadUnretained(this), |
| 278 WTF::Passed(std::move(web_channel)))); |
276 } | 279 } |
277 | 280 |
278 void WebSharedWorkerImpl::ConnectTaskOnWorkerThread( | 281 void WebSharedWorkerImpl::ConnectTaskOnWorkerThread( |
279 std::unique_ptr<WebMessagePortChannel> channel) { | 282 std::unique_ptr<WebMessagePortChannel> channel) { |
280 // Wrap the passed-in channel in a MessagePort, and send it off via a connect | 283 // Wrap the passed-in channel in a MessagePort, and send it off via a connect |
281 // event. | 284 // event. |
282 DCHECK(worker_thread_->IsCurrentThread()); | 285 DCHECK(worker_thread_->IsCurrentThread()); |
283 WorkerGlobalScope* worker_global_scope = | 286 WorkerGlobalScope* worker_global_scope = |
284 ToWorkerGlobalScope(worker_thread_->GlobalScope()); | 287 ToWorkerGlobalScope(worker_thread_->GlobalScope()); |
285 MessagePort* port = MessagePort::Create(*worker_global_scope); | 288 MessagePort* port = MessagePort::Create(*worker_global_scope); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 if (devtools_agent) | 424 if (devtools_agent) |
422 devtools_agent->DispatchOnInspectorBackend(session_id, call_id, method, | 425 devtools_agent->DispatchOnInspectorBackend(session_id, call_id, method, |
423 message); | 426 message); |
424 } | 427 } |
425 | 428 |
426 WebSharedWorker* WebSharedWorker::Create(WebSharedWorkerClient* client) { | 429 WebSharedWorker* WebSharedWorker::Create(WebSharedWorkerClient* client) { |
427 return new WebSharedWorkerImpl(client); | 430 return new WebSharedWorkerImpl(client); |
428 } | 431 } |
429 | 432 |
430 } // namespace blink | 433 } // namespace blink |
OLD | NEW |