Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/task/cancelable_task_tracker.h" | 5 #include "base/task/cancelable_task_tracker.h" |
| 6 | 6 |
| 7 #include <cstddef> | 7 #include <cstddef> |
| 8 #include <deque> | 8 #include <deque> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 339 class CancelableTaskTrackerDeathTest : public CancelableTaskTrackerTest { | 339 class CancelableTaskTrackerDeathTest : public CancelableTaskTrackerTest { |
| 340 protected: | 340 protected: |
| 341 CancelableTaskTrackerDeathTest() { | 341 CancelableTaskTrackerDeathTest() { |
| 342 // The default style "fast" does not support multi-threaded tests. | 342 // The default style "fast" does not support multi-threaded tests. |
| 343 ::testing::FLAGS_gtest_death_test_style = "threadsafe"; | 343 ::testing::FLAGS_gtest_death_test_style = "threadsafe"; |
| 344 } | 344 } |
| 345 }; | 345 }; |
| 346 | 346 |
| 347 // Duplicated from base/threading/thread_checker.h so that we can be | 347 // Duplicated from base/threading/thread_checker.h so that we can be |
| 348 // good citizens there and undef the macro. | 348 // good citizens there and undef the macro. |
| 349 #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) | 349 #if DCHECK_IS_ON() |
| 350 #define ENABLE_THREAD_CHECKER 1 | 350 #define ENABLE_THREAD_CHECKER 1 |
|
danakj
2016/07/19 20:17:01
Do we need this separate #define, or just use DCHE
gab
2016/07/20 02:43:58
Done.
| |
| 351 #else | 351 #else |
| 352 #define ENABLE_THREAD_CHECKER 0 | 352 #define ENABLE_THREAD_CHECKER 0 |
| 353 #endif | 353 #endif |
| 354 | 354 |
| 355 // Runs |fn| with |task_tracker|, expecting it to crash in debug mode. | 355 // Runs |fn| with |task_tracker|, expecting it to crash in debug mode. |
| 356 void MaybeRunDeadlyTaskTrackerMemberFunction( | 356 void MaybeRunDeadlyTaskTrackerMemberFunction( |
| 357 CancelableTaskTracker* task_tracker, | 357 CancelableTaskTracker* task_tracker, |
| 358 const Callback<void(CancelableTaskTracker*)>& fn) { | 358 const Callback<void(CancelableTaskTracker*)>& fn) { |
| 359 // CancelableTask uses DCHECKs with its ThreadChecker (itself only | 359 // CancelableTask uses DCHECKs with its ThreadChecker (itself only |
| 360 // enabled in debug mode). | 360 // enabled in debug mode). |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 415 | 415 |
| 416 bad_thread.task_runner()->PostTask( | 416 bad_thread.task_runner()->PostTask( |
| 417 FROM_HERE, | 417 FROM_HERE, |
| 418 Bind(&MaybeRunDeadlyTaskTrackerMemberFunction, Unretained(&task_tracker_), | 418 Bind(&MaybeRunDeadlyTaskTrackerMemberFunction, Unretained(&task_tracker_), |
| 419 Bind(&CancelableTaskTracker::TryCancelAll))); | 419 Bind(&CancelableTaskTracker::TryCancelAll))); |
| 420 | 420 |
| 421 test_task_runner->RunUntilIdle(); | 421 test_task_runner->RunUntilIdle(); |
| 422 } | 422 } |
| 423 | 423 |
| 424 } // namespace base | 424 } // namespace base |
| OLD | NEW |