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

[TaskScheduler]: Use ScopedBlockingCall to mark blocking tasks in /components/metrics.

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.

Bug: 874080
Change-Id: Ifa1cba993d25114f81984771e50d4734ef66a954
Reviewed-on: https://chromium-review.googlesource.com/c/1191325Reviewed-by: default avatarAlexei Svitkine <asvitkine@chromium.org>
Commit-Queue: Alexei Svitkine <asvitkine@chromium.org>
Cr-Commit-Position: refs/heads/master@{#599210}
parent 44dba1cd
......@@ -21,8 +21,9 @@
#include "base/metrics/histogram_functions.h"
#include "base/metrics/sparse_histogram.h"
#include "base/numerics/safe_conversions.h"
#include "base/optional.h"
#include "base/sys_info.h"
#include "base/threading/thread_restrictions.h"
#include "base/threading/scoped_blocking_call.h"
#include "build/build_config.h"
namespace {
......@@ -1068,7 +1069,7 @@ bool FilePersistentMemoryAllocator::IsFileAcceptable(
void FilePersistentMemoryAllocator::Cache() {
// Since this method is expected to load data from permanent storage
// into memory, blocking I/O may occur.
AssertBlockingAllowed();
base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
// Calculate begin/end addresses so that the first byte of every page
// in that range can be read. Keep within the used space. The |volatile|
......@@ -1092,14 +1093,16 @@ void FilePersistentMemoryAllocator::Cache() {
}
void FilePersistentMemoryAllocator::FlushPartial(size_t length, bool sync) {
if (sync)
AssertBlockingAllowed();
if (IsReadonly())
return;
base::Optional<base::ScopedBlockingCall> scoped_blocking_call;
if (sync)
scoped_blocking_call.emplace(base::BlockingType::MAY_BLOCK);
#if defined(OS_WIN)
// Windows doesn't support asynchronous flush.
AssertBlockingAllowed();
scoped_blocking_call.emplace(base::BlockingType::MAY_BLOCK);
BOOL success = ::FlushViewOfFile(data(), length);
DPCHECK(success);
#elif defined(OS_MACOSX)
......
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