Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(802)

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/AudioWorkletThreadTest.cpp

Issue 2513413003: Worker: Provide a way to access parent frame task runners from a worker thread (Closed)
Patch Set: update comments Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/webaudio/AudioWorkletThread.h" 5 #include "modules/webaudio/AudioWorkletThread.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/inspector/ConsoleMessage.h" 11 #include "core/inspector/ConsoleMessage.h"
12 #include "core/workers/ParentFrameTaskRunners.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/WorkerOrWorkletGlobalScope.h" 15 #include "core/workers/WorkerOrWorkletGlobalScope.h"
15 #include "core/workers/WorkerReportingProxy.h" 16 #include "core/workers/WorkerReportingProxy.h"
16 #include "core/workers/WorkerThreadStartupData.h" 17 #include "core/workers/WorkerThreadStartupData.h"
17 #include "platform/CrossThreadFunctional.h" 18 #include "platform/CrossThreadFunctional.h"
18 #include "platform/WaitableEvent.h" 19 #include "platform/WaitableEvent.h"
19 #include "platform/WebThreadSupportingGC.h" 20 #include "platform/WebThreadSupportingGC.h"
20 #include "platform/heap/Handle.h" 21 #include "platform/heap/Handle.h"
21 #include "platform/testing/TestingPlatformSupport.h" 22 #include "platform/testing/TestingPlatformSupport.h"
22 #include "platform/testing/UnitTestHelpers.h" 23 #include "platform/testing/UnitTestHelpers.h"
23 #include "public/platform/Platform.h" 24 #include "public/platform/Platform.h"
24 #include "public/platform/WebAddressSpace.h" 25 #include "public/platform/WebAddressSpace.h"
25 #include "testing/gtest/include/gtest/gtest.h" 26 #include "testing/gtest/include/gtest/gtest.h"
26 #include "wtf/PtrUtil.h" 27 #include "wtf/PtrUtil.h"
27 #include <memory> 28 #include <memory>
28 29
29 namespace blink { 30 namespace blink {
30 31
31 namespace { 32 namespace {
32 33
33 // A null WorkerReportingProxy, supplied when creating AudioWorkletThreads. 34 // A null WorkerReportingProxy, supplied when creating AudioWorkletThreads.
34 class TestAudioWorkletReportingProxy : public WorkerReportingProxy { 35 class TestAudioWorkletReportingProxy : public WorkerReportingProxy {
35 public: 36 public:
36 static std::unique_ptr<TestAudioWorkletReportingProxy> create() { 37 static std::unique_ptr<TestAudioWorkletReportingProxy> create() {
37 return wrapUnique(new TestAudioWorkletReportingProxy()); 38 return wrapUnique(new TestAudioWorkletReportingProxy());
38 } 39 }
39 40
40 // (Empty) WorkerReportingProxy implementation: 41 // (Empty) WorkerReportingProxy implementation:
kinuko 2016/11/28 04:24:09 Empty -> well, 'almost' empty?
nhiroki 2016/11/28 05:29:26 Acknowledged. I'll fix this in a separate CL.
41 void reportException(const String& errorMessage, 42 void reportException(const String& errorMessage,
42 std::unique_ptr<SourceLocation>, 43 std::unique_ptr<SourceLocation>,
43 int exceptionId) override {} 44 int exceptionId) override {}
44 void reportConsoleMessage(MessageSource, 45 void reportConsoleMessage(MessageSource,
45 MessageLevel, 46 MessageLevel,
46 const String& message, 47 const String& message,
47 SourceLocation*) override {} 48 SourceLocation*) override {}
48 void postMessageToPageInspector(const String&) override {} 49 void postMessageToPageInspector(const String&) override {}
50 ParentFrameTaskRunners* getParentFrameTaskRunners() override {
51 return m_parentFrameTaskRunners.get();
52 }
49 53
50 void didEvaluateWorkerScript(bool success) override {} 54 void didEvaluateWorkerScript(bool success) override {}
51 void didCloseWorkerGlobalScope() override {} 55 void didCloseWorkerGlobalScope() override {}
52 void willDestroyWorkerGlobalScope() override {} 56 void willDestroyWorkerGlobalScope() override {}
53 void didTerminateWorkerThread() override {} 57 void didTerminateWorkerThread() override {}
54 58
55 private: 59 private:
56 TestAudioWorkletReportingProxy() {} 60 TestAudioWorkletReportingProxy()
61 : m_parentFrameTaskRunners(ParentFrameTaskRunners::create(nullptr)) {}
62
63 Persistent<ParentFrameTaskRunners> m_parentFrameTaskRunners;
57 }; 64 };
58 65
59 } // namespace 66 } // namespace
60 67
61 class AudioWorkletThreadTest : public ::testing::Test { 68 class AudioWorkletThreadTest : public ::testing::Test {
62 public: 69 public:
63 void SetUp() override { 70 void SetUp() override {
64 AudioWorkletThread::createSharedBackingThreadForTest(); 71 AudioWorkletThread::createSharedBackingThreadForTest();
65 m_reportingProxy = TestAudioWorkletReportingProxy::create(); 72 m_reportingProxy = TestAudioWorkletReportingProxy::create();
66 m_securityOrigin = 73 m_securityOrigin =
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 ASSERT_TRUE(secondIsolate); 194 ASSERT_TRUE(secondIsolate);
188 EXPECT_EQ(firstIsolate, secondIsolate); 195 EXPECT_EQ(firstIsolate, secondIsolate);
189 196
190 // Verify that the isolate can run some scripts correctly in the second 197 // Verify that the isolate can run some scripts correctly in the second
191 // worklet. 198 // worklet.
192 checkWorkletCanExecuteScript(secondWorklet.get()); 199 checkWorkletCanExecuteScript(secondWorklet.get());
193 secondWorklet->terminateAndWait(); 200 secondWorklet->terminateAndWait();
194 } 201 }
195 202
196 } // namespace blink 203 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698