Commit 8e2eef3e 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 /chrome/browser/ui/webui/print_preview.

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

Bug: 874080
Change-Id: Ib9f4215acff0afbbcdac414bf4d5617c09c81078
Reviewed-on: https://chromium-review.googlesource.com/1190931Reviewed-by: default avatarWei Li <weili@chromium.org>
Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#586700}
parent 3d4cd0cf
......@@ -10,7 +10,7 @@
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/task/post_task.h"
#include "base/threading/thread_restrictions.h"
#include "base/threading/scoped_blocking_call.h"
#include "chrome/browser/ui/webui/print_preview/print_preview_utils.h"
#include "components/printing/common/printer_capabilities.h"
#include "content/public/browser/browser_thread.h"
......@@ -19,7 +19,7 @@
namespace {
printing::PrinterList EnumeratePrintersAsync() {
base::AssertBlockingAllowed();
base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
scoped_refptr<printing::PrintBackend> print_backend(
printing::PrintBackend::CreateInstance(nullptr));
......@@ -30,7 +30,7 @@ printing::PrinterList EnumeratePrintersAsync() {
std::unique_ptr<base::DictionaryValue> FetchCapabilitiesAsync(
const std::string& device_name) {
base::AssertBlockingAllowed();
base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
scoped_refptr<printing::PrintBackend> print_backend(
printing::PrintBackend::CreateInstance(nullptr));
......@@ -51,7 +51,7 @@ std::unique_ptr<base::DictionaryValue> FetchCapabilitiesAsync(
}
std::string GetDefaultPrinterAsync() {
base::AssertBlockingAllowed();
base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
scoped_refptr<printing::PrintBackend> print_backend(
printing::PrintBackend::CreateInstance(nullptr));
......
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