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

Side by Side Diff: third_party/WebKit/Source/modules/compositorworker/CompositorWorkerThreadTest.cpp

Issue 2718643002: Worker: Pass ParentFrameTaskRunners via WorkerThread::start() instead of the ctor (Closed)
Patch Set: Created 3 years, 10 months 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 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/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"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 m_securityOrigin = 101 m_securityOrigin =
102 SecurityOrigin::create(KURL(ParsedURLString, "http://fake.url/")); 102 SecurityOrigin::create(KURL(ParsedURLString, "http://fake.url/"));
103 } 103 }
104 104
105 void TearDown() override { 105 void TearDown() override {
106 CompositorWorkerThread::clearSharedBackingThread(); 106 CompositorWorkerThread::clearSharedBackingThread();
107 } 107 }
108 108
109 std::unique_ptr<CompositorWorkerThread> createCompositorWorker() { 109 std::unique_ptr<CompositorWorkerThread> createCompositorWorker() {
110 std::unique_ptr<CompositorWorkerThread> workerThread = 110 std::unique_ptr<CompositorWorkerThread> workerThread =
111 CompositorWorkerThread::create(nullptr, *m_objectProxy, 111 CompositorWorkerThread::create(nullptr, *m_objectProxy, 0);
112 m_parentFrameTaskRunners.get(), 0);
113 WorkerClients* clients = WorkerClients::create(); 112 WorkerClients* clients = WorkerClients::create();
114 provideCompositorWorkerProxyClientTo(clients, 113 provideCompositorWorkerProxyClientTo(clients,
115 new TestCompositorWorkerProxyClient); 114 new TestCompositorWorkerProxyClient);
116 workerThread->start(WorkerThreadStartupData::create( 115 workerThread->start(
117 KURL(ParsedURLString, "http://fake.url/"), "fake user agent", 116 WorkerThreadStartupData::create(
118 "//fake source code", nullptr, DontPauseWorkerGlobalScopeOnStart, 117 KURL(ParsedURLString, "http://fake.url/"), "fake user agent",
119 nullptr, "", m_securityOrigin.get(), clients, WebAddressSpaceLocal, 118 "//fake source code", nullptr, DontPauseWorkerGlobalScopeOnStart,
120 nullptr, nullptr, WorkerV8Settings::Default())); 119 nullptr, "", m_securityOrigin.get(), clients, WebAddressSpaceLocal,
120 nullptr, nullptr, WorkerV8Settings::Default()),
121 m_parentFrameTaskRunners.get());
121 return workerThread; 122 return workerThread;
122 } 123 }
123 124
124 // Attempts to run some simple script for |worker|. 125 // Attempts to run some simple script for |worker|.
125 void checkWorkerCanExecuteScript(WorkerThread* worker) { 126 void checkWorkerCanExecuteScript(WorkerThread* worker) {
126 std::unique_ptr<WaitableEvent> waitEvent = WTF::makeUnique<WaitableEvent>(); 127 std::unique_ptr<WaitableEvent> waitEvent = WTF::makeUnique<WaitableEvent>();
127 worker->workerBackingThread().backingThread().postTask( 128 worker->workerBackingThread().backingThread().postTask(
128 BLINK_FROM_HERE, 129 BLINK_FROM_HERE,
129 crossThreadBind(&CompositorWorkerThreadTest::executeScriptInWorker, 130 crossThreadBind(&CompositorWorkerThreadTest::executeScriptInWorker,
130 crossThreadUnretained(this), 131 crossThreadUnretained(this),
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 ASSERT_TRUE(secondIsolate); 239 ASSERT_TRUE(secondIsolate);
239 EXPECT_EQ(firstIsolate, secondIsolate); 240 EXPECT_EQ(firstIsolate, secondIsolate);
240 241
241 // Verify that the isolate can run some scripts correctly in the second 242 // Verify that the isolate can run some scripts correctly in the second
242 // worker. 243 // worker.
243 checkWorkerCanExecuteScript(secondWorker.get()); 244 checkWorkerCanExecuteScript(secondWorker.get());
244 secondWorker->terminateAndWait(); 245 secondWorker->terminateAndWait();
245 } 246 }
246 247
247 } // namespace blink 248 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698