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

Side by Side Diff: base/threading/sequenced_worker_pool_unittest.cc

Issue 1852433005: Convert //base to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase after r384946 Created 4 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 unified diff | Download patch
« no previous file with comments | « base/threading/sequenced_worker_pool.cc ('k') | base/threading/thread.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/threading/sequenced_worker_pool.h" 5 #include "base/threading/sequenced_worker_pool.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory>
10 11
11 #include "base/bind.h" 12 #include "base/bind.h"
12 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
13 #include "base/macros.h" 14 #include "base/macros.h"
14 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
17 #include "base/sequence_checker_impl.h" 17 #include "base/sequence_checker_impl.h"
18 #include "base/stl_util.h" 18 #include "base/stl_util.h"
19 #include "base/synchronization/condition_variable.h" 19 #include "base/synchronization/condition_variable.h"
20 #include "base/synchronization/lock.h" 20 #include "base/synchronization/lock.h"
21 #include "base/synchronization/waitable_event.h" 21 #include "base/synchronization/waitable_event.h"
22 #include "base/test/sequenced_task_runner_test_template.h" 22 #include "base/test/sequenced_task_runner_test_template.h"
23 #include "base/test/sequenced_worker_pool_owner.h" 23 #include "base/test/sequenced_worker_pool_owner.h"
24 #include "base/test/task_runner_test_template.h" 24 #include "base/test/task_runner_test_template.h"
25 #include "base/test/test_timeouts.h" 25 #include "base/test/test_timeouts.h"
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 // Clean up the task IDs we added. 287 // Clean up the task IDs we added.
288 tracker()->ClearCompleteSequence(); 288 tracker()->ClearCompleteSequence();
289 } 289 }
290 290
291 int has_work_call_count() const { 291 int has_work_call_count() const {
292 return pool_owner_->has_work_call_count(); 292 return pool_owner_->has_work_call_count();
293 } 293 }
294 294
295 private: 295 private:
296 MessageLoop message_loop_; 296 MessageLoop message_loop_;
297 scoped_ptr<SequencedWorkerPoolOwner> pool_owner_; 297 std::unique_ptr<SequencedWorkerPoolOwner> pool_owner_;
298 const scoped_refptr<TestTracker> tracker_; 298 const scoped_refptr<TestTracker> tracker_;
299 }; 299 };
300 300
301 // Checks that the given number of entries are in the tasks to complete of 301 // Checks that the given number of entries are in the tasks to complete of
302 // the given tracker, and then signals the given event the given number of 302 // the given tracker, and then signals the given event the given number of
303 // times. This is used to wake up blocked background threads before blocking 303 // times. This is used to wake up blocked background threads before blocking
304 // on shutdown. 304 // on shutdown.
305 void EnsureTasksToCompleteCountAndUnblock(scoped_refptr<TestTracker> tracker, 305 void EnsureTasksToCompleteCountAndUnblock(scoped_refptr<TestTracker> tracker,
306 size_t expected_tasks_to_complete, 306 size_t expected_tasks_to_complete,
307 ThreadBlocker* blocker, 307 ThreadBlocker* blocker,
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
1060 // Make sure all tasks are run before shutting down. Delayed tasks are 1060 // Make sure all tasks are run before shutting down. Delayed tasks are
1061 // not run, they're simply deleted. 1061 // not run, they're simply deleted.
1062 pool_owner_->pool()->FlushForTesting(); 1062 pool_owner_->pool()->FlushForTesting();
1063 pool_owner_->pool()->Shutdown(); 1063 pool_owner_->pool()->Shutdown();
1064 // Don't reset |pool_owner_| here, as the test may still hold a 1064 // Don't reset |pool_owner_| here, as the test may still hold a
1065 // reference to the pool. 1065 // reference to the pool.
1066 } 1066 }
1067 1067
1068 private: 1068 private:
1069 MessageLoop message_loop_; 1069 MessageLoop message_loop_;
1070 scoped_ptr<SequencedWorkerPoolOwner> pool_owner_; 1070 std::unique_ptr<SequencedWorkerPoolOwner> pool_owner_;
1071 }; 1071 };
1072 1072
1073 INSTANTIATE_TYPED_TEST_CASE_P( 1073 INSTANTIATE_TYPED_TEST_CASE_P(
1074 SequencedWorkerPool, TaskRunnerTest, 1074 SequencedWorkerPool, TaskRunnerTest,
1075 SequencedWorkerPoolTaskRunnerTestDelegate); 1075 SequencedWorkerPoolTaskRunnerTestDelegate);
1076 INSTANTIATE_TYPED_TEST_CASE_P(SequencedWorkerPool, TaskRunnerAffinityTest, 1076 INSTANTIATE_TYPED_TEST_CASE_P(SequencedWorkerPool, TaskRunnerAffinityTest,
1077 SequencedWorkerPoolTaskRunnerTestDelegate); 1077 SequencedWorkerPoolTaskRunnerTestDelegate);
1078 1078
1079 class SequencedWorkerPoolTaskRunnerWithShutdownBehaviorTestDelegate { 1079 class SequencedWorkerPoolTaskRunnerWithShutdownBehaviorTestDelegate {
1080 public: 1080 public:
(...skipping 17 matching lines...) Expand all
1098 // Make sure all tasks are run before shutting down. Delayed tasks are 1098 // Make sure all tasks are run before shutting down. Delayed tasks are
1099 // not run, they're simply deleted. 1099 // not run, they're simply deleted.
1100 pool_owner_->pool()->FlushForTesting(); 1100 pool_owner_->pool()->FlushForTesting();
1101 pool_owner_->pool()->Shutdown(); 1101 pool_owner_->pool()->Shutdown();
1102 // Don't reset |pool_owner_| here, as the test may still hold a 1102 // Don't reset |pool_owner_| here, as the test may still hold a
1103 // reference to the pool. 1103 // reference to the pool.
1104 } 1104 }
1105 1105
1106 private: 1106 private:
1107 MessageLoop message_loop_; 1107 MessageLoop message_loop_;
1108 scoped_ptr<SequencedWorkerPoolOwner> pool_owner_; 1108 std::unique_ptr<SequencedWorkerPoolOwner> pool_owner_;
1109 scoped_refptr<TaskRunner> task_runner_; 1109 scoped_refptr<TaskRunner> task_runner_;
1110 }; 1110 };
1111 1111
1112 INSTANTIATE_TYPED_TEST_CASE_P( 1112 INSTANTIATE_TYPED_TEST_CASE_P(
1113 SequencedWorkerPoolTaskRunner, TaskRunnerTest, 1113 SequencedWorkerPoolTaskRunner, TaskRunnerTest,
1114 SequencedWorkerPoolTaskRunnerWithShutdownBehaviorTestDelegate); 1114 SequencedWorkerPoolTaskRunnerWithShutdownBehaviorTestDelegate);
1115 INSTANTIATE_TYPED_TEST_CASE_P( 1115 INSTANTIATE_TYPED_TEST_CASE_P(
1116 SequencedWorkerPoolTaskRunner, TaskRunnerAffinityTest, 1116 SequencedWorkerPoolTaskRunner, TaskRunnerAffinityTest,
1117 SequencedWorkerPoolTaskRunnerWithShutdownBehaviorTestDelegate); 1117 SequencedWorkerPoolTaskRunnerWithShutdownBehaviorTestDelegate);
1118 1118
(...skipping 19 matching lines...) Expand all
1138 // Make sure all tasks are run before shutting down. Delayed tasks are 1138 // Make sure all tasks are run before shutting down. Delayed tasks are
1139 // not run, they're simply deleted. 1139 // not run, they're simply deleted.
1140 pool_owner_->pool()->FlushForTesting(); 1140 pool_owner_->pool()->FlushForTesting();
1141 pool_owner_->pool()->Shutdown(); 1141 pool_owner_->pool()->Shutdown();
1142 // Don't reset |pool_owner_| here, as the test may still hold a 1142 // Don't reset |pool_owner_| here, as the test may still hold a
1143 // reference to the pool. 1143 // reference to the pool.
1144 } 1144 }
1145 1145
1146 private: 1146 private:
1147 MessageLoop message_loop_; 1147 MessageLoop message_loop_;
1148 scoped_ptr<SequencedWorkerPoolOwner> pool_owner_; 1148 std::unique_ptr<SequencedWorkerPoolOwner> pool_owner_;
1149 scoped_refptr<SequencedTaskRunner> task_runner_; 1149 scoped_refptr<SequencedTaskRunner> task_runner_;
1150 }; 1150 };
1151 1151
1152 INSTANTIATE_TYPED_TEST_CASE_P( 1152 INSTANTIATE_TYPED_TEST_CASE_P(
1153 SequencedWorkerPoolSequencedTaskRunner, TaskRunnerTest, 1153 SequencedWorkerPoolSequencedTaskRunner, TaskRunnerTest,
1154 SequencedWorkerPoolSequencedTaskRunnerTestDelegate); 1154 SequencedWorkerPoolSequencedTaskRunnerTestDelegate);
1155 INSTANTIATE_TYPED_TEST_CASE_P( 1155 INSTANTIATE_TYPED_TEST_CASE_P(
1156 SequencedWorkerPoolSequencedTaskRunner, TaskRunnerAffinityTest, 1156 SequencedWorkerPoolSequencedTaskRunner, TaskRunnerAffinityTest,
1157 SequencedWorkerPoolSequencedTaskRunnerTestDelegate); 1157 SequencedWorkerPoolSequencedTaskRunnerTestDelegate);
1158 1158
1159 INSTANTIATE_TYPED_TEST_CASE_P( 1159 INSTANTIATE_TYPED_TEST_CASE_P(
1160 SequencedWorkerPoolSequencedTaskRunner, SequencedTaskRunnerTest, 1160 SequencedWorkerPoolSequencedTaskRunner, SequencedTaskRunnerTest,
1161 SequencedWorkerPoolSequencedTaskRunnerTestDelegate); 1161 SequencedWorkerPoolSequencedTaskRunnerTestDelegate);
1162 INSTANTIATE_TYPED_TEST_CASE_P( 1162 INSTANTIATE_TYPED_TEST_CASE_P(
1163 SequencedWorkerPoolSequencedTaskRunner, 1163 SequencedWorkerPoolSequencedTaskRunner,
1164 SequencedTaskRunnerDelayedTest, 1164 SequencedTaskRunnerDelayedTest,
1165 SequencedWorkerPoolSequencedTaskRunnerTestDelegate); 1165 SequencedWorkerPoolSequencedTaskRunnerTestDelegate);
1166 1166
1167 } // namespace 1167 } // namespace
1168 1168
1169 } // namespace base 1169 } // namespace base
OLDNEW
« no previous file with comments | « base/threading/sequenced_worker_pool.cc ('k') | base/threading/thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698