Commit 563d6a00 authored by Etienne Pierre-Doray's avatar Etienne Pierre-Doray Committed by Commit Bot

[TaskScheduler]: Migrate off of AssertBlockingAllowedDeprecated in...

[TaskScheduler]: Migrate off of AssertBlockingAllowedDeprecated in /services/device/time_zone_monitor

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

Bug: 903957
Change-Id: I2be2db1919ad6f58b47a8e66e47fa7a138684d87
Reviewed-on: https://chromium-review.googlesource.com/c/1338490
Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
Reviewed-by: default avatarMark Mentovai <mark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609362}
parent 39a7ff94
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/sequenced_task_runner.h" #include "base/sequenced_task_runner.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/scoped_blocking_call.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h" #include "build/build_config.h"
...@@ -88,9 +88,15 @@ class TimeZoneMonitorLinuxImpl ...@@ -88,9 +88,15 @@ class TimeZoneMonitorLinuxImpl
~TimeZoneMonitorLinuxImpl() { DCHECK(!owner_); } ~TimeZoneMonitorLinuxImpl() { DCHECK(!owner_); }
void StartWatchingOnFileThread() { void StartWatchingOnFileThread() {
base::AssertBlockingAllowedDeprecated();
DCHECK(file_task_runner_->RunsTasksInCurrentSequence()); DCHECK(file_task_runner_->RunsTasksInCurrentSequence());
auto callback =
base::BindRepeating(&TimeZoneMonitorLinuxImpl::OnTimeZoneFileChanged,
base::RetainedRef(this));
base::ScopedBlockingCall scoped_blocking_call(
base::BlockingType::MAY_BLOCK);
// There is no true standard for where time zone information is actually // There is no true standard for where time zone information is actually
// stored. glibc uses /etc/localtime, uClibc uses /etc/TZ, and some older // stored. glibc uses /etc/localtime, uClibc uses /etc/TZ, and some older
// systems store the name of the time zone file within /usr/share/zoneinfo // systems store the name of the time zone file within /usr/share/zoneinfo
...@@ -101,10 +107,6 @@ class TimeZoneMonitorLinuxImpl ...@@ -101,10 +107,6 @@ class TimeZoneMonitorLinuxImpl
const char* const kFilesToWatch[] = { const char* const kFilesToWatch[] = {
"/etc/localtime", "/etc/timezone", "/etc/TZ", "/etc/localtime", "/etc/timezone", "/etc/TZ",
}; };
auto callback =
base::BindRepeating(&TimeZoneMonitorLinuxImpl::OnTimeZoneFileChanged,
base::RetainedRef(this));
for (size_t index = 0; index < arraysize(kFilesToWatch); ++index) { for (size_t index = 0; index < arraysize(kFilesToWatch); ++index) {
file_path_watchers_.push_back(std::make_unique<base::FilePathWatcher>()); file_path_watchers_.push_back(std::make_unique<base::FilePathWatcher>());
file_path_watchers_.back()->Watch(base::FilePath(kFilesToWatch[index]), file_path_watchers_.back()->Watch(base::FilePath(kFilesToWatch[index]),
......
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