| 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/CompositorWorkerThread.h" | 5 #include "modules/compositorworker/CompositorWorkerThread.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptSourceCode.h" | 7 #include "bindings/core/v8/ScriptSourceCode.h" |
| 8 #include "bindings/core/v8/SourceLocation.h" | 8 #include "bindings/core/v8/SourceLocation.h" |
| 9 #include "bindings/core/v8/V8GCController.h" | 9 #include "bindings/core/v8/V8GCController.h" |
| 10 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" | 10 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #include <memory> | 29 #include <memory> |
| 30 | 30 |
| 31 namespace blink { | 31 namespace blink { |
| 32 namespace { | 32 namespace { |
| 33 | 33 |
| 34 // A null InProcessWorkerObjectProxy, supplied when creating | 34 // A null InProcessWorkerObjectProxy, supplied when creating |
| 35 // CompositorWorkerThreads. | 35 // CompositorWorkerThreads. |
| 36 class TestCompositorWorkerObjectProxy : public InProcessWorkerObjectProxy { | 36 class TestCompositorWorkerObjectProxy : public InProcessWorkerObjectProxy { |
| 37 public: | 37 public: |
| 38 static std::unique_ptr<TestCompositorWorkerObjectProxy> create() { | 38 static std::unique_ptr<TestCompositorWorkerObjectProxy> create() { |
| 39 return wrapUnique(new TestCompositorWorkerObjectProxy()); | 39 return WTF::wrapUnique(new TestCompositorWorkerObjectProxy()); |
| 40 } | 40 } |
| 41 | 41 |
| 42 // (Empty) WorkerReportingProxy implementation: | 42 // (Empty) WorkerReportingProxy implementation: |
| 43 virtual void dispatchErrorEvent(const String& errorMessage, | 43 virtual void dispatchErrorEvent(const String& errorMessage, |
| 44 std::unique_ptr<SourceLocation>, | 44 std::unique_ptr<SourceLocation>, |
| 45 int exceptionId) {} | 45 int exceptionId) {} |
| 46 void reportConsoleMessage(MessageSource, | 46 void reportConsoleMessage(MessageSource, |
| 47 MessageLevel, | 47 MessageLevel, |
| 48 const String& message, | 48 const String& message, |
| 49 SourceLocation*) override {} | 49 SourceLocation*) override {} |
| (...skipping 21 matching lines...) Expand all Loading... |
| 71 void dispose() override {} | 71 void dispose() override {} |
| 72 void setGlobalScope(WorkerGlobalScope*) override {} | 72 void setGlobalScope(WorkerGlobalScope*) override {} |
| 73 void requestAnimationFrame() override {} | 73 void requestAnimationFrame() override {} |
| 74 void registerCompositorProxy(CompositorProxy*) override {} | 74 void registerCompositorProxy(CompositorProxy*) override {} |
| 75 void unregisterCompositorProxy(CompositorProxy*) override {} | 75 void unregisterCompositorProxy(CompositorProxy*) override {} |
| 76 }; | 76 }; |
| 77 | 77 |
| 78 class CompositorWorkerTestPlatform : public TestingPlatformSupport { | 78 class CompositorWorkerTestPlatform : public TestingPlatformSupport { |
| 79 public: | 79 public: |
| 80 CompositorWorkerTestPlatform() | 80 CompositorWorkerTestPlatform() |
| 81 : m_thread(wrapUnique(m_oldPlatform->createThread("Compositor"))) {} | 81 : m_thread(WTF::wrapUnique(m_oldPlatform->createThread("Compositor"))) {} |
| 82 | 82 |
| 83 WebThread* compositorThread() const override { return m_thread.get(); } | 83 WebThread* compositorThread() const override { return m_thread.get(); } |
| 84 | 84 |
| 85 WebCompositorSupport* compositorSupport() override { | 85 WebCompositorSupport* compositorSupport() override { |
| 86 return &m_compositorSupport; | 86 return &m_compositorSupport; |
| 87 } | 87 } |
| 88 | 88 |
| 89 private: | 89 private: |
| 90 std::unique_ptr<WebThread> m_thread; | 90 std::unique_ptr<WebThread> m_thread; |
| 91 TestingCompositorSupport m_compositorSupport; | 91 TestingCompositorSupport m_compositorSupport; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 114 workerThread->start(WorkerThreadStartupData::create( | 114 workerThread->start(WorkerThreadStartupData::create( |
| 115 KURL(ParsedURLString, "http://fake.url/"), "fake user agent", | 115 KURL(ParsedURLString, "http://fake.url/"), "fake user agent", |
| 116 "//fake source code", nullptr, DontPauseWorkerGlobalScopeOnStart, | 116 "//fake source code", nullptr, DontPauseWorkerGlobalScopeOnStart, |
| 117 nullptr, "", m_securityOrigin.get(), clients, WebAddressSpaceLocal, | 117 nullptr, "", m_securityOrigin.get(), clients, WebAddressSpaceLocal, |
| 118 nullptr, nullptr, V8CacheOptionsDefault)); | 118 nullptr, nullptr, V8CacheOptionsDefault)); |
| 119 return workerThread; | 119 return workerThread; |
| 120 } | 120 } |
| 121 | 121 |
| 122 // Attempts to run some simple script for |worker|. | 122 // Attempts to run some simple script for |worker|. |
| 123 void checkWorkerCanExecuteScript(WorkerThread* worker) { | 123 void checkWorkerCanExecuteScript(WorkerThread* worker) { |
| 124 std::unique_ptr<WaitableEvent> waitEvent = makeUnique<WaitableEvent>(); | 124 std::unique_ptr<WaitableEvent> waitEvent = WTF::makeUnique<WaitableEvent>(); |
| 125 worker->workerBackingThread().backingThread().postTask( | 125 worker->workerBackingThread().backingThread().postTask( |
| 126 BLINK_FROM_HERE, | 126 BLINK_FROM_HERE, |
| 127 crossThreadBind(&CompositorWorkerThreadTest::executeScriptInWorker, | 127 crossThreadBind(&CompositorWorkerThreadTest::executeScriptInWorker, |
| 128 crossThreadUnretained(this), | 128 crossThreadUnretained(this), |
| 129 crossThreadUnretained(worker), | 129 crossThreadUnretained(worker), |
| 130 crossThreadUnretained(waitEvent.get()))); | 130 crossThreadUnretained(waitEvent.get()))); |
| 131 waitEvent->wait(); | 131 waitEvent->wait(); |
| 132 } | 132 } |
| 133 | 133 |
| 134 private: | 134 private: |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 ASSERT_TRUE(secondIsolate); | 235 ASSERT_TRUE(secondIsolate); |
| 236 EXPECT_EQ(firstIsolate, secondIsolate); | 236 EXPECT_EQ(firstIsolate, secondIsolate); |
| 237 | 237 |
| 238 // Verify that the isolate can run some scripts correctly in the second | 238 // Verify that the isolate can run some scripts correctly in the second |
| 239 // worker. | 239 // worker. |
| 240 checkWorkerCanExecuteScript(secondWorker.get()); | 240 checkWorkerCanExecuteScript(secondWorker.get()); |
| 241 secondWorker->terminateAndWait(); | 241 secondWorker->terminateAndWait(); |
| 242 } | 242 } |
| 243 | 243 |
| 244 } // namespace blink | 244 } // namespace blink |
| OLD | NEW |