Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "modules/compositorworker/CompositorWorker.h" | 5 #include "modules/compositorworker/CompositorWorker.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
| 8 #include "core/dom/CompositorProxyClient.h" | |
| 8 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" |
| 9 #include "core/dom/ExceptionCode.h" | 10 #include "core/dom/ExceptionCode.h" |
| 11 #include "core/page/ChromeClient.h" | |
| 10 #include "core/workers/WorkerClients.h" | 12 #include "core/workers/WorkerClients.h" |
| 11 #include "modules/EventTargetModules.h" | 13 #include "modules/EventTargetModules.h" |
| 12 #include "modules/compositorworker/CompositorWorkerMessagingProxy.h" | 14 #include "modules/compositorworker/CompositorWorkerMessagingProxy.h" |
| 15 #include "modules/compositorworker/CompositorWorkerThread.h" | |
| 13 | 16 |
| 14 namespace blink { | 17 namespace blink { |
| 15 | 18 |
| 16 inline CompositorWorker::CompositorWorker(ExecutionContext* context) | 19 inline CompositorWorker::CompositorWorker(ExecutionContext* context) |
| 17 : InProcessWorkerBase(context) | 20 : InProcessWorkerBase(context) |
| 18 { | 21 { |
| 19 } | 22 } |
| 20 | 23 |
| 21 CompositorWorker* CompositorWorker::create(ExecutionContext* context, const Stri ng& url, ExceptionState& exceptionState) | 24 CompositorWorker* CompositorWorker::create(ExecutionContext* context, const Stri ng& url, ExceptionState& exceptionState) |
| 22 { | 25 { |
| 26 // Ensure the compositor worker backing thread is ready. | |
| 27 CompositorWorkerThread::ensureSharedBackingThread(); | |
| 28 | |
| 23 ASSERT(isMainThread()); | 29 ASSERT(isMainThread()); |
| 24 Document* document = toDocument(context); | 30 Document* document = toDocument(context); |
| 25 if (!document->page()) { | 31 if (!document->page()) { |
| 26 exceptionState.throwDOMException(InvalidAccessError, "The context provid ed is invalid."); | 32 exceptionState.throwDOMException(InvalidAccessError, "The context provid ed is invalid."); |
| 27 return nullptr; | 33 return nullptr; |
| 28 } | 34 } |
| 29 CompositorWorker* worker = new CompositorWorker(context); | 35 CompositorWorker* worker = new CompositorWorker(context); |
| 30 if (worker->initialize(context, url, exceptionState)) | 36 if (worker->initialize(context, url, exceptionState)) |
| 31 return worker; | 37 return worker; |
| 32 return nullptr; | 38 return nullptr; |
| 33 } | 39 } |
| 34 | 40 |
| 35 CompositorWorker::~CompositorWorker() | 41 CompositorWorker::~CompositorWorker() |
| 36 { | 42 { |
| 37 ASSERT(isMainThread()); | 43 ASSERT(isMainThread()); |
| 38 } | 44 } |
| 39 | 45 |
| 40 const AtomicString& CompositorWorker::interfaceName() const | 46 const AtomicString& CompositorWorker::interfaceName() const |
| 41 { | 47 { |
| 42 return EventTargetNames::CompositorWorker; | 48 return EventTargetNames::CompositorWorker; |
| 43 } | 49 } |
| 44 | 50 |
| 45 WorkerGlobalScopeProxy* CompositorWorker::createWorkerGlobalScopeProxy(Execution Context* worker) | 51 WorkerGlobalScopeProxy* CompositorWorker::createWorkerGlobalScopeProxy(Execution Context* context) |
| 46 { | 52 { |
| 47 ASSERT(getExecutionContext()->isDocument()); | 53 ASSERT(context->isDocument()); |
|
jbroman
2016/04/29 19:42:22
The assertion here is redundant, since toDocument
flackr
2016/05/03 22:24:54
Heh, I like the pun. Thanks, removed.
| |
| 48 return new CompositorWorkerMessagingProxy(this); | 54 Document* document = toDocument(context); |
| 55 WorkerClients* workerClients = WorkerClients::create(); | |
| 56 provideCompositorProxyClientTo(workerClients, document->frame()->chromeClien t().createCompositorProxyClient(document->frame())); | |
| 57 return new CompositorWorkerMessagingProxy(this, workerClients); | |
| 49 } | 58 } |
| 50 | 59 |
| 51 } // namespace blink | 60 } // namespace blink |
| OLD | NEW |