OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 ConsoleMessage::Create( | 256 ConsoleMessage::Create( |
257 kOtherMessageSource, web_core_message_level, message.text, | 257 kOtherMessageSource, web_core_message_level, message.text, |
258 SourceLocation::Create(message.url, message.line_number, | 258 SourceLocation::Create(message.url, message.line_number, |
259 message.column_number, nullptr))); | 259 message.column_number, nullptr))); |
260 } | 260 } |
261 | 261 |
262 void WebEmbeddedWorkerImpl::PostMessageToPageInspector(const String& message) { | 262 void WebEmbeddedWorkerImpl::PostMessageToPageInspector(const String& message) { |
263 worker_inspector_proxy_->DispatchMessageFromWorker(message); | 263 worker_inspector_proxy_->DispatchMessageFromWorker(message); |
264 } | 264 } |
265 | 265 |
266 void WebEmbeddedWorkerImpl::PostTaskToLoader( | |
267 const WebTraceLocation& location, | |
268 std::unique_ptr<WTF::CrossThreadClosure> task) { | |
269 main_thread_task_runners_->Get(TaskType::kNetworking) | |
270 ->PostTask(BLINK_FROM_HERE, std::move(task)); | |
271 } | |
272 | |
273 void WebEmbeddedWorkerImpl::PostTaskToWorkerGlobalScope( | |
274 const WebTraceLocation& location, | |
275 std::unique_ptr<WTF::CrossThreadClosure> task) { | |
276 if (asked_to_terminate_ || !worker_thread_) | |
277 return; | |
278 TaskRunnerHelper::Get(TaskType::kNetworking, worker_thread_.get()) | |
279 ->PostTask(location, std::move(task)); | |
280 } | |
281 | |
282 ThreadableLoadingContext* WebEmbeddedWorkerImpl::GetThreadableLoadingContext() { | 266 ThreadableLoadingContext* WebEmbeddedWorkerImpl::GetThreadableLoadingContext() { |
283 if (!loading_context_) { | 267 if (!loading_context_) { |
284 loading_context_ = ThreadableLoadingContext::Create( | 268 loading_context_ = ThreadableLoadingContext::Create( |
285 *main_frame_->GetFrame()->GetDocument()); | 269 *main_frame_->GetFrame()->GetDocument()); |
286 } | 270 } |
287 return loading_context_; | 271 return loading_context_; |
288 } | 272 } |
289 | 273 |
290 void WebEmbeddedWorkerImpl::PrepareShadowPageForLoader() { | 274 void WebEmbeddedWorkerImpl::PrepareShadowPageForLoader() { |
291 // Create 'shadow page', which is never displayed and is used mainly to | 275 // Create 'shadow page', which is never displayed and is used mainly to |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 main_script_loader_->SourceText(), | 444 main_script_loader_->SourceText(), |
461 main_script_loader_->ReleaseCachedMetadata(), start_mode, | 445 main_script_loader_->ReleaseCachedMetadata(), start_mode, |
462 document->GetContentSecurityPolicy()->Headers().get(), | 446 document->GetContentSecurityPolicy()->Headers().get(), |
463 main_script_loader_->GetReferrerPolicy(), starter_origin, | 447 main_script_loader_->GetReferrerPolicy(), starter_origin, |
464 worker_clients, main_script_loader_->ResponseAddressSpace(), | 448 worker_clients, main_script_loader_->ResponseAddressSpace(), |
465 main_script_loader_->OriginTrialTokens(), std::move(worker_settings), | 449 main_script_loader_->OriginTrialTokens(), std::move(worker_settings), |
466 worker_v8_settings); | 450 worker_v8_settings); |
467 | 451 |
468 main_script_loader_.Clear(); | 452 main_script_loader_.Clear(); |
469 | 453 |
470 // We have a dummy document here for loading but it doesn't really represent | |
471 // the document/frame of associated document(s) for this worker. Here we | |
472 // populate the task runners with null document not to confuse the frame | |
473 // scheduler (which will end up using the thread's default task runner). | |
474 main_thread_task_runners_ = ParentFrameTaskRunners::Create(nullptr); | |
475 | |
476 worker_global_scope_proxy_ = ServiceWorkerGlobalScopeProxy::Create( | 454 worker_global_scope_proxy_ = ServiceWorkerGlobalScopeProxy::Create( |
477 *this, *document, *worker_context_client_); | 455 *this, *document, *worker_context_client_); |
478 loader_proxy_ = WorkerLoaderProxy::Create(this); | 456 loader_proxy_ = WorkerLoaderProxy::Create(this); |
479 worker_thread_ = | 457 worker_thread_ = |
480 ServiceWorkerThread::Create(loader_proxy_, *worker_global_scope_proxy_); | 458 ServiceWorkerThread::Create(loader_proxy_, *worker_global_scope_proxy_); |
| 459 |
| 460 // We have a dummy document here for loading but it doesn't really represent |
| 461 // the document/frame of associated document(s) for this worker. Here we |
| 462 // populate the task runners with null document not to confuse the frame |
| 463 // scheduler (which will end up using the thread's default task runner). |
481 worker_thread_->Start(std::move(startup_data), | 464 worker_thread_->Start(std::move(startup_data), |
482 main_thread_task_runners_.Get()); | 465 ParentFrameTaskRunners::Create(nullptr)); |
| 466 |
483 worker_inspector_proxy_->WorkerThreadCreated(document, worker_thread_.get(), | 467 worker_inspector_proxy_->WorkerThreadCreated(document, worker_thread_.get(), |
484 script_url); | 468 script_url); |
485 } | 469 } |
486 | 470 |
487 } // namespace blink | 471 } // namespace blink |
OLD | NEW |