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