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

Unified Diff: content/child/scheduler/task_queue_manager_unittest.cc

Issue 1072473002: Speculative patch: Make it safe to delete the TQM inside a Task (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added some comments Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/child/scheduler/task_queue_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/scheduler/task_queue_manager_unittest.cc
diff --git a/content/child/scheduler/task_queue_manager_unittest.cc b/content/child/scheduler/task_queue_manager_unittest.cc
index 8fa5e29d7818820be834cf46c8192442352e82d8..b145b9eab0686f9285830abb1df85d446f07387b 100644
--- a/content/child/scheduler/task_queue_manager_unittest.cc
+++ b/content/child/scheduler/task_queue_manager_unittest.cc
@@ -98,6 +98,11 @@ class ExplicitSelectorForTest : public SelectorForTest {
};
class TaskQueueManagerTest : public testing::Test {
+ public:
+ void DeleteTaskQueueManager() {
+ manager_.reset();
+ }
+
protected:
enum class SelectorType {
Automatic,
@@ -1036,5 +1041,19 @@ TEST_F(TaskQueueManagerTest, NextPendingDelayedTaskRunTime_MultipleQueues) {
manager_->NextPendingDelayedTaskRunTime());
}
+TEST_F(TaskQueueManagerTest, DeleteTaskQueueManagerInsideATask) {
+ Initialize(1u, SelectorType::Automatic);
+
+ scoped_refptr<base::SingleThreadTaskRunner> runner =
+ manager_->TaskRunnerForQueue(0);
+ runner->PostTask(FROM_HERE,
+ base::Bind(&TaskQueueManagerTest::DeleteTaskQueueManager,
+ base::Unretained(this)));
+
+ // This should not crash, assuming DoWork detects the TaskQueueManager has
+ // been deleted.
+ test_task_runner_->RunUntilIdle();
+}
+
} // namespace
} // namespace content
« no previous file with comments | « content/child/scheduler/task_queue_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698