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

Side by Side Diff: Source/core/workers/WorkerThreadTest.cpp

Issue 1274023003: compositor-worker: Get the thread to run compositor-workers from the Platform. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: . Created 5 years, 4 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 | Annotate | Revision Log
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 "core/workers/WorkerThread.h" 6 #include "core/workers/WorkerThread.h"
7 7
8 #include "core/inspector/ConsoleMessage.h" 8 #include "core/inspector/ConsoleMessage.h"
9 #include "core/workers/WorkerReportingProxy.h" 9 #include "core/workers/WorkerReportingProxy.h"
10 #include "core/workers/WorkerThreadStartupData.h" 10 #include "core/workers/WorkerThreadStartupData.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 WorkerReportingProxy& mockWorkerReportingProxy) 98 WorkerReportingProxy& mockWorkerReportingProxy)
99 : WorkerThread(WorkerLoaderProxy::create(mockWorkerLoaderProxyProvider), mockWorkerReportingProxy) 99 : WorkerThread(WorkerLoaderProxy::create(mockWorkerLoaderProxyProvider), mockWorkerReportingProxy)
100 , m_thread(WebThreadSupportingGC::create("Test thread")) 100 , m_thread(WebThreadSupportingGC::create("Test thread"))
101 , m_scriptLoadedEvent(adoptPtr(Platform::current()->createWaitableEvent( ))) 101 , m_scriptLoadedEvent(adoptPtr(Platform::current()->createWaitableEvent( )))
102 { 102 {
103 } 103 }
104 104
105 ~WorkerThreadForTest() override { } 105 ~WorkerThreadForTest() override { }
106 106
107 // WorkerThread implementation: 107 // WorkerThread implementation:
108 WebThreadSupportingGC& backingThread() override 108 WebThread& backingThread() override
109 { 109 {
110 return *m_thread; 110 return m_thread->platformThread();
111 } 111 }
112 112
113 MOCK_METHOD1(doIdleGc, bool(double deadlineSeconds)); 113 MOCK_METHOD1(doIdleGc, bool(double deadlineSeconds));
114 114
115 PassRefPtrWillBeRawPtr<WorkerGlobalScope> createWorkerGlobalScope(PassOwnPtr <WorkerThreadStartupData> startupData) override 115 PassRefPtrWillBeRawPtr<WorkerGlobalScope> createWorkerGlobalScope(PassOwnPtr <WorkerThreadStartupData> startupData) override
116 { 116 {
117 return adoptRefWillBeNoop(new FakeWorkerGlobalScope(startupData->m_scrip tURL, startupData->m_userAgent, this, startupData->m_starterOrigin, startupData- >m_workerClients.release())); 117 return adoptRefWillBeNoop(new FakeWorkerGlobalScope(startupData->m_scrip tURL, startupData->m_userAgent, this, startupData->m_starterOrigin, startupData- >m_workerClients.release()));
118 } 118 }
119 119
120 void waitUntilScriptLoaded() 120 void waitUntilScriptLoaded()
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 TEST_F(WorkerThreadTest, GcDoesNotOccurWhenNotIdle) 317 TEST_F(WorkerThreadTest, GcDoesNotOccurWhenNotIdle)
318 { 318 {
319 OwnPtr<WebWaitableEvent> completion = adoptPtr(Platform::current()->createWa itableEvent()); 319 OwnPtr<WebWaitableEvent> completion = adoptPtr(Platform::current()->createWa itableEvent());
320 320
321 EXPECT_CALL(*m_workerThread, doIdleGc(_)).Times(0); 321 EXPECT_CALL(*m_workerThread, doIdleGc(_)).Times(0);
322 322
323 expectWorkerLifetimeReportingCalls(); 323 expectWorkerLifetimeReportingCalls();
324 start(); 324 start();
325 waitForInit(); 325 waitForInit();
326 326
327 WebScheduler* scheduler = m_workerThread->backingThread().platformThread().s cheduler(); 327 WebScheduler* scheduler = m_workerThread->backingThread().scheduler();
328 328
329 // Post a repeating task that should prevent any GC from happening. 329 // Post a repeating task that should prevent any GC from happening.
330 scheduler->postLoadingTask(FROM_HERE, new RepeatingTask(scheduler, completio n.get())); 330 scheduler->postLoadingTask(FROM_HERE, new RepeatingTask(scheduler, completio n.get()));
331 331
332 completion->wait(); 332 completion->wait();
333 333
334 // Make sure doIdleGc has not been called by this stage. 334 // Make sure doIdleGc has not been called by this stage.
335 Mock::VerifyAndClearExpectations(m_workerThread.get()); 335 Mock::VerifyAndClearExpectations(m_workerThread.get());
336 336
337 m_workerThread->terminateAndWait(); 337 m_workerThread->terminateAndWait();
338 } 338 }
339 339
340 } // namespace blink 340 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698