Commit ef1da7a0 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 /base/win.

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

Bug: 874080
Change-Id: I0fa6e881ea4b00d0c31b3c8026e095950764a627
Reviewed-on: https://chromium-review.googlesource.com/1191101Reviewed-by: default avatarGreg Thompson <grt@chromium.org>
Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#587117}
parent e8fc42d5
......@@ -11,7 +11,7 @@
#include <wrl/client.h>
#include "base/files/file_util.h"
#include "base/threading/thread_restrictions.h"
#include "base/threading/scoped_blocking_call.h"
#include "base/win/scoped_propvariant.h"
#include "base/win/win_util.h"
#include "base/win/windows_version.h"
......@@ -57,7 +57,7 @@ ShortcutProperties::~ShortcutProperties() {
bool CreateOrUpdateShortcutLink(const FilePath& shortcut_path,
const ShortcutProperties& properties,
ShortcutOperation operation) {
AssertBlockingAllowed();
ScopedBlockingCall scoped_blocking_call(BlockingType::MAY_BLOCK);
// A target is required unless |operation| is SHORTCUT_UPDATE_EXISTING.
if (operation != SHORTCUT_UPDATE_EXISTING &&
......@@ -199,7 +199,7 @@ bool ResolveShortcutProperties(const FilePath& shortcut_path,
uint32_t options,
ShortcutProperties* properties) {
DCHECK(options && properties);
AssertBlockingAllowed();
ScopedBlockingCall scoped_blocking_call(BlockingType::MAY_BLOCK);
if (options & ~ShortcutProperties::PROPERTIES_ALL)
NOTREACHED() << "Unhandled property is used.";
......@@ -355,7 +355,7 @@ bool CanPinShortcutToTaskbar() {
}
bool PinShortcutToTaskbar(const FilePath& shortcut) {
AssertBlockingAllowed();
ScopedBlockingCall scoped_blocking_call(BlockingType::MAY_BLOCK);
DCHECK(CanPinShortcutToTaskbar());
intptr_t result = reinterpret_cast<intptr_t>(ShellExecute(
......@@ -364,7 +364,7 @@ bool PinShortcutToTaskbar(const FilePath& shortcut) {
}
bool UnpinShortcutFromTaskbar(const FilePath& shortcut) {
AssertBlockingAllowed();
ScopedBlockingCall scoped_blocking_call(BlockingType::MAY_BLOCK);
intptr_t result = reinterpret_cast<intptr_t>(ShellExecute(
NULL, L"taskbarunpin", shortcut.value().c_str(), NULL, NULL, 0));
......
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