Commit 9d234f0b 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/background/background_mode_manager_mac.mm.

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

Bug: 874080
Change-Id: Ic807c6eb4e22dc7ebdd34e2240e1fe6484e44174
Reviewed-on: https://chromium-review.googlesource.com/1191232Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#593676}
parent f477d272
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include "base/mac/mac_util.h" #include "base/mac/mac_util.h"
#include "base/sequenced_task_runner.h" #include "base/sequenced_task_runner.h"
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/scoped_blocking_call.h"
#include "chrome/browser/background/background_mode_manager.h" #include "chrome/browser/background/background_mode_manager.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
...@@ -32,7 +32,7 @@ void SetCreatedLoginItemPrefOnUIThread() { ...@@ -32,7 +32,7 @@ void SetCreatedLoginItemPrefOnUIThread() {
} }
void DisableLaunchOnStartupOnWorkerThread() { void DisableLaunchOnStartupOnWorkerThread() {
base::AssertBlockingAllowed(); base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
// If the LoginItem is not hidden, it means it's user created, so don't // If the LoginItem is not hidden, it means it's user created, so don't
// delete it. // delete it.
bool is_hidden = false; bool is_hidden = false;
...@@ -41,7 +41,7 @@ void DisableLaunchOnStartupOnWorkerThread() { ...@@ -41,7 +41,7 @@ void DisableLaunchOnStartupOnWorkerThread() {
} }
void CheckForUserRemovedLoginItemOnWorkerThread() { void CheckForUserRemovedLoginItemOnWorkerThread() {
base::AssertBlockingAllowed(); base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
if (!base::mac::CheckLoginItemStatus(NULL)) { if (!base::mac::CheckLoginItemStatus(NULL)) {
// There's no LoginItem, so set the kUserRemovedLoginItem pref. // There's no LoginItem, so set the kUserRemovedLoginItem pref.
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI}, base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
...@@ -50,7 +50,7 @@ void CheckForUserRemovedLoginItemOnWorkerThread() { ...@@ -50,7 +50,7 @@ void CheckForUserRemovedLoginItemOnWorkerThread() {
} }
void EnableLaunchOnStartupOnWorkerThread(bool need_migration) { void EnableLaunchOnStartupOnWorkerThread(bool need_migration) {
base::AssertBlockingAllowed(); base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
if (need_migration) { if (need_migration) {
// This is the first time running Chrome since the kChromeCreatedLoginItem // This is the first time running Chrome since the kChromeCreatedLoginItem
// pref was added. Initialize the status of this pref based on whether // pref was added. Initialize the status of this pref based on whether
......
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