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

Side by Side Diff: third_party/WebKit/Source/platform/threading/BackgroundTaskRunnerTest.cpp

Issue 1682423002: Remove WebWaitableEvent and replace it with WaitableEvent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix android build Created 4 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 "platform/threading/BackgroundTaskRunner.h" 5 #include "platform/threading/BackgroundTaskRunner.h"
6 6
7 #include "platform/ThreadSafeFunctional.h" 7 #include "platform/ThreadSafeFunctional.h"
8 #include "public/platform/Platform.h" 8 #include "platform/WaitableEvent.h"
9 #include "public/platform/WebTraceLocation.h" 9 #include "public/platform/WebTraceLocation.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 12
13 namespace { 13 namespace {
14 14
15 using namespace blink; 15 using namespace blink;
16 16
17 void PingPongTask(WebWaitableEvent* doneEvent) 17 void PingPongTask(WaitableEvent* doneEvent)
18 { 18 {
19 doneEvent->signal(); 19 doneEvent->signal();
20 } 20 }
21 21
22 class BackgroundTaskRunnerTest : public testing::Test { 22 class BackgroundTaskRunnerTest : public testing::Test {
23 }; 23 };
24 24
25 TEST_F(BackgroundTaskRunnerTest, RunShortTaskOnBackgroundThread) 25 TEST_F(BackgroundTaskRunnerTest, RunShortTaskOnBackgroundThread)
26 { 26 {
27 OwnPtr<WebWaitableEvent> doneEvent = adoptPtr(Platform::current()->createWai tableEvent()); 27 OwnPtr<WaitableEvent> doneEvent = adoptPtr(new WaitableEvent());
28 BackgroundTaskRunner::postOnBackgroundThread(BLINK_FROM_HERE, threadSafeBind (&PingPongTask, AllowCrossThreadAccess(doneEvent.get())), BackgroundTaskRunner:: TaskSizeShortRunningTask); 28 BackgroundTaskRunner::postOnBackgroundThread(BLINK_FROM_HERE, threadSafeBind (&PingPongTask, AllowCrossThreadAccess(doneEvent.get())), BackgroundTaskRunner:: TaskSizeShortRunningTask);
29 // Test passes by not hanging on the following wait(). 29 // Test passes by not hanging on the following wait().
30 doneEvent->wait(); 30 doneEvent->wait();
31 } 31 }
32 32
33 TEST_F(BackgroundTaskRunnerTest, RunLongTaskOnBackgroundThread) 33 TEST_F(BackgroundTaskRunnerTest, RunLongTaskOnBackgroundThread)
34 { 34 {
35 OwnPtr<WebWaitableEvent> doneEvent = adoptPtr(Platform::current()->createWai tableEvent()); 35 OwnPtr<WaitableEvent> doneEvent = adoptPtr(new WaitableEvent());
36 BackgroundTaskRunner::postOnBackgroundThread(BLINK_FROM_HERE, threadSafeBind (&PingPongTask, AllowCrossThreadAccess(doneEvent.get())), BackgroundTaskRunner:: TaskSizeLongRunningTask); 36 BackgroundTaskRunner::postOnBackgroundThread(BLINK_FROM_HERE, threadSafeBind (&PingPongTask, AllowCrossThreadAccess(doneEvent.get())), BackgroundTaskRunner:: TaskSizeLongRunningTask);
37 // Test passes by not hanging on the following wait(). 37 // Test passes by not hanging on the following wait().
38 doneEvent->wait(); 38 doneEvent->wait();
39 } 39 }
40 40
41 } // unnamed namespace 41 } // unnamed namespace
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/Canvas2DLayerBridgeTest.cpp ('k') | third_party/WebKit/public/blink_headers.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698