| 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" |
| 11 #include "core/dom/CompositorProxyClient.h" | 11 #include "core/dom/CompositorWorkerProxyClient.h" |
| 12 #include "core/inspector/ConsoleMessage.h" | 12 #include "core/inspector/ConsoleMessage.h" |
| 13 #include "core/workers/InProcessWorkerObjectProxy.h" | 13 #include "core/workers/InProcessWorkerObjectProxy.h" |
| 14 #include "core/workers/ParentFrameTaskRunners.h" | 14 #include "core/workers/ParentFrameTaskRunners.h" |
| 15 #include "core/workers/WorkerBackingThread.h" | 15 #include "core/workers/WorkerBackingThread.h" |
| 16 #include "core/workers/WorkerLoaderProxy.h" | 16 #include "core/workers/WorkerLoaderProxy.h" |
| 17 #include "core/workers/WorkerOrWorkletGlobalScope.h" | 17 #include "core/workers/WorkerOrWorkletGlobalScope.h" |
| 18 #include "core/workers/WorkerThreadStartupData.h" | 18 #include "core/workers/WorkerThreadStartupData.h" |
| 19 #include "platform/CrossThreadFunctional.h" | 19 #include "platform/CrossThreadFunctional.h" |
| 20 #include "platform/WaitableEvent.h" | 20 #include "platform/WaitableEvent.h" |
| 21 #include "platform/WebThreadSupportingGC.h" | 21 #include "platform/WebThreadSupportingGC.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 void didCloseWorkerGlobalScope() override {} | 53 void didCloseWorkerGlobalScope() override {} |
| 54 void willDestroyWorkerGlobalScope() override {} | 54 void willDestroyWorkerGlobalScope() override {} |
| 55 void didTerminateWorkerThread() override {} | 55 void didTerminateWorkerThread() override {} |
| 56 | 56 |
| 57 private: | 57 private: |
| 58 TestCompositorWorkerObjectProxy() | 58 TestCompositorWorkerObjectProxy() |
| 59 : InProcessWorkerObjectProxy(nullptr, | 59 : InProcessWorkerObjectProxy(nullptr, |
| 60 ParentFrameTaskRunners::create(nullptr)) {} | 60 ParentFrameTaskRunners::create(nullptr)) {} |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 class TestCompositorProxyClient | 63 class TestCompositorWorkerProxyClient : public CompositorWorkerProxyClient { |
| 64 : public GarbageCollected<TestCompositorProxyClient>, | |
| 65 public CompositorProxyClient { | |
| 66 USING_GARBAGE_COLLECTED_MIXIN(TestCompositorProxyClient); | |
| 67 | |
| 68 public: | 64 public: |
| 69 TestCompositorProxyClient() {} | 65 TestCompositorWorkerProxyClient() {} |
| 70 | 66 |
| 71 void dispose() override {} | 67 void dispose() override {} |
| 72 void setGlobalScope(WorkerGlobalScope*) override {} | 68 void setGlobalScope(WorkerGlobalScope*) override {} |
| 73 void requestAnimationFrame() override {} | 69 void requestAnimationFrame() override {} |
| 74 void registerCompositorProxy(CompositorProxy*) override {} | 70 void registerCompositorProxy(CompositorProxy*) override {} |
| 75 void unregisterCompositorProxy(CompositorProxy*) override {} | 71 void unregisterCompositorProxy(CompositorProxy*) override {} |
| 76 }; | 72 }; |
| 77 | 73 |
| 78 class CompositorWorkerTestPlatform : public TestingPlatformSupport { | 74 class CompositorWorkerTestPlatform : public TestingPlatformSupport { |
| 79 public: | 75 public: |
| (...skipping 23 matching lines...) Expand all Loading... |
| 103 } | 99 } |
| 104 | 100 |
| 105 void TearDown() override { | 101 void TearDown() override { |
| 106 CompositorWorkerThread::clearSharedBackingThread(); | 102 CompositorWorkerThread::clearSharedBackingThread(); |
| 107 } | 103 } |
| 108 | 104 |
| 109 std::unique_ptr<CompositorWorkerThread> createCompositorWorker() { | 105 std::unique_ptr<CompositorWorkerThread> createCompositorWorker() { |
| 110 std::unique_ptr<CompositorWorkerThread> workerThread = | 106 std::unique_ptr<CompositorWorkerThread> workerThread = |
| 111 CompositorWorkerThread::create(nullptr, *m_objectProxy, 0); | 107 CompositorWorkerThread::create(nullptr, *m_objectProxy, 0); |
| 112 WorkerClients* clients = WorkerClients::create(); | 108 WorkerClients* clients = WorkerClients::create(); |
| 113 provideCompositorProxyClientTo(clients, new TestCompositorProxyClient); | 109 provideCompositorWorkerProxyClientTo(clients, |
| 110 new TestCompositorWorkerProxyClient); |
| 114 workerThread->start(WorkerThreadStartupData::create( | 111 workerThread->start(WorkerThreadStartupData::create( |
| 115 KURL(ParsedURLString, "http://fake.url/"), "fake user agent", | 112 KURL(ParsedURLString, "http://fake.url/"), "fake user agent", |
| 116 "//fake source code", nullptr, DontPauseWorkerGlobalScopeOnStart, | 113 "//fake source code", nullptr, DontPauseWorkerGlobalScopeOnStart, |
| 117 nullptr, "", m_securityOrigin.get(), clients, WebAddressSpaceLocal, | 114 nullptr, "", m_securityOrigin.get(), clients, WebAddressSpaceLocal, |
| 118 nullptr, nullptr, WorkerV8Settings::Default())); | 115 nullptr, nullptr, WorkerV8Settings::Default())); |
| 119 return workerThread; | 116 return workerThread; |
| 120 } | 117 } |
| 121 | 118 |
| 122 // Attempts to run some simple script for |worker|. | 119 // Attempts to run some simple script for |worker|. |
| 123 void checkWorkerCanExecuteScript(WorkerThread* worker) { | 120 void checkWorkerCanExecuteScript(WorkerThread* worker) { |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 ASSERT_TRUE(secondIsolate); | 239 ASSERT_TRUE(secondIsolate); |
| 243 EXPECT_EQ(firstIsolate, secondIsolate); | 240 EXPECT_EQ(firstIsolate, secondIsolate); |
| 244 | 241 |
| 245 // Verify that the isolate can run some scripts correctly in the second | 242 // Verify that the isolate can run some scripts correctly in the second |
| 246 // worker. | 243 // worker. |
| 247 checkWorkerCanExecuteScript(secondWorker.get()); | 244 checkWorkerCanExecuteScript(secondWorker.get()); |
| 248 secondWorker->terminateAndWait(); | 245 secondWorker->terminateAndWait(); |
| 249 } | 246 } |
| 250 | 247 |
| 251 } // namespace blink | 248 } // namespace blink |
| OLD | NEW |