Commit b774142b 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 /chromeos/printing.

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=thestig@chromium.org

Bug: 874080
Change-Id: Ic3048f1874bd6d575a061c5f9f773df4850d6d32
Reviewed-on: https://chromium-review.googlesource.com/1191099Reviewed-by: default avatarSean Kau <skau@chromium.org>
Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#587670}
parent 20848114
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
#include "base/synchronization/lock.h" #include "base/synchronization/lock.h"
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "base/task_runner_util.h" #include "base/task_runner_util.h"
#include "base/threading/scoped_blocking_call.h"
#include "base/threading/sequenced_task_runner_handle.h" #include "base/threading/sequenced_task_runner_handle.h"
#include "base/threading/thread_restrictions.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "base/values.h" #include "base/values.h"
#include "chromeos/printing/printing_constants.h" #include "chromeos/printing/printing_constants.h"
...@@ -47,7 +47,7 @@ void MaybeCreateCache(const base::FilePath& base_dir) { ...@@ -47,7 +47,7 @@ void MaybeCreateCache(const base::FilePath& base_dir) {
// allows I/O. // allows I/O.
PpdCache::FindResult FindImpl(const base::FilePath& cache_dir, PpdCache::FindResult FindImpl(const base::FilePath& cache_dir,
const std::string& key) { const std::string& key) {
base::AssertBlockingAllowed(); base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
PpdCache::FindResult result; PpdCache::FindResult result;
result.success = false; result.success = false;
...@@ -93,7 +93,7 @@ void StoreImpl(const base::FilePath& cache_dir, ...@@ -93,7 +93,7 @@ void StoreImpl(const base::FilePath& cache_dir,
const std::string& key, const std::string& key,
const std::string& contents, const std::string& contents,
base::TimeDelta age) { base::TimeDelta age) {
base::AssertBlockingAllowed(); base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
MaybeCreateCache(cache_dir); MaybeCreateCache(cache_dir);
if (contents.size() > kMaxPpdSizeBytes) { if (contents.size() > kMaxPpdSizeBytes) {
LOG(ERROR) << "Ignoring attempt to cache large object"; LOG(ERROR) << "Ignoring attempt to cache large object";
......
...@@ -27,8 +27,8 @@ ...@@ -27,8 +27,8 @@
#include "base/synchronization/lock.h" #include "base/synchronization/lock.h"
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "base/task_runner_util.h" #include "base/task_runner_util.h"
#include "base/threading/scoped_blocking_call.h"
#include "base/threading/sequenced_task_runner_handle.h" #include "base/threading/sequenced_task_runner_handle.h"
#include "base/threading/thread_restrictions.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "base/values.h" #include "base/values.h"
#include "chromeos/printing/ppd_cache.h" #include "chromeos/printing/ppd_cache.h"
...@@ -251,7 +251,7 @@ bool PpdReferenceIsWellFormed(const Printer::PpdReference& reference) { ...@@ -251,7 +251,7 @@ bool PpdReferenceIsWellFormed(const Printer::PpdReference& reference) {
bool FetchFile(const GURL& url, std::string* file_contents) { bool FetchFile(const GURL& url, std::string* file_contents) {
CHECK(url.is_valid()); CHECK(url.is_valid());
CHECK(url.SchemeIs("file")); CHECK(url.SchemeIs("file"));
base::AssertBlockingAllowed(); base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
// Here we are un-escaping the file path represented by the url. If we don't // Here we are un-escaping the file path represented by the url. If we don't
// transform the url into a valid file path then the file may fail to be // transform the url into a valid file path then the file may fail to be
......
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