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