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

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

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt to land. Created 4 years, 6 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 "platform/WaitableEvent.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 #include "wtf/PtrUtil.h"
12 #include <memory>
11 13
12 14
13 namespace { 15 namespace {
14 16
15 using namespace blink; 17 using namespace blink;
16 18
17 void PingPongTask(WaitableEvent* doneEvent) 19 void PingPongTask(WaitableEvent* doneEvent)
18 { 20 {
19 doneEvent->signal(); 21 doneEvent->signal();
20 } 22 }
21 23
22 class BackgroundTaskRunnerTest : public testing::Test { 24 class BackgroundTaskRunnerTest : public testing::Test {
23 }; 25 };
24 26
25 TEST_F(BackgroundTaskRunnerTest, RunShortTaskOnBackgroundThread) 27 TEST_F(BackgroundTaskRunnerTest, RunShortTaskOnBackgroundThread)
26 { 28 {
27 OwnPtr<WaitableEvent> doneEvent = adoptPtr(new WaitableEvent()); 29 std::unique_ptr<WaitableEvent> doneEvent = wrapUnique(new WaitableEvent());
28 BackgroundTaskRunner::postOnBackgroundThread(BLINK_FROM_HERE, threadSafeBind (&PingPongTask, AllowCrossThreadAccess(doneEvent.get())), BackgroundTaskRunner:: TaskSizeShortRunningTask); 30 BackgroundTaskRunner::postOnBackgroundThread(BLINK_FROM_HERE, threadSafeBind (&PingPongTask, AllowCrossThreadAccess(doneEvent.get())), BackgroundTaskRunner:: TaskSizeShortRunningTask);
29 // Test passes by not hanging on the following wait(). 31 // Test passes by not hanging on the following wait().
30 doneEvent->wait(); 32 doneEvent->wait();
31 } 33 }
32 34
33 TEST_F(BackgroundTaskRunnerTest, RunLongTaskOnBackgroundThread) 35 TEST_F(BackgroundTaskRunnerTest, RunLongTaskOnBackgroundThread)
34 { 36 {
35 OwnPtr<WaitableEvent> doneEvent = adoptPtr(new WaitableEvent()); 37 std::unique_ptr<WaitableEvent> doneEvent = wrapUnique(new WaitableEvent());
36 BackgroundTaskRunner::postOnBackgroundThread(BLINK_FROM_HERE, threadSafeBind (&PingPongTask, AllowCrossThreadAccess(doneEvent.get())), BackgroundTaskRunner:: TaskSizeLongRunningTask); 38 BackgroundTaskRunner::postOnBackgroundThread(BLINK_FROM_HERE, threadSafeBind (&PingPongTask, AllowCrossThreadAccess(doneEvent.get())), BackgroundTaskRunner:: TaskSizeLongRunningTask);
37 // Test passes by not hanging on the following wait(). 39 // Test passes by not hanging on the following wait().
38 doneEvent->wait(); 40 doneEvent->wait();
39 } 41 }
40 42
41 } // unnamed namespace 43 } // unnamed namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698