| 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/Document.h" | 8 #include "core/dom/Document.h" |
| 9 #include "core/dom/ExceptionCode.h" | 9 #include "core/dom/ExceptionCode.h" |
| 10 #include "core/workers/WorkerClients.h" | 10 #include "core/workers/WorkerClients.h" |
| 11 #include "modules/EventTargetModules.h" | 11 #include "modules/EventTargetModules.h" |
| 12 #include "modules/compositorworker/CompositorWorkerMessagingProxy.h" | 12 #include "modules/compositorworker/CompositorWorkerMessagingProxy.h" |
| 13 #include "modules/compositorworker/CompositorWorkerThread.h" |
| 13 | 14 |
| 14 namespace blink { | 15 namespace blink { |
| 15 | 16 |
| 16 inline CompositorWorker::CompositorWorker(ExecutionContext* context) | 17 inline CompositorWorker::CompositorWorker(ExecutionContext* context) |
| 17 : InProcessWorkerBase(context) | 18 : InProcessWorkerBase(context) |
| 18 { | 19 { |
| 19 } | 20 } |
| 20 | 21 |
| 21 CompositorWorker* CompositorWorker::create(ExecutionContext* context, const Stri
ng& url, ExceptionState& exceptionState) | 22 CompositorWorker* CompositorWorker::create(ExecutionContext* context, const Stri
ng& url, ExceptionState& exceptionState) |
| 22 { | 23 { |
| 23 ASSERT(isMainThread()); | 24 ASSERT(isMainThread()); |
| 24 Document* document = toDocument(context); | 25 Document* document = toDocument(context); |
| 25 if (!document->page()) { | 26 if (!document->page()) { |
| 26 exceptionState.throwDOMException(InvalidAccessError, "The context provid
ed is invalid."); | 27 exceptionState.throwDOMException(InvalidAccessError, "The context provid
ed is invalid."); |
| 27 return nullptr; | 28 return nullptr; |
| 28 } | 29 } |
| 29 CompositorWorker* worker = new CompositorWorker(context); | 30 CompositorWorker* worker = new CompositorWorker(context); |
| 31 |
| 32 // Ensure the compositor worker backing thread is ready before we try to |
| 33 // initialize the CompositorWorker so that we can construct oilpan |
| 34 // objects on the compositor thread referenced from the worker clients. |
| 35 CompositorWorkerThread::ensureSharedBackingThread(); |
| 36 |
| 30 if (worker->initialize(context, url, exceptionState)) | 37 if (worker->initialize(context, url, exceptionState)) |
| 31 return worker; | 38 return worker; |
| 32 return nullptr; | 39 return nullptr; |
| 33 } | 40 } |
| 34 | 41 |
| 35 CompositorWorker::~CompositorWorker() | 42 CompositorWorker::~CompositorWorker() |
| 36 { | 43 { |
| 37 ASSERT(isMainThread()); | 44 ASSERT(isMainThread()); |
| 38 } | 45 } |
| 39 | 46 |
| 40 const AtomicString& CompositorWorker::interfaceName() const | 47 const AtomicString& CompositorWorker::interfaceName() const |
| 41 { | 48 { |
| 42 return EventTargetNames::CompositorWorker; | 49 return EventTargetNames::CompositorWorker; |
| 43 } | 50 } |
| 44 | 51 |
| 45 InProcessWorkerGlobalScopeProxy* CompositorWorker::createInProcessWorkerGlobalSc
opeProxy(ExecutionContext* worker) | 52 InProcessWorkerGlobalScopeProxy* CompositorWorker::createInProcessWorkerGlobalSc
opeProxy(ExecutionContext* worker) |
| 46 { | 53 { |
| 47 ASSERT(getExecutionContext()->isDocument()); | 54 ASSERT(getExecutionContext()->isDocument()); |
| 48 return new CompositorWorkerMessagingProxy(this); | 55 return new CompositorWorkerMessagingProxy(this); |
| 49 } | 56 } |
| 50 | 57 |
| 51 } // namespace blink | 58 } // namespace blink |
| OLD | NEW |