| Index: third_party/WebKit/Source/modules/compositorworker/CompositorWorkerScriptTest.cpp
|
| diff --git a/third_party/WebKit/Source/modules/compositorworker/CompositorWorkerThreadTest.cpp b/third_party/WebKit/Source/modules/compositorworker/CompositorWorkerScriptTest.cpp
|
| similarity index 80%
|
| rename from third_party/WebKit/Source/modules/compositorworker/CompositorWorkerThreadTest.cpp
|
| rename to third_party/WebKit/Source/modules/compositorworker/CompositorWorkerScriptTest.cpp
|
| index 2154ae7f54d597edf8f2a6120b3a773ccd3dca00..4885d10f995c4337b2ca33e5203f09b1956a3ecf 100644
|
| --- a/third_party/WebKit/Source/modules/compositorworker/CompositorWorkerThreadTest.cpp
|
| +++ b/third_party/WebKit/Source/modules/compositorworker/CompositorWorkerScriptTest.cpp
|
| @@ -2,7 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "modules/compositorworker/CompositorWorkerThread.h"
|
| +#include "modules/compositorworker/CompositorWorkerScript.h"
|
|
|
| #include "bindings/core/v8/ScriptSourceCode.h"
|
| #include "bindings/core/v8/V8GCController.h"
|
| @@ -10,7 +10,7 @@
|
| #include "core/testing/DummyPageHolder.h"
|
| #include "core/workers/WorkerLoaderProxy.h"
|
| #include "core/workers/WorkerObjectProxy.h"
|
| -#include "core/workers/WorkerThreadStartupData.h"
|
| +#include "core/workers/WorkerScriptStartupData.h"
|
| #include "platform/NotImplemented.h"
|
| #include "platform/ThreadSafeFunctional.h"
|
| #include "platform/WaitableEvent.h"
|
| @@ -23,15 +23,15 @@
|
| namespace blink {
|
| namespace {
|
|
|
| -class TestCompositorWorkerThread : public CompositorWorkerThread {
|
| +class TestCompositorWorkerScript : public CompositorWorkerScript {
|
| public:
|
| - TestCompositorWorkerThread(WorkerLoaderProxyProvider* loaderProxyProvider, WorkerObjectProxy& objectProxy, double timeOrigin, WaitableEvent* startEvent)
|
| - : CompositorWorkerThread(WorkerLoaderProxy::create(loaderProxyProvider), objectProxy, timeOrigin)
|
| + TestCompositorWorkerScript(WorkerLoaderProxyProvider* loaderProxyProvider, WorkerObjectProxy& objectProxy, double timeOrigin, WaitableEvent* startEvent)
|
| + : CompositorWorkerScript(WorkerLoaderProxy::create(loaderProxyProvider), objectProxy, timeOrigin)
|
| , m_startEvent(startEvent)
|
| {
|
| }
|
|
|
| - ~TestCompositorWorkerThread() override {}
|
| + ~TestCompositorWorkerScript() override {}
|
|
|
| void setCallbackAfterV8Termination(PassOwnPtr<Function<void()>> callback)
|
| {
|
| @@ -39,14 +39,14 @@ public:
|
| }
|
|
|
| private:
|
| - // WorkerThread:
|
| - void didStartWorkerThread() override
|
| + // WorkerScript:
|
| + void didStartWorkerScript() override
|
| {
|
| m_startEvent->signal();
|
| }
|
| void terminateV8Execution() override
|
| {
|
| - CompositorWorkerThread::terminateV8Execution();
|
| + CompositorWorkerScript::terminateV8Execution();
|
| if (m_v8TerminationCallback)
|
| (*m_v8TerminationCallback)();
|
| }
|
| @@ -55,14 +55,14 @@ private:
|
| {
|
| v8::Isolate::GetCurrent()->RequestGarbageCollectionForTesting(v8::Isolate::kFullGarbageCollection);
|
| Heap::collectAllGarbage();
|
| - CompositorWorkerThread::willDestroyIsolate();
|
| + CompositorWorkerScript::willDestroyIsolate();
|
| }
|
|
|
| WaitableEvent* m_startEvent;
|
| OwnPtr<Function<void()>> m_v8TerminationCallback;
|
| };
|
|
|
| -// A null WorkerObjectProxy, supplied when creating CompositorWorkerThreads.
|
| +// A null WorkerObjectProxy, supplied when creating CompositorWorkerScripts.
|
| class TestCompositorWorkerObjectProxy : public WorkerObjectProxy {
|
| public:
|
| static PassOwnPtr<TestCompositorWorkerObjectProxy> create(ExecutionContext* context)
|
| @@ -79,7 +79,7 @@ public:
|
| void didEvaluateWorkerScript(bool success) override {}
|
| void workerGlobalScopeStarted(WorkerGlobalScope*) override {}
|
| void workerGlobalScopeClosed() override {}
|
| - void workerThreadTerminated() override {}
|
| + void workerScriptTerminated() override {}
|
| void willDestroyWorkerGlobalScope() override {}
|
|
|
| ExecutionContext* executionContext() override { return m_executionContext.get(); }
|
| @@ -115,7 +115,7 @@ private:
|
|
|
| } // namespace
|
|
|
| -class CompositorWorkerThreadTest : public ::testing::Test {
|
| +class CompositorWorkerScriptTest : public ::testing::Test {
|
| public:
|
| void SetUp() override
|
| {
|
| @@ -131,11 +131,11 @@ public:
|
| m_page.clear();
|
| }
|
|
|
| - PassRefPtr<TestCompositorWorkerThread> createCompositorWorker(WaitableEvent* startEvent)
|
| + PassRefPtr<TestCompositorWorkerScript> createCompositorWorker(WaitableEvent* startEvent)
|
| {
|
| - TestCompositorWorkerThread* workerThread = new TestCompositorWorkerThread(nullptr, *m_objectProxy, 0, startEvent);
|
| + TestCompositorWorkerScript* workerScript = new TestCompositorWorkerScript(nullptr, *m_objectProxy, 0, startEvent);
|
| OwnPtrWillBeRawPtr<WorkerClients> clients = nullptr;
|
| - workerThread->start(WorkerThreadStartupData::create(
|
| + workerScript->start(WorkerScriptStartupData::create(
|
| KURL(ParsedURLString, "http://fake.url/"),
|
| "fake user agent",
|
| "//fake source code",
|
| @@ -145,19 +145,19 @@ public:
|
| m_securityOrigin.get(),
|
| clients.release(),
|
| V8CacheOptionsDefault));
|
| - return adoptRef(workerThread);
|
| + return adoptRef(workerScript);
|
| }
|
|
|
| - void createWorkerAdapter(RefPtr<CompositorWorkerThread>* workerThread, WaitableEvent* creationEvent)
|
| + void createWorkerAdapter(RefPtr<CompositorWorkerScript>* workerScript, WaitableEvent* creationEvent)
|
| {
|
| - *workerThread = createCompositorWorker(creationEvent);
|
| + *workerScript = createCompositorWorker(creationEvent);
|
| }
|
|
|
| // Attempts to run some simple script for |worker|.
|
| - void checkWorkerCanExecuteScript(WorkerThread* worker)
|
| + void checkWorkerCanExecuteScript(WorkerScript* worker)
|
| {
|
| OwnPtr<WaitableEvent> waitEvent = adoptPtr(new WaitableEvent());
|
| - worker->backingThread().platformThread().taskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(&CompositorWorkerThreadTest::executeScriptInWorker, AllowCrossThreadAccess(this),
|
| + worker->backingThread().platformThread().taskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(&CompositorWorkerScriptTest::executeScriptInWorker, AllowCrossThreadAccess(this),
|
| AllowCrossThreadAccess(worker), AllowCrossThreadAccess(waitEvent.get())));
|
| waitEvent->wait();
|
| }
|
| @@ -170,16 +170,16 @@ public:
|
|
|
| bool hasThread() const
|
| {
|
| - return CompositorWorkerThread::hasThreadForTest();
|
| + return CompositorWorkerScript::hasThreadForTest();
|
| }
|
|
|
| bool hasIsolate() const
|
| {
|
| - return CompositorWorkerThread::hasIsolateForTest();
|
| + return CompositorWorkerScript::hasIsolateForTest();
|
| }
|
|
|
| private:
|
| - void executeScriptInWorker(WorkerThread* worker, WaitableEvent* waitEvent)
|
| + void executeScriptInWorker(WorkerScript* worker, WaitableEvent* waitEvent)
|
| {
|
| WorkerOrWorkletScriptController* scriptController = worker->workerGlobalScope()->scriptController();
|
| bool evaluateResult = scriptController->evaluate(ScriptSourceCode("var counter = 0; ++counter;"));
|
| @@ -193,22 +193,22 @@ private:
|
| CompositorWorkerTestPlatform m_testPlatform;
|
| };
|
|
|
| -TEST_F(CompositorWorkerThreadTest, Basic)
|
| +TEST_F(CompositorWorkerScriptTest, Basic)
|
| {
|
| OwnPtr<WaitableEvent> creationEvent = adoptPtr(new WaitableEvent());
|
| - RefPtr<CompositorWorkerThread> compositorWorker = createCompositorWorker(creationEvent.get());
|
| + RefPtr<CompositorWorkerScript> compositorWorker = createCompositorWorker(creationEvent.get());
|
| waitForWaitableEventAfterIteratingCurrentLoop(creationEvent.get());
|
| checkWorkerCanExecuteScript(compositorWorker.get());
|
| compositorWorker->terminateAndWait();
|
| }
|
|
|
| // Tests that the same WebThread is used for new workers if the WebThread is still alive.
|
| -TEST_F(CompositorWorkerThreadTest, CreateSecondAndTerminateFirst)
|
| +TEST_F(CompositorWorkerScriptTest, CreateSecondAndTerminateFirst)
|
| {
|
| // Create the first worker and wait until it is initialized.
|
| OwnPtr<WaitableEvent> firstCreationEvent = adoptPtr(new WaitableEvent());
|
| - RefPtr<CompositorWorkerThread> firstWorker = createCompositorWorker(firstCreationEvent.get());
|
| - WebThreadSupportingGC* firstThread = CompositorWorkerThread::sharedBackingThread();
|
| + RefPtr<CompositorWorkerScript> firstWorker = createCompositorWorker(firstCreationEvent.get());
|
| + WebThreadSupportingGC* firstThread = CompositorWorkerScript::sharedBackingThread();
|
| ASSERT(firstThread);
|
| waitForWaitableEventAfterIteratingCurrentLoop(firstCreationEvent.get());
|
| v8::Isolate* firstIsolate = firstWorker->isolate();
|
| @@ -216,12 +216,12 @@ TEST_F(CompositorWorkerThreadTest, CreateSecondAndTerminateFirst)
|
|
|
| // Create the second worker and immediately destroy the first worker.
|
| OwnPtr<WaitableEvent> secondCreationEvent = adoptPtr(new WaitableEvent());
|
| - RefPtr<CompositorWorkerThread> secondWorker = createCompositorWorker(secondCreationEvent.get());
|
| + RefPtr<CompositorWorkerScript> secondWorker = createCompositorWorker(secondCreationEvent.get());
|
| firstWorker->terminateAndWait();
|
|
|
| // Wait until the second worker is initialized. Verify that the second worker is using the same
|
| // thread and Isolate as the first worker.
|
| - WebThreadSupportingGC* secondThread = CompositorWorkerThread::sharedBackingThread();
|
| + WebThreadSupportingGC* secondThread = CompositorWorkerScript::sharedBackingThread();
|
| ASSERT(secondThread);
|
| waitForWaitableEventAfterIteratingCurrentLoop(secondCreationEvent.get());
|
| EXPECT_EQ(firstThread, secondThread);
|
| @@ -243,12 +243,12 @@ static void checkCurrentIsolate(v8::Isolate* isolate, WaitableEvent* event)
|
| }
|
|
|
| // Tests that a new WebThread is created if all existing workers are terminated before a new worker is created.
|
| -TEST_F(CompositorWorkerThreadTest, TerminateFirstAndCreateSecond)
|
| +TEST_F(CompositorWorkerScriptTest, TerminateFirstAndCreateSecond)
|
| {
|
| // Create the first worker, wait until it is initialized, and terminate it.
|
| OwnPtr<WaitableEvent> creationEvent = adoptPtr(new WaitableEvent());
|
| - RefPtr<CompositorWorkerThread> compositorWorker = createCompositorWorker(creationEvent.get());
|
| - WebThreadSupportingGC* firstThread = CompositorWorkerThread::sharedBackingThread();
|
| + RefPtr<CompositorWorkerScript> compositorWorker = createCompositorWorker(creationEvent.get());
|
| + WebThreadSupportingGC* firstThread = CompositorWorkerScript::sharedBackingThread();
|
| waitForWaitableEventAfterIteratingCurrentLoop(creationEvent.get());
|
| ASSERT(compositorWorker->isolate());
|
| compositorWorker->terminateAndWait();
|
| @@ -257,7 +257,7 @@ TEST_F(CompositorWorkerThreadTest, TerminateFirstAndCreateSecond)
|
| // thread will have been destroyed after destroying the first worker.
|
| creationEvent = adoptPtr(new WaitableEvent());
|
| compositorWorker = createCompositorWorker(creationEvent.get());
|
| - WebThreadSupportingGC* secondThread = CompositorWorkerThread::sharedBackingThread();
|
| + WebThreadSupportingGC* secondThread = CompositorWorkerScript::sharedBackingThread();
|
| EXPECT_NE(firstThread, secondThread);
|
| waitForWaitableEventAfterIteratingCurrentLoop(creationEvent.get());
|
|
|
| @@ -271,10 +271,10 @@ TEST_F(CompositorWorkerThreadTest, TerminateFirstAndCreateSecond)
|
| }
|
|
|
| // Tests that v8::Isolate and WebThread are correctly set-up if a worker is created while another is terminating.
|
| -TEST_F(CompositorWorkerThreadTest, CreatingSecondDuringTerminationOfFirst)
|
| +TEST_F(CompositorWorkerScriptTest, CreatingSecondDuringTerminationOfFirst)
|
| {
|
| OwnPtr<WaitableEvent> firstCreationEvent = adoptPtr(new WaitableEvent());
|
| - RefPtr<TestCompositorWorkerThread> firstWorker = createCompositorWorker(firstCreationEvent.get());
|
| + RefPtr<TestCompositorWorkerScript> firstWorker = createCompositorWorker(firstCreationEvent.get());
|
| waitForWaitableEventAfterIteratingCurrentLoop(firstCreationEvent.get());
|
| v8::Isolate* firstIsolate = firstWorker->isolate();
|
| ASSERT(firstIsolate);
|
| @@ -282,8 +282,8 @@ TEST_F(CompositorWorkerThreadTest, CreatingSecondDuringTerminationOfFirst)
|
| // Request termination of the first worker, and set-up to make sure the second worker is created right as
|
| // the first worker terminates its isolate.
|
| OwnPtr<WaitableEvent> secondCreationEvent = adoptPtr(new WaitableEvent());
|
| - RefPtr<CompositorWorkerThread> secondWorker;
|
| - firstWorker->setCallbackAfterV8Termination(bind(&CompositorWorkerThreadTest::createWorkerAdapter, this, &secondWorker, secondCreationEvent.get()));
|
| + RefPtr<CompositorWorkerScript> secondWorker;
|
| + firstWorker->setCallbackAfterV8Termination(bind(&CompositorWorkerScriptTest::createWorkerAdapter, this, &secondWorker, secondCreationEvent.get()));
|
| firstWorker->terminateAndWait();
|
| ASSERT(secondWorker);
|
|
|
|
|