| 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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 SourceLocation::create(message.url, message.lineNumber, | 255 SourceLocation::create(message.url, message.lineNumber, |
| 256 message.columnNumber, nullptr))); | 256 message.columnNumber, nullptr))); |
| 257 } | 257 } |
| 258 | 258 |
| 259 void WebEmbeddedWorkerImpl::postMessageToPageInspector(const String& message) { | 259 void WebEmbeddedWorkerImpl::postMessageToPageInspector(const String& message) { |
| 260 m_workerInspectorProxy->dispatchMessageFromWorker(message); | 260 m_workerInspectorProxy->dispatchMessageFromWorker(message); |
| 261 } | 261 } |
| 262 | 262 |
| 263 void WebEmbeddedWorkerImpl::postTaskToLoader( | 263 void WebEmbeddedWorkerImpl::postTaskToLoader( |
| 264 const WebTraceLocation& location, | 264 const WebTraceLocation& location, |
| 265 std::unique_ptr<ExecutionContextTask> task) { | 265 std::unique_ptr<WTF::CrossThreadClosure> task) { |
| 266 // This cross-thread operation is brittle wrt per-thread heaps, | |
| 267 // posting a task to main-thread owned objects. | |
| 268 m_mainThreadTaskRunners->get(TaskType::Networking) | 266 m_mainThreadTaskRunners->get(TaskType::Networking) |
| 269 ->postTask( | 267 ->postTask(BLINK_FROM_HERE, std::move(task)); |
| 270 BLINK_FROM_HERE, | |
| 271 crossThreadBind( | |
| 272 &ExecutionContextTask::performTaskIfContextIsValid, | |
| 273 WTF::passed(std::move(task)), | |
| 274 wrapCrossThreadWeakPersistent(m_mainFrame->frame()->document()))); | |
| 275 } | 268 } |
| 276 | 269 |
| 277 void WebEmbeddedWorkerImpl::postTaskToWorkerGlobalScope( | 270 void WebEmbeddedWorkerImpl::postTaskToWorkerGlobalScope( |
| 278 const WebTraceLocation& location, | 271 const WebTraceLocation& location, |
| 279 std::unique_ptr<WTF::CrossThreadClosure> task) { | 272 std::unique_ptr<WTF::CrossThreadClosure> task) { |
| 280 if (m_askedToTerminate || !m_workerThread) | 273 if (m_askedToTerminate || !m_workerThread) |
| 281 return; | 274 return; |
| 282 m_workerThread->postTask(location, std::move(task)); | 275 m_workerThread->postTask(location, std::move(task)); |
| 283 } | 276 } |
| 284 | 277 |
| 278 ExecutionContext* WebEmbeddedWorkerImpl::getLoaderExecutionContext() { |
| 279 return m_mainFrame->frame()->document(); |
| 280 } |
| 281 |
| 285 void WebEmbeddedWorkerImpl::prepareShadowPageForLoader() { | 282 void WebEmbeddedWorkerImpl::prepareShadowPageForLoader() { |
| 286 // Create 'shadow page', which is never displayed and is used mainly to | 283 // Create 'shadow page', which is never displayed and is used mainly to |
| 287 // provide a context for loading on the main thread. | 284 // provide a context for loading on the main thread. |
| 288 // | 285 // |
| 289 // FIXME: This does mostly same as WebSharedWorkerImpl::initializeLoader. | 286 // FIXME: This does mostly same as WebSharedWorkerImpl::initializeLoader. |
| 290 // This code, and probably most of the code in this class should be shared | 287 // This code, and probably most of the code in this class should be shared |
| 291 // with SharedWorker. | 288 // with SharedWorker. |
| 292 DCHECK(!m_webView); | 289 DCHECK(!m_webView); |
| 293 m_webView = WebView::create(nullptr, WebPageVisibilityStateVisible); | 290 m_webView = WebView::create(nullptr, WebPageVisibilityStateVisible); |
| 294 WebSettings* settings = m_webView->settings(); | 291 WebSettings* settings = m_webView->settings(); |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 *this, *document, *m_workerContextClient); | 474 *this, *document, *m_workerContextClient); |
| 478 m_loaderProxy = WorkerLoaderProxy::create(this); | 475 m_loaderProxy = WorkerLoaderProxy::create(this); |
| 479 m_workerThread = ServiceWorkerThread::create( | 476 m_workerThread = ServiceWorkerThread::create( |
| 480 m_loaderProxy, *m_workerGlobalScopeProxy, m_mainThreadTaskRunners.get()); | 477 m_loaderProxy, *m_workerGlobalScopeProxy, m_mainThreadTaskRunners.get()); |
| 481 m_workerThread->start(std::move(startupData)); | 478 m_workerThread->start(std::move(startupData)); |
| 482 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(), | 479 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(), |
| 483 scriptURL); | 480 scriptURL); |
| 484 } | 481 } |
| 485 | 482 |
| 486 } // namespace blink | 483 } // namespace blink |
| OLD | NEW |