Chromium Code Reviews| Index: base/task_scheduler/task_tracker_unittest.cc | 
| diff --git a/base/task_scheduler/task_tracker_unittest.cc b/base/task_scheduler/task_tracker_unittest.cc | 
| index 3a1ff789442496a625cf00158b02c337bdcdfe16..74ad963228cc5fb80a6dbf8810c31f0875d29944 100644 | 
| --- a/base/task_scheduler/task_tracker_unittest.cc | 
| +++ b/base/task_scheduler/task_tracker_unittest.cc | 
| @@ -431,6 +431,34 @@ TEST_P(TaskSchedulerTaskTrackerTest, SingletonAllowed) { | 
| } | 
| } | 
| +// Verify that AssertIOAllowed() succeeds only for a WithFileIO() task. | 
| +TEST_P(TaskSchedulerTaskTrackerTest, IOAllowed) { | 
| + TaskTracker tracker; | 
| + | 
| + // Unset the IO allowed bit. Expect TaskTracker to set it before running a | 
| + // task with the WithFileIO() trait. | 
| + ThreadRestrictions::SetIOAllowed(false); | 
| + std::unique_ptr<Task> task_with_file_io(new Task( | 
| 
 
gab
2016/11/28 16:45:47
= MakeUnique<Task>(...)
 
fdoray
2016/11/28 17:44:28
Done.
 
 | 
| + FROM_HERE, Bind([]() { | 
| + // Shouldn't fail. | 
| + ThreadRestrictions::AssertIOAllowed(); | 
| + }), | 
| + TaskTraits().WithFileIO().WithShutdownBehavior(GetParam()), TimeDelta())); | 
| + EXPECT_TRUE(tracker.WillPostTask(task_with_file_io.get())); | 
| + tracker.RunTask(std::move(task_with_file_io), SequenceToken::Create()); | 
| + | 
| + // Set the IO allowed bit. Expect TaskTracker to unset it before running a | 
| + // task without the WithFileIO() trait. | 
| + ThreadRestrictions::SetIOAllowed(true); | 
| + std::unique_ptr<Task> task_without_file_io(new Task( | 
| 
 
gab
2016/11/28 16:45:47
ditto
 
fdoray
2016/11/28 17:44:28
Done.
 
 | 
| + FROM_HERE, Bind([]() { | 
| + EXPECT_DCHECK_DEATH({ ThreadRestrictions::AssertIOAllowed(); }); | 
| + }), | 
| + TaskTraits().WithShutdownBehavior(GetParam()), TimeDelta())); | 
| + EXPECT_TRUE(tracker.WillPostTask(task_without_file_io.get())); | 
| + tracker.RunTask(std::move(task_without_file_io), SequenceToken::Create()); | 
| +} | 
| + | 
| static void RunTaskRunnerHandleVerificationTask( | 
| TaskTracker* tracker, | 
| std::unique_ptr<Task> verify_task) { |