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/dom/CompositorProxyClient.h" |
9 #include "core/inspector/ConsoleMessage.h" | 10 #include "core/inspector/ConsoleMessage.h" |
10 #include "core/testing/DummyPageHolder.h" | 11 #include "core/testing/DummyPageHolder.h" |
11 #include "core/workers/InProcessWorkerObjectProxy.h" | 12 #include "core/workers/InProcessWorkerObjectProxy.h" |
12 #include "core/workers/WorkerBackingThread.h" | 13 #include "core/workers/WorkerBackingThread.h" |
13 #include "core/workers/WorkerLoaderProxy.h" | 14 #include "core/workers/WorkerLoaderProxy.h" |
14 #include "core/workers/WorkerThreadStartupData.h" | 15 #include "core/workers/WorkerThreadStartupData.h" |
15 #include "platform/ThreadSafeFunctional.h" | 16 #include "platform/ThreadSafeFunctional.h" |
16 #include "platform/WaitableEvent.h" | 17 #include "platform/WaitableEvent.h" |
17 #include "platform/WebThreadSupportingGC.h" | 18 #include "platform/WebThreadSupportingGC.h" |
18 #include "platform/heap/Handle.h" | 19 #include "platform/heap/Handle.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 private: | 51 private: |
51 TestCompositorWorkerObjectProxy(ExecutionContext* context) | 52 TestCompositorWorkerObjectProxy(ExecutionContext* context) |
52 : InProcessWorkerObjectProxy(nullptr) | 53 : InProcessWorkerObjectProxy(nullptr) |
53 , m_executionContext(context) | 54 , m_executionContext(context) |
54 { | 55 { |
55 } | 56 } |
56 | 57 |
57 Persistent<ExecutionContext> m_executionContext; | 58 Persistent<ExecutionContext> m_executionContext; |
58 }; | 59 }; |
59 | 60 |
| 61 class TestCompositorProxyClient |
| 62 : public GarbageCollected<TestCompositorProxyClient> |
| 63 , public CompositorProxyClient { |
| 64 USING_GARBAGE_COLLECTED_MIXIN(TestCompositorProxyClient); |
| 65 public: |
| 66 TestCompositorProxyClient() {} |
| 67 |
| 68 void setGlobalScope(WorkerGlobalScope*) override {} |
| 69 void requestAnimationFrame() override {} |
| 70 }; |
| 71 |
60 class CompositorWorkerTestPlatform : public TestingPlatformSupport { | 72 class CompositorWorkerTestPlatform : public TestingPlatformSupport { |
61 public: | 73 public: |
62 CompositorWorkerTestPlatform() | 74 CompositorWorkerTestPlatform() |
63 : m_thread(adoptPtr(m_oldPlatform->createThread("Compositor"))) | 75 : m_thread(adoptPtr(m_oldPlatform->createThread("Compositor"))) |
64 { | 76 { |
65 } | 77 } |
66 | 78 |
67 WebThread* compositorThread() const override | 79 WebThread* compositorThread() const override |
68 { | 80 { |
69 return m_thread.get(); | 81 return m_thread.get(); |
(...skipping 14 matching lines...) Expand all Loading... |
84 { | 96 { |
85 CompositorWorkerThread::resetSharedBackingThreadForTest(); | 97 CompositorWorkerThread::resetSharedBackingThreadForTest(); |
86 m_page = DummyPageHolder::create(); | 98 m_page = DummyPageHolder::create(); |
87 m_objectProxy = TestCompositorWorkerObjectProxy::create(&m_page->documen
t()); | 99 m_objectProxy = TestCompositorWorkerObjectProxy::create(&m_page->documen
t()); |
88 m_securityOrigin = SecurityOrigin::create(KURL(ParsedURLString, "http://
fake.url/")); | 100 m_securityOrigin = SecurityOrigin::create(KURL(ParsedURLString, "http://
fake.url/")); |
89 } | 101 } |
90 | 102 |
91 void TearDown() override | 103 void TearDown() override |
92 { | 104 { |
93 m_page.clear(); | 105 m_page.clear(); |
94 CompositorWorkerThread::resetSharedBackingThreadForTest(); | 106 CompositorWorkerThread::clearSharedBackingThread(); |
95 } | 107 } |
96 | 108 |
97 PassOwnPtr<CompositorWorkerThread> createCompositorWorker() | 109 PassOwnPtr<CompositorWorkerThread> createCompositorWorker() |
98 { | 110 { |
99 OwnPtr<CompositorWorkerThread> workerThread = CompositorWorkerThread::cr
eate(nullptr, *m_objectProxy, 0); | 111 OwnPtr<CompositorWorkerThread> workerThread = CompositorWorkerThread::cr
eate(nullptr, *m_objectProxy, 0); |
100 WorkerClients* clients = nullptr; | 112 WorkerClients* clients = WorkerClients::create(); |
| 113 provideCompositorProxyClientTo(clients, new TestCompositorProxyClient); |
101 workerThread->start(WorkerThreadStartupData::create( | 114 workerThread->start(WorkerThreadStartupData::create( |
102 KURL(ParsedURLString, "http://fake.url/"), | 115 KURL(ParsedURLString, "http://fake.url/"), |
103 "fake user agent", | 116 "fake user agent", |
104 "//fake source code", | 117 "//fake source code", |
105 nullptr, | 118 nullptr, |
106 DontPauseWorkerGlobalScopeOnStart, | 119 DontPauseWorkerGlobalScopeOnStart, |
107 adoptPtr(new Vector<CSPHeaderAndType>()), | 120 adoptPtr(new Vector<CSPHeaderAndType>()), |
108 m_securityOrigin.get(), | 121 m_securityOrigin.get(), |
109 clients, | 122 clients, |
110 WebAddressSpaceLocal, | 123 WebAddressSpaceLocal, |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 v8::Isolate* secondIsolate = secondWorker->isolate(); | 231 v8::Isolate* secondIsolate = secondWorker->isolate(); |
219 ASSERT_TRUE(secondIsolate); | 232 ASSERT_TRUE(secondIsolate); |
220 EXPECT_EQ(firstIsolate, secondIsolate); | 233 EXPECT_EQ(firstIsolate, secondIsolate); |
221 | 234 |
222 // Verify that the isolate can run some scripts correctly in the second work
er. | 235 // Verify that the isolate can run some scripts correctly in the second work
er. |
223 checkWorkerCanExecuteScript(secondWorker.get()); | 236 checkWorkerCanExecuteScript(secondWorker.get()); |
224 secondWorker->terminateAndWait(); | 237 secondWorker->terminateAndWait(); |
225 } | 238 } |
226 | 239 |
227 } // namespace blink | 240 } // namespace blink |
OLD | NEW |