Commit b5034e04 authored by Etienne Pierre-doray's avatar Etienne Pierre-doray Committed by Commit Bot

[TaskScheduler]: Use ScopedBlockingCall to mark blocking tasks.

This CL uses ScopedBlockingCall to mark blocking calls in /components/metrics.

This CL was created by replacing calls to AssertBlockingAllowed()
with instantiations of ScopedBlockingCall(MAY_BLOCK).
I kindly ask the reviewer to make sure of the following:
  - ScopedBlockingCall is instantiated in a scope with minimal CPU usage.
    If this is not the case, ScopedBlockingCall should be instantiated
    closer to the blocking call. See scoped_blocking_call.h for more
    info. Please let me know when/where the blocking call happens if this needs
    to be changed.
  - Parameter |blocking_type| matches expectation (MAY_BLOCK/WILL_BLOCK). See
    BlockingType for more info. While I assumed MAY_BLOCK by default, that might
    not be the best fit if we know that this callsite is guaranteed to block.
  - The ScopedBlockingCall's scope covers the entirety of the blocking operation
    previously asserted against by the AssertBlockingAllowed().

This CL was uploaded by git cl split.

R=bcwhite@chromium.org

Bug: 874080
Change-Id: I6ac58796b199be52c55b5a14d41ca836dc4faa61
Reviewed-on: https://chromium-review.googlesource.com/1191323Reviewed-by: default avatarBrian White <bcwhite@chromium.org>
Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#586443}
parent ba675a60
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include "base/path_service.h" #include "base/path_service.h"
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "base/task/task_traits.h" #include "base/task/task_traits.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/scoped_blocking_call.h"
#include "base/time/time.h" #include "base/time/time.h"
namespace metrics { namespace metrics {
...@@ -50,7 +50,7 @@ DriveMetricsProvider::SeekPenaltyResponse::SeekPenaltyResponse() ...@@ -50,7 +50,7 @@ DriveMetricsProvider::SeekPenaltyResponse::SeekPenaltyResponse()
DriveMetricsProvider::DriveMetrics DriveMetricsProvider::DriveMetrics
DriveMetricsProvider::GetDriveMetricsOnBackgroundThread( DriveMetricsProvider::GetDriveMetricsOnBackgroundThread(
int local_state_path_key) { int local_state_path_key) {
base::AssertBlockingAllowed(); base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::WILL_BLOCK);
DriveMetricsProvider::DriveMetrics metrics; DriveMetricsProvider::DriveMetrics metrics;
QuerySeekPenalty(base::FILE_EXE, &metrics.app_drive); QuerySeekPenalty(base::FILE_EXE, &metrics.app_drive);
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include "base/base_paths.h" #include "base/base_paths.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/scoped_blocking_call.h"
#include "base/win/scoped_handle.h" #include "base/win/scoped_handle.h"
namespace metrics { namespace metrics {
...@@ -25,7 +25,7 @@ bool MachineIdProvider::HasId() { ...@@ -25,7 +25,7 @@ bool MachineIdProvider::HasId() {
// is running from. // is running from.
// static // static
std::string MachineIdProvider::GetMachineId() { std::string MachineIdProvider::GetMachineId() {
base::AssertBlockingAllowed(); base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
// Use the program's path to get the drive used for the machine id. This means // Use the program's path to get the drive used for the machine id. This means
// that whenever the underlying drive changes, it's considered a new machine. // that whenever the underlying drive changes, it's considered a new machine.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment