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

Side by Side Diff: base/message_loop_unittest.cc

Issue 9384024: Prefer ScopedNestableTaskAllower over manual save/restore (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <vector> 5 #include <vector>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/eintr_wrapper.h" 10 #include "base/eintr_wrapper.h"
(...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 EXPECT_EQ(order.Get(14), TaskItem(RECURSIVE, 1, true)); 978 EXPECT_EQ(order.Get(14), TaskItem(RECURSIVE, 1, true));
979 EXPECT_EQ(order.Get(15), TaskItem(RECURSIVE, 1, false)); 979 EXPECT_EQ(order.Get(15), TaskItem(RECURSIVE, 1, false));
980 EXPECT_EQ(order.Get(16), TaskItem(RECURSIVE, 3, true)); 980 EXPECT_EQ(order.Get(16), TaskItem(RECURSIVE, 3, true));
981 EXPECT_EQ(order.Get(17), TaskItem(RECURSIVE, 3, false)); 981 EXPECT_EQ(order.Get(17), TaskItem(RECURSIVE, 3, false));
982 } 982 }
983 983
984 #endif // defined(OS_WIN) 984 #endif // defined(OS_WIN)
985 985
986 void FuncThatPumps(TaskList* order, int cookie) { 986 void FuncThatPumps(TaskList* order, int cookie) {
987 order->RecordStart(PUMPS, cookie); 987 order->RecordStart(PUMPS, cookie);
988 bool old_state = MessageLoop::current()->NestableTasksAllowed(); 988 {
989 MessageLoop::current()->SetNestableTasksAllowed(true); 989 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current());
990 MessageLoop::current()->RunAllPending(); 990 MessageLoop::current()->RunAllPending();
991 MessageLoop::current()->SetNestableTasksAllowed(old_state); 991 }
992 order->RecordEnd(PUMPS, cookie); 992 order->RecordEnd(PUMPS, cookie);
993 } 993 }
994 994
995 // Tests that non nestable tasks run in FIFO if there are no nested loops. 995 // Tests that non nestable tasks run in FIFO if there are no nested loops.
996 void RunTest_NonNestableWithNoNesting( 996 void RunTest_NonNestableWithNoNesting(
997 MessageLoop::Type message_loop_type) { 997 MessageLoop::Type message_loop_type) {
998 MessageLoop loop(message_loop_type); 998 MessageLoop loop(message_loop_type);
999 999
1000 TaskList order; 1000 TaskList order;
1001 1001
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
1675 base::Bind(&DestructionObserverProbe::Run, 1675 base::Bind(&DestructionObserverProbe::Run,
1676 new DestructionObserverProbe(&task_destroyed, 1676 new DestructionObserverProbe(&task_destroyed,
1677 &destruction_observer_called)), 1677 &destruction_observer_called)),
1678 kDelay); 1678 kDelay);
1679 delete loop; 1679 delete loop;
1680 EXPECT_TRUE(observer.task_destroyed_before_message_loop()); 1680 EXPECT_TRUE(observer.task_destroyed_before_message_loop());
1681 // The task should have been destroyed when we deleted the loop. 1681 // The task should have been destroyed when we deleted the loop.
1682 EXPECT_TRUE(task_destroyed); 1682 EXPECT_TRUE(task_destroyed);
1683 EXPECT_TRUE(destruction_observer_called); 1683 EXPECT_TRUE(destruction_observer_called);
1684 } 1684 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698