| 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 "platform/TraceEvent.h" |
| 13 #include "wtf/MainThread.h" | 16 #include "wtf/MainThread.h" |
| 14 | 17 |
| 15 namespace blink { | 18 namespace blink { |
| 16 | 19 |
| 17 inline CompositorWorker::CompositorWorker(ExecutionContext* context) | 20 inline CompositorWorker::CompositorWorker(ExecutionContext* context) |
| 18 : InProcessWorkerBase(context) | 21 : InProcessWorkerBase(context) |
| 19 { | 22 { |
| 20 } | 23 } |
| 21 | 24 |
| 22 CompositorWorker* CompositorWorker::create(ExecutionContext* context, const Stri
ng& url, ExceptionState& exceptionState) | 25 CompositorWorker* CompositorWorker::create(ExecutionContext* context, const Stri
ng& url, ExceptionState& exceptionState) |
| 23 { | 26 { |
| 27 TRACE_EVENT0("compositor-worker", "CompositorWorker::create"); |
| 24 ASSERT(isMainThread()); | 28 ASSERT(isMainThread()); |
| 25 Document* document = toDocument(context); | 29 Document* document = toDocument(context); |
| 26 if (!document->page()) { | 30 if (!document->page()) { |
| 27 exceptionState.throwDOMException(InvalidAccessError, "The context provid
ed is invalid."); | 31 exceptionState.throwDOMException(InvalidAccessError, "The context provid
ed is invalid."); |
| 28 return nullptr; | 32 return nullptr; |
| 29 } | 33 } |
| 30 CompositorWorker* worker = new CompositorWorker(context); | 34 CompositorWorker* worker = new CompositorWorker(context); |
| 31 if (worker->initialize(context, url, exceptionState)) | 35 if (worker->initialize(context, url, exceptionState)) |
| 32 return worker; | 36 return worker; |
| 33 return nullptr; | 37 return nullptr; |
| 34 } | 38 } |
| 35 | 39 |
| 36 CompositorWorker::~CompositorWorker() | 40 CompositorWorker::~CompositorWorker() |
| 37 { | 41 { |
| 42 TRACE_EVENT0("compositor-worker", "CompositorWorker::~CompositorWorker"); |
| 38 ASSERT(isMainThread()); | 43 ASSERT(isMainThread()); |
| 39 } | 44 } |
| 40 | 45 |
| 41 const AtomicString& CompositorWorker::interfaceName() const | 46 const AtomicString& CompositorWorker::interfaceName() const |
| 42 { | 47 { |
| 43 return EventTargetNames::CompositorWorker; | 48 return EventTargetNames::CompositorWorker; |
| 44 } | 49 } |
| 45 | 50 |
| 46 WorkerGlobalScopeProxy* CompositorWorker::createWorkerGlobalScopeProxy(Execution
Context* worker) | 51 WorkerGlobalScopeProxy* CompositorWorker::createWorkerGlobalScopeProxy(Execution
Context* context) |
| 47 { | 52 { |
| 48 ASSERT(executionContext()->isDocument()); | 53 TRACE_EVENT0("compositor-worker", "CompositorWorker::createWorkerGlobalScope
Proxy"); |
| 49 return new CompositorWorkerMessagingProxy(this); | 54 ASSERT(context->isDocument()); |
| 55 Document* document = toDocument(context); |
| 56 OwnPtrWillBeRawPtr<WorkerClients> workerClients = WorkerClients::create(); |
| 57 provideCompositorProxyClientTo(workerClients.get(), adoptPtrWillBeNoop(docum
ent->frame()->chromeClient().createCompositorProxyClient())); |
| 58 return new CompositorWorkerMessagingProxy(this, workerClients.release()); |
| 50 } | 59 } |
| 51 | 60 |
| 52 } // namespace blink | 61 } // namespace blink |
| OLD | NEW |