| 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/V8GCController.h" | 8 #include "bindings/core/v8/V8GCController.h" |
| 9 #include "core/inspector/ConsoleMessage.h" | 9 #include "core/inspector/ConsoleMessage.h" |
| 10 #include "core/testing/DummyPageHolder.h" | 10 #include "core/testing/DummyPageHolder.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 // A null WorkerObjectProxy, supplied when creating CompositorWorkerThreads. | 68 // A null WorkerObjectProxy, supplied when creating CompositorWorkerThreads. |
| 69 class TestCompositorWorkerObjectProxy : public WorkerObjectProxy { | 69 class TestCompositorWorkerObjectProxy : public WorkerObjectProxy { |
| 70 public: | 70 public: |
| 71 static PassOwnPtr<TestCompositorWorkerObjectProxy> create(ExecutionContext*
context) | 71 static PassOwnPtr<TestCompositorWorkerObjectProxy> create(ExecutionContext*
context) |
| 72 { | 72 { |
| 73 return adoptPtr(new TestCompositorWorkerObjectProxy(context)); | 73 return adoptPtr(new TestCompositorWorkerObjectProxy(context)); |
| 74 } | 74 } |
| 75 | 75 |
| 76 // (Empty) WorkerReportingProxy implementation: | 76 // (Empty) WorkerReportingProxy implementation: |
| 77 virtual void reportException(const String& errorMessage, int lineNumber, int
columnNumber, const String& sourceURL, int exceptionId) {} | 77 virtual void reportException(const String& errorMessage, int lineNumber, int
columnNumber, const String& sourceURL, int exceptionId) {} |
| 78 void reportConsoleMessage(PassRefPtrWillBeRawPtr<ConsoleMessage>) override {
} | 78 void reportConsoleMessage(RawPtr<ConsoleMessage>) override {} |
| 79 void postMessageToPageInspector(const String&) override {} | 79 void postMessageToPageInspector(const String&) override {} |
| 80 void postWorkerConsoleAgentEnabled() override {} | 80 void postWorkerConsoleAgentEnabled() override {} |
| 81 | 81 |
| 82 void didEvaluateWorkerScript(bool success) override {} | 82 void didEvaluateWorkerScript(bool success) override {} |
| 83 void workerGlobalScopeStarted(WorkerGlobalScope*) override {} | 83 void workerGlobalScopeStarted(WorkerGlobalScope*) override {} |
| 84 void workerGlobalScopeClosed() override {} | 84 void workerGlobalScopeClosed() override {} |
| 85 void workerThreadTerminated() override {} | 85 void workerThreadTerminated() override {} |
| 86 void willDestroyWorkerGlobalScope() override {} | 86 void willDestroyWorkerGlobalScope() override {} |
| 87 | 87 |
| 88 ExecutionContext* getExecutionContext() override { return m_executionContext
.get(); } | 88 ExecutionContext* getExecutionContext() override { return m_executionContext
.get(); } |
| 89 | 89 |
| 90 private: | 90 private: |
| 91 TestCompositorWorkerObjectProxy(ExecutionContext* context) | 91 TestCompositorWorkerObjectProxy(ExecutionContext* context) |
| 92 : WorkerObjectProxy(nullptr) | 92 : WorkerObjectProxy(nullptr) |
| 93 , m_executionContext(context) | 93 , m_executionContext(context) |
| 94 { | 94 { |
| 95 } | 95 } |
| 96 | 96 |
| 97 RefPtrWillBePersistent<ExecutionContext> m_executionContext; | 97 Persistent<ExecutionContext> m_executionContext; |
| 98 }; | 98 }; |
| 99 | 99 |
| 100 class CompositorWorkerTestPlatform : public TestingPlatformSupport { | 100 class CompositorWorkerTestPlatform : public TestingPlatformSupport { |
| 101 public: | 101 public: |
| 102 CompositorWorkerTestPlatform() | 102 CompositorWorkerTestPlatform() |
| 103 : m_thread(adoptPtr(m_oldPlatform->createThread("Compositor"))) | 103 : m_thread(adoptPtr(m_oldPlatform->createThread("Compositor"))) |
| 104 { | 104 { |
| 105 } | 105 } |
| 106 | 106 |
| 107 WebThread* compositorThread() const override | 107 WebThread* compositorThread() const override |
| (...skipping 22 matching lines...) Expand all Loading... |
| 130 void TearDown() override | 130 void TearDown() override |
| 131 { | 131 { |
| 132 ASSERT(!hasThread()); | 132 ASSERT(!hasThread()); |
| 133 ASSERT(!hasIsolate()); | 133 ASSERT(!hasIsolate()); |
| 134 m_page.clear(); | 134 m_page.clear(); |
| 135 } | 135 } |
| 136 | 136 |
| 137 PassOwnPtr<TestCompositorWorkerThread> createCompositorWorker(WaitableEvent*
startEvent) | 137 PassOwnPtr<TestCompositorWorkerThread> createCompositorWorker(WaitableEvent*
startEvent) |
| 138 { | 138 { |
| 139 TestCompositorWorkerThread* workerThread = new TestCompositorWorkerThrea
d(nullptr, *m_objectProxy, 0, startEvent); | 139 TestCompositorWorkerThread* workerThread = new TestCompositorWorkerThrea
d(nullptr, *m_objectProxy, 0, startEvent); |
| 140 OwnPtrWillBeRawPtr<WorkerClients> clients = nullptr; | 140 RawPtr<WorkerClients> clients = nullptr; |
| 141 workerThread->start(WorkerThreadStartupData::create( | 141 workerThread->start(WorkerThreadStartupData::create( |
| 142 KURL(ParsedURLString, "http://fake.url/"), | 142 KURL(ParsedURLString, "http://fake.url/"), |
| 143 "fake user agent", | 143 "fake user agent", |
| 144 "//fake source code", | 144 "//fake source code", |
| 145 nullptr, | 145 nullptr, |
| 146 DontPauseWorkerGlobalScopeOnStart, | 146 DontPauseWorkerGlobalScopeOnStart, |
| 147 adoptPtr(new Vector<CSPHeaderAndType>()), | 147 adoptPtr(new Vector<CSPHeaderAndType>()), |
| 148 m_securityOrigin.get(), | 148 m_securityOrigin.get(), |
| 149 clients.release(), | 149 clients.release(), |
| 150 WebAddressSpaceLocal, | 150 WebAddressSpaceLocal, |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 v8::Isolate* secondIsolate = secondWorker->isolate(); | 295 v8::Isolate* secondIsolate = secondWorker->isolate(); |
| 296 ASSERT(secondIsolate); | 296 ASSERT(secondIsolate); |
| 297 EXPECT_EQ(firstIsolate, secondIsolate); | 297 EXPECT_EQ(firstIsolate, secondIsolate); |
| 298 | 298 |
| 299 // Verify that the isolate can run some scripts correctly in the second work
er. | 299 // Verify that the isolate can run some scripts correctly in the second work
er. |
| 300 checkWorkerCanExecuteScript(secondWorker.get()); | 300 checkWorkerCanExecuteScript(secondWorker.get()); |
| 301 secondWorker->terminateAndWait(); | 301 secondWorker->terminateAndWait(); |
| 302 } | 302 } |
| 303 | 303 |
| 304 } // namespace blink | 304 } // namespace blink |
| OLD | NEW |