| 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 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 // and the moment they complete their execution. | 398 // and the moment they complete their execution. |
| 399 const bool shutdown_started = state_->IncrementNumTasksBlockingShutdown(); | 399 const bool shutdown_started = state_->IncrementNumTasksBlockingShutdown(); |
| 400 | 400 |
| 401 if (shutdown_started) { | 401 if (shutdown_started) { |
| 402 AutoSchedulerLock auto_lock(shutdown_lock_); | 402 AutoSchedulerLock auto_lock(shutdown_lock_); |
| 403 | 403 |
| 404 // A BLOCK_SHUTDOWN task posted after shutdown has completed is an | 404 // A BLOCK_SHUTDOWN task posted after shutdown has completed is an |
| 405 // ordering bug. This aims to catch those early. | 405 // ordering bug. This aims to catch those early. |
| 406 DCHECK(shutdown_event_); | 406 DCHECK(shutdown_event_); |
| 407 if (shutdown_event_->IsSignaled()) { | 407 if (shutdown_event_->IsSignaled()) { |
| 408 #if DCHECK_IS_ON() |
| 409 // clang-format off |
| 408 // TODO(robliao): http://crbug.com/698140. Since the service thread | 410 // TODO(robliao): http://crbug.com/698140. Since the service thread |
| 409 // doesn't stop processing its own tasks at shutdown, we may still | 411 // doesn't stop processing its own tasks at shutdown, we may still |
| 410 // attempt to post a BLOCK_SHUTDOWN task in response to a | 412 // attempt to post a BLOCK_SHUTDOWN task in response to a |
| 411 // FileDescriptorWatcher. | 413 // FileDescriptorWatcher. Same is true for FilePathWatcher |
| 412 #if DCHECK_IS_ON() | 414 // (http://crbug.com/728235). Until it's possible for such services to |
| 413 DCHECK(IsPostingBlockShutdownTaskAfterShutdownAllowed()); | 415 // post to non-BLOCK_SHUTDOWN sequences which are themselves funneled to |
| 416 // the main execution sequence (a future plan for the post_task.h API), |
| 417 // this DCHECK will be flaky and must be disabled. |
| 418 // DCHECK(IsPostingBlockShutdownTaskAfterShutdownAllowed()); |
| 419 // clang-format on |
| 414 #endif | 420 #endif |
| 415 state_->DecrementNumTasksBlockingShutdown(); | 421 state_->DecrementNumTasksBlockingShutdown(); |
| 416 return false; | 422 return false; |
| 417 } | 423 } |
| 418 | 424 |
| 419 ++num_block_shutdown_tasks_posted_during_shutdown_; | 425 ++num_block_shutdown_tasks_posted_during_shutdown_; |
| 420 | 426 |
| 421 if (num_block_shutdown_tasks_posted_during_shutdown_ == | 427 if (num_block_shutdown_tasks_posted_during_shutdown_ == |
| 422 kMaxBlockShutdownTasksPostedDuringShutdown) { | 428 kMaxBlockShutdownTasksPostedDuringShutdown) { |
| 423 // Record the TaskScheduler.BlockShutdownTasksPostedDuringShutdown | 429 // Record the TaskScheduler.BlockShutdownTasksPostedDuringShutdown |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 task_latency_histograms_[static_cast<int>(task->traits.priority())] | 522 task_latency_histograms_[static_cast<int>(task->traits.priority())] |
| 517 [task->traits.may_block() || | 523 [task->traits.may_block() || |
| 518 task->traits.with_base_sync_primitives() | 524 task->traits.with_base_sync_primitives() |
| 519 ? 1 | 525 ? 1 |
| 520 : 0] | 526 : 0] |
| 521 ->Add(task_latency.InMicroseconds()); | 527 ->Add(task_latency.InMicroseconds()); |
| 522 } | 528 } |
| 523 | 529 |
| 524 } // namespace internal | 530 } // namespace internal |
| 525 } // namespace base | 531 } // namespace base |
| OLD | NEW |