Commit 1e53af3d authored by Etienne Pierre-Doray's avatar Etienne Pierre-Doray Committed by Commit Bot

[TaskScheduler]: Migrate off of AssertBlockingAllowedDeprecated in /storage/browser/blob

base::AssertBlockingAllowedDeprecated is deprecated in favor of
ScopedBlockingCall, which serves as a precise annotation of
the scope that may/will block.

Please 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: The call might block (e.g. file I/O that might hit in memory cache).
      WILL_BLOCK: The call will definitely block (e.g. cache already checked and now pinging
        server synchronously).
    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().
  - Calls to blocking //base APIs don't need to be annotated
    with ScopedBlockingCall. All blocking //base APIs (e.g. base::ReadFileToString, base::File::Read,
    base::SysInfo::AmountOfFreeDiskSpace, base::WaitableEvent::Wait, etc.) have their
    own internal annotations.

Refer to the top-level CL if necessary :
https://chromium-review.googlesource.com/c/chromium/src/+/1338391

Please CQ if LGTY!

This CL was uploaded by git cl split.

R=jianli@chromium.org

Bug: 903957
Change-Id: I05eabae1bc94d675e26a59ba61d862d536a8513d
Reviewed-on: https://chromium-review.googlesource.com/c/1338394Reviewed-by: default avatarJian Li <jianli@chromium.org>
Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612845}
parent ab98b58b
......@@ -28,7 +28,7 @@
#include "base/system/sys_info.h"
#include "base/task_runner.h"
#include "base/task_runner_util.h"
#include "base/threading/thread_restrictions.h"
#include "base/threading/scoped_blocking_call.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "storage/browser/blob/blob_data_builder.h"
......@@ -145,7 +145,7 @@ EmptyFilesResult CreateEmptyFiles(
DiskSpaceFuncPtr disk_space_function,
scoped_refptr<base::TaskRunner> file_task_runner,
std::vector<base::FilePath> file_paths) {
base::AssertBlockingAllowedDeprecated();
base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
File::Error dir_create_status = CreateBlobDirectory(blob_storage_dir);
if (dir_create_status != File::FILE_OK) {
......@@ -186,7 +186,7 @@ std::pair<FileCreationInfo, int64_t> CreateFileAndWriteItems(
size_t total_size_bytes) {
DCHECK_NE(0u, total_size_bytes);
UMA_HISTOGRAM_MEMORY_KB("Storage.Blob.PageFileSize", total_size_bytes / 1024);
base::AssertBlockingAllowedDeprecated();
base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
FileCreationInfo creation_info;
creation_info.file_deletion_runner = std::move(file_task_runner);
......
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