Commit 2b201320 authored by Etienne Pierre-Doray's avatar Etienne Pierre-Doray Committed by Commit Bot

[TaskScheduler]: Migrate off of AssertBlockingAllowedDeprecated in /printing/backend/cups_jobs.cc

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

Bug: 903957
Change-Id: Icd6f4bf53daa45bf540611ededc97b941f09da88
Reviewed-on: https://chromium-review.googlesource.com/c/1338407Reviewed-by: default avatarSean Kau <skau@chromium.org>
Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610064}
parent 21dfae8b
......@@ -14,7 +14,7 @@
#include "base/stl_util.h"
#include "base/strings/string_piece.h"
#include "base/strings/stringprintf.h"
#include "base/threading/thread_restrictions.h"
#include "base/threading/scoped_blocking_call.h"
#include "base/version.h"
#include "printing/backend/cups_deleters.h"
#include "printing/backend/cups_ipp_util.h"
......@@ -380,7 +380,6 @@ ScopedIppPtr GetPrinterAttributes(http_t* http,
int num_attributes,
const char* const* attributes,
ipp_status_t* status) {
base::AssertBlockingAllowedDeprecated();
DCHECK(http);
// CUPS expects a leading slash for resource names. Add one if it's missing.
......@@ -400,6 +399,7 @@ ScopedIppPtr GetPrinterAttributes(http_t* http,
DCHECK_EQ(ippValidateAttributes(request.get()), 1);
base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::WILL_BLOCK);
auto response = WrapIpp(cupsDoRequest(http, request.release(), rp.c_str()));
*status = ippGetStatusCode(response.get());
......@@ -434,7 +434,6 @@ bool GetPrinterInfo(const std::string& address,
const std::string& resource,
bool encrypted,
PrinterInfo* printer_info) {
base::AssertBlockingAllowedDeprecated();
ScopedHttpPtr http = ScopedHttpPtr(httpConnect2(
address.c_str(), port, nullptr, AF_INET,
......@@ -470,7 +469,6 @@ bool GetPrinterInfo(const std::string& address,
bool GetPrinterStatus(http_t* http,
const std::string& printer_id,
PrinterStatus* printer_status) {
base::AssertBlockingAllowedDeprecated();
ipp_status_t status;
const std::string printer_uri = PrinterUriFromName(printer_id);
......@@ -492,7 +490,6 @@ bool GetCupsJobs(http_t* http,
int limit,
JobCompletionState which,
std::vector<CupsJob>* jobs) {
base::AssertBlockingAllowedDeprecated();
DCHECK(http);
auto request = WrapIpp(ippNewRequest(IPP_OP_GET_JOBS));
......@@ -519,6 +516,7 @@ bool GetCupsJobs(http_t* http,
return false;
}
base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
// cupsDoRequest will delete the request.
auto response = WrapIpp(cupsDoRequest(http, request.release(), "/"));
......
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