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

Side by Side Diff: Source/modules/compositorworker/CompositorWorkerManagerTest.cpp

Issue 1303153005: Introduce WebTaskRunner Patch 3/5 (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add missing #include Created 5 years, 3 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 "config.h" 5 #include "config.h"
6 #include "modules/compositorworker/CompositorWorkerManager.h" 6 #include "modules/compositorworker/CompositorWorkerManager.h"
7 7
8 #include "bindings/core/v8/ScriptSourceCode.h" 8 #include "bindings/core/v8/ScriptSourceCode.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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 125
126 void createWorkerAdapter(RefPtr<CompositorWorkerThread>* workerThread, WebWa itableEvent* creationEvent) 126 void createWorkerAdapter(RefPtr<CompositorWorkerThread>* workerThread, WebWa itableEvent* creationEvent)
127 { 127 {
128 *workerThread = createCompositorWorker(creationEvent); 128 *workerThread = createCompositorWorker(creationEvent);
129 } 129 }
130 130
131 // Attempts to run some simple script for |worker|. 131 // Attempts to run some simple script for |worker|.
132 void checkWorkerCanExecuteScript(WorkerThread* worker) 132 void checkWorkerCanExecuteScript(WorkerThread* worker)
133 { 133 {
134 OwnPtr<WebWaitableEvent> waitEvent = adoptPtr(Platform::current()->creat eWaitableEvent()); 134 OwnPtr<WebWaitableEvent> waitEvent = adoptPtr(Platform::current()->creat eWaitableEvent());
135 worker->backingThread().platformThread().postTask(FROM_HERE, threadSafeB ind(&CompositorWorkerManagerTest::executeScriptInWorker, AllowCrossThreadAccess( this), 135 worker->backingThread().platformThread().taskRunner()->postTask(FROM_HER E, threadSafeBind(&CompositorWorkerManagerTest::executeScriptInWorker, AllowCros sThreadAccess(this),
136 AllowCrossThreadAccess(worker), AllowCrossThreadAccess(waitEvent.get ()))); 136 AllowCrossThreadAccess(worker), AllowCrossThreadAccess(waitEvent.get ())));
137 waitEvent->wait(); 137 waitEvent->wait();
138 } 138 }
139 139
140 void waitForWaitableEventAfterIteratingCurrentLoop(WebWaitableEvent* waitEve nt) 140 void waitForWaitableEventAfterIteratingCurrentLoop(WebWaitableEvent* waitEve nt)
141 { 141 {
142 testing::runPendingTasks(); 142 testing::runPendingTasks();
143 waitEvent->wait(); 143 waitEvent->wait();
144 } 144 }
145 145
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 // Create the second worker. Verify that the second worker lives in a differ ent WebThread since the first 230 // Create the second worker. Verify that the second worker lives in a differ ent WebThread since the first
231 // thread will have been destroyed after destroying the first worker. 231 // thread will have been destroyed after destroying the first worker.
232 creationEvent = adoptPtr(Platform::current()->createWaitableEvent()); 232 creationEvent = adoptPtr(Platform::current()->createWaitableEvent());
233 compositorWorker = createCompositorWorker(creationEvent.get()); 233 compositorWorker = createCompositorWorker(creationEvent.get());
234 WebThreadSupportingGC* secondThread = &CompositorWorkerManager::instance()-> compositorWorkerThread(); 234 WebThreadSupportingGC* secondThread = &CompositorWorkerManager::instance()-> compositorWorkerThread();
235 EXPECT_NE(firstThread, secondThread); 235 EXPECT_NE(firstThread, secondThread);
236 waitForWaitableEventAfterIteratingCurrentLoop(creationEvent.get()); 236 waitForWaitableEventAfterIteratingCurrentLoop(creationEvent.get());
237 237
238 // Jump over to the worker's thread to verify that the Isolate is set up cor rectly and execute script. 238 // Jump over to the worker's thread to verify that the Isolate is set up cor rectly and execute script.
239 OwnPtr<WebWaitableEvent> checkEvent = adoptPtr(Platform::current()->createWa itableEvent()); 239 OwnPtr<WebWaitableEvent> checkEvent = adoptPtr(Platform::current()->createWa itableEvent());
240 secondThread->platformThread().postTask(FROM_HERE, threadSafeBind(&checkCurr entIsolate, AllowCrossThreadAccess(compositorWorker->isolate()), AllowCrossThrea dAccess(checkEvent.get()))); 240 secondThread->platformThread().taskRunner()->postTask(FROM_HERE, threadSafeB ind(&checkCurrentIsolate, AllowCrossThreadAccess(compositorWorker->isolate()), A llowCrossThreadAccess(checkEvent.get())));
241 waitForWaitableEventAfterIteratingCurrentLoop(checkEvent.get()); 241 waitForWaitableEventAfterIteratingCurrentLoop(checkEvent.get());
242 checkWorkerCanExecuteScript(compositorWorker.get()); 242 checkWorkerCanExecuteScript(compositorWorker.get());
243 243
244 compositorWorker->terminateAndWait(); 244 compositorWorker->terminateAndWait();
245 } 245 }
246 246
247 // Tests that v8::Isolate and WebThread are correctly set-up if a worker is crea ted while another is terminating. 247 // Tests that v8::Isolate and WebThread are correctly set-up if a worker is crea ted while another is terminating.
248 TEST_F(CompositorWorkerManagerTest, CreatingSecondDuringTerminationOfFirst) 248 TEST_F(CompositorWorkerManagerTest, CreatingSecondDuringTerminationOfFirst)
249 { 249 {
250 OwnPtr<WebWaitableEvent> firstCreationEvent = adoptPtr(Platform::current()-> createWaitableEvent()); 250 OwnPtr<WebWaitableEvent> firstCreationEvent = adoptPtr(Platform::current()-> createWaitableEvent());
(...skipping 14 matching lines...) Expand all
265 v8::Isolate* secondIsolate = secondWorker->isolate(); 265 v8::Isolate* secondIsolate = secondWorker->isolate();
266 ASSERT(secondIsolate); 266 ASSERT(secondIsolate);
267 EXPECT_EQ(firstIsolate, secondIsolate); 267 EXPECT_EQ(firstIsolate, secondIsolate);
268 268
269 // Verify that the isolate can run some scripts correctly in the second work er. 269 // Verify that the isolate can run some scripts correctly in the second work er.
270 checkWorkerCanExecuteScript(secondWorker.get()); 270 checkWorkerCanExecuteScript(secondWorker.get());
271 secondWorker->terminateAndWait(); 271 secondWorker->terminateAndWait();
272 } 272 }
273 273
274 } // namespace blink 274 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/compositorworker/CompositorWorkerManager.cpp ('k') | Source/modules/fetch/CompositeDataConsumerHandle.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698