OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_scheduler/task_tracker.h" | 5 #include "base/task_scheduler/task_tracker.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 } | 381 } |
382 } | 382 } |
383 } | 383 } |
384 | 384 |
385 #if DCHECK_IS_ON() | 385 #if DCHECK_IS_ON() |
386 bool TaskTracker::IsPostingBlockShutdownTaskAfterShutdownAllowed() { | 386 bool TaskTracker::IsPostingBlockShutdownTaskAfterShutdownAllowed() { |
387 return false; | 387 return false; |
388 } | 388 } |
389 #endif | 389 #endif |
390 | 390 |
391 int TaskTracker::GetNumPendingUndelayedTasksForTesting() const { | |
392 return subtle::Acquire_Load(&num_pending_undelayed_tasks_); | |
393 } | |
394 | |
395 bool TaskTracker::BeforePostTask(TaskShutdownBehavior shutdown_behavior) { | 391 bool TaskTracker::BeforePostTask(TaskShutdownBehavior shutdown_behavior) { |
396 if (shutdown_behavior == TaskShutdownBehavior::BLOCK_SHUTDOWN) { | 392 if (shutdown_behavior == TaskShutdownBehavior::BLOCK_SHUTDOWN) { |
397 // BLOCK_SHUTDOWN tasks block shutdown between the moment they are posted | 393 // BLOCK_SHUTDOWN tasks block shutdown between the moment they are posted |
398 // and the moment they complete their execution. | 394 // and the moment they complete their execution. |
399 const bool shutdown_started = state_->IncrementNumTasksBlockingShutdown(); | 395 const bool shutdown_started = state_->IncrementNumTasksBlockingShutdown(); |
400 | 396 |
401 if (shutdown_started) { | 397 if (shutdown_started) { |
402 AutoSchedulerLock auto_lock(shutdown_lock_); | 398 AutoSchedulerLock auto_lock(shutdown_lock_); |
403 | 399 |
404 // A BLOCK_SHUTDOWN task posted after shutdown has completed is an | 400 // A BLOCK_SHUTDOWN task posted after shutdown has completed is an |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 task_latency_histograms_[static_cast<int>(task->traits.priority())] | 512 task_latency_histograms_[static_cast<int>(task->traits.priority())] |
517 [task->traits.may_block() || | 513 [task->traits.may_block() || |
518 task->traits.with_base_sync_primitives() | 514 task->traits.with_base_sync_primitives() |
519 ? 1 | 515 ? 1 |
520 : 0] | 516 : 0] |
521 ->Add(task_latency.InMicroseconds()); | 517 ->Add(task_latency.InMicroseconds()); |
522 } | 518 } |
523 | 519 |
524 } // namespace internal | 520 } // namespace internal |
525 } // namespace base | 521 } // namespace base |
OLD | NEW |