Commit d331fba0 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/web_applications/components/web_app_shortcut_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=rsesek@chromium.org

Bug: 874080
Change-Id: Iffe2955c934c9a81ffddefd2d42cfb277aec0ddb
Reviewed-on: https://chromium-review.googlesource.com/1191665Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#586719}
parent 0b261f4c
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.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 "base/version.h" #include "base/version.h"
#import "chrome/browser/mac/dock.h" #import "chrome/browser/mac/dock.h"
#include "chrome/browser/shell_integration.h" #include "chrome/browser/shell_integration.h"
...@@ -180,7 +180,7 @@ bool HasSameUserDataDir(const base::FilePath& bundle_path) { ...@@ -180,7 +180,7 @@ bool HasSameUserDataDir(const base::FilePath& bundle_path) {
void LaunchShimOnFileThread(bool launched_after_rebuild, void LaunchShimOnFileThread(bool launched_after_rebuild,
const web_app::ShortcutInfo& shortcut_info) { const web_app::ShortcutInfo& shortcut_info) {
base::AssertBlockingAllowed(); base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
base::FilePath shim_path = web_app::GetAppInstallPath(shortcut_info); base::FilePath shim_path = web_app::GetAppInstallPath(shortcut_info);
if (shim_path.empty() || !base::PathExists(shim_path) || if (shim_path.empty() || !base::PathExists(shim_path) ||
...@@ -215,7 +215,7 @@ void UpdatePlatformShortcutsInternal( ...@@ -215,7 +215,7 @@ void UpdatePlatformShortcutsInternal(
const base::FilePath& app_data_path, const base::FilePath& app_data_path,
const base::string16& old_app_title, const base::string16& old_app_title,
const web_app::ShortcutInfo& shortcut_info) { const web_app::ShortcutInfo& shortcut_info) {
base::AssertBlockingAllowed(); base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
if (AppShimsDisabledForTest() && if (AppShimsDisabledForTest() &&
!g_app_shims_allow_update_and_launch_in_tests) { !g_app_shims_allow_update_and_launch_in_tests) {
return; return;
...@@ -228,7 +228,7 @@ void UpdatePlatformShortcutsInternal( ...@@ -228,7 +228,7 @@ void UpdatePlatformShortcutsInternal(
void UpdateAndLaunchShimOnFileThread( void UpdateAndLaunchShimOnFileThread(
const web_app::ShortcutInfo& shortcut_info) { const web_app::ShortcutInfo& shortcut_info) {
base::AssertBlockingAllowed(); base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
base::FilePath shortcut_data_dir = web_app::GetWebAppDataDirectory( base::FilePath shortcut_data_dir = web_app::GetWebAppDataDirectory(
shortcut_info.profile_path, shortcut_info.extension_id, GURL()); shortcut_info.profile_path, shortcut_info.extension_id, GURL());
UpdatePlatformShortcutsInternal(shortcut_data_dir, base::string16(), UpdatePlatformShortcutsInternal(shortcut_data_dir, base::string16(),
...@@ -339,7 +339,7 @@ void GetImageResourcesOnUIThread( ...@@ -339,7 +339,7 @@ void GetImageResourcesOnUIThread(
void SetWorkspaceIconOnWorkerThread(const base::FilePath& apps_directory, void SetWorkspaceIconOnWorkerThread(const base::FilePath& apps_directory,
std::unique_ptr<ResourceIDToImage> images) { std::unique_ptr<ResourceIDToImage> images) {
base::AssertBlockingAllowed(); base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
base::scoped_nsobject<NSImage> folder_icon_image([[NSImage alloc] init]); base::scoped_nsobject<NSImage> folder_icon_image([[NSImage alloc] init]);
// Use complete assets for the small icon sizes. -[NSWorkspace setIcon:] has a // Use complete assets for the small icon sizes. -[NSWorkspace setIcon:] has a
...@@ -941,7 +941,7 @@ bool CreatePlatformShortcuts(const base::FilePath& app_data_path, ...@@ -941,7 +941,7 @@ bool CreatePlatformShortcuts(const base::FilePath& app_data_path,
const ShortcutLocations& creation_locations, const ShortcutLocations& creation_locations,
ShortcutCreationReason creation_reason, ShortcutCreationReason creation_reason,
const ShortcutInfo& shortcut_info) { const ShortcutInfo& shortcut_info) {
base::AssertBlockingAllowed(); base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
if (AppShimsDisabledForTest()) if (AppShimsDisabledForTest())
return true; return true;
...@@ -951,7 +951,7 @@ bool CreatePlatformShortcuts(const base::FilePath& app_data_path, ...@@ -951,7 +951,7 @@ bool CreatePlatformShortcuts(const base::FilePath& app_data_path,
void DeletePlatformShortcuts(const base::FilePath& app_data_path, void DeletePlatformShortcuts(const base::FilePath& app_data_path,
const ShortcutInfo& shortcut_info) { const ShortcutInfo& shortcut_info) {
base::AssertBlockingAllowed(); base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
WebAppShortcutCreator shortcut_creator(app_data_path, &shortcut_info); WebAppShortcutCreator shortcut_creator(app_data_path, &shortcut_info);
shortcut_creator.DeleteShortcuts(); shortcut_creator.DeleteShortcuts();
} }
...@@ -963,7 +963,7 @@ void UpdatePlatformShortcuts(const base::FilePath& app_data_path, ...@@ -963,7 +963,7 @@ void UpdatePlatformShortcuts(const base::FilePath& app_data_path,
} }
void DeleteAllShortcutsForProfile(const base::FilePath& profile_path) { void DeleteAllShortcutsForProfile(const base::FilePath& profile_path) {
base::AssertBlockingAllowed(); base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
const std::string profile_base_name = profile_path.BaseName().value(); const std::string profile_base_name = profile_path.BaseName().value();
std::vector<base::FilePath> bundles = GetAllAppBundlesInPath( std::vector<base::FilePath> bundles = GetAllAppBundlesInPath(
profile_path.Append(chrome::kWebAppDirname), profile_base_name); profile_path.Append(chrome::kWebAppDirname), profile_base_name);
......
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