Commit 0fbce43c 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.

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: I2984ff747f7cce7b40f48251c4bdaa21d0b0df93
Reviewed-on: https://chromium-review.googlesource.com/1191582Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#586396}
parent 233a3244
......@@ -18,8 +18,8 @@
#include "base/path_service.h"
#include "base/strings/string_number_conversions.h"
#include "base/task/post_task.h"
#include "base/threading/scoped_blocking_call.h"
#include "base/threading/thread.h"
#include "base/threading/thread_restrictions.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "chrome/browser/about_flags.h"
......@@ -286,7 +286,7 @@ void ShutdownPostThreadsStop(int shutdown_flags) {
void ReadLastShutdownFile(ShutdownType type,
int num_procs,
int num_procs_slow) {
base::AssertBlockingAllowed();
base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
base::FilePath shutdown_ms_file = GetShutdownMsPath();
std::string shutdown_ms_str;
......
......@@ -19,7 +19,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_restrictions.h"
#include "base/threading/scoped_blocking_call.h"
#include "build/build_config.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/grit/chromium_strings.h"
......@@ -112,7 +112,7 @@ ProcessData* MemoryDetails::ChromeBrowser() {
void MemoryDetails::CollectProcessData(
const std::vector<ProcessMemoryInformation>& child_info) {
base::AssertBlockingAllowed();
base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
ProcessMap process_map = GetProcesses();
std::set<pid_t> browsers_found;
......
......@@ -17,8 +17,8 @@
#include "base/process/process_iterator.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/scoped_blocking_call.h"
#include "base/threading/thread.h"
#include "base/threading/thread_restrictions.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/chromium_strings.h"
......@@ -80,7 +80,7 @@ ProcessData* MemoryDetails::ChromeBrowser() {
void MemoryDetails::CollectProcessData(
const std::vector<ProcessMemoryInformation>& child_info) {
base::AssertBlockingAllowed();
base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
// Clear old data.
process_data_[0].processes.clear();
......
......@@ -19,7 +19,7 @@
#include "base/path_service.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_restrictions.h"
#include "base/threading/scoped_blocking_call.h"
#include "base/win/scoped_handle.h"
#include "base/win/windows_version.h"
#include "chrome/common/url_constants.h"
......@@ -47,7 +47,7 @@ ProcessData* MemoryDetails::ChromeBrowser() {
void MemoryDetails::CollectProcessData(
const std::vector<ProcessMemoryInformation>& child_info) {
base::AssertBlockingAllowed();
base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
// Clear old data.
process_data_[0].processes.clear();
......
......@@ -21,7 +21,7 @@
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/post_task.h"
#include "base/threading/thread_restrictions.h"
#include "base/threading/scoped_blocking_call.h"
#include "base/win/registry.h"
#include "base/win/scoped_co_mem.h"
#include "chrome/browser/platform_util_internal.h"
......@@ -37,7 +37,7 @@ namespace platform_util {
namespace {
void ShowItemInFolderOnWorkerThread(const base::FilePath& full_path) {
base::AssertBlockingAllowed();
base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
base::FilePath dir = full_path.DirName().AsEndingWithSeparator();
// ParseDisplayName will fail if the directory is "C:", it must be "C:\\".
if (dir.empty())
......@@ -80,7 +80,7 @@ void ShowItemInFolderOnWorkerThread(const base::FilePath& full_path) {
}
void OpenExternalOnWorkerThread(const GURL& url) {
base::AssertBlockingAllowed();
base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
// Quote the input scheme to be sure that the command does not have
// parameters unexpected by the external program. This url should already
// have been escaped.
......
......@@ -16,7 +16,7 @@
#include "base/task/post_task.h"
#include "base/task/single_thread_task_runner_thread_mode.h"
#include "base/task/task_traits.h"
#include "base/threading/thread_restrictions.h"
#include "base/threading/scoped_blocking_call.h"
#include "build/build_config.h"
#include "chrome/browser/policy/policy_path_parser.h"
#include "chrome/common/chrome_paths.h"
......@@ -89,7 +89,7 @@ base::CommandLine CommandLineArgsForLauncher(
const GURL& url,
const std::string& extension_app_id,
const base::FilePath& profile_path) {
base::AssertBlockingAllowed();
base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
base::CommandLine new_cmd_line(base::CommandLine::NO_PROGRAM);
AppendProfileArgs(
......@@ -187,7 +187,7 @@ void DefaultWebClientWorker::OnCheckIsDefaultComplete(
// DefaultWebClientWorker, private:
void DefaultWebClientWorker::CheckIsDefault(bool is_following_set_as_default) {
base::AssertBlockingAllowed();
base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
DefaultWebClientState state = CheckIsDefaultImpl();
BrowserThread::PostTask(
......@@ -197,7 +197,7 @@ void DefaultWebClientWorker::CheckIsDefault(bool is_following_set_as_default) {
}
void DefaultWebClientWorker::SetAsDefault() {
base::AssertBlockingAllowed();
base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
// SetAsDefaultImpl will make sure the callback is executed exactly once.
SetAsDefaultImpl(
......
......@@ -21,7 +21,7 @@
#include "base/path_service.h"
#include "base/strings/string_util.h"
#include "base/strings/sys_string_conversions.h"
#include "base/threading/thread_restrictions.h"
#include "base/threading/scoped_blocking_call.h"
#include "base/version.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
......@@ -62,7 +62,7 @@ NSString* GetServiceProcessLaunchDSocketKey() {
bool RemoveFromLaunchd() {
// We're killing a file.
base::AssertBlockingAllowed();
base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
base::ScopedCFTypeRef<CFStringRef> name(CopyServiceProcessLaunchDName());
return Launchd::GetInstance()->DeletePlist(Launchd::User,
Launchd::Agent,
......@@ -274,7 +274,7 @@ CFDictionaryRef CreateServiceProcessLaunchdPlist(base::CommandLine* cmd_line,
// auto launched on the next user login.
bool ServiceProcessState::AddToAutoRun() {
// We're creating directories and writing a file.
base::AssertBlockingAllowed();
base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
DCHECK(autorun_command_line_.get());
base::ScopedCFTypeRef<CFStringRef> name(CopyServiceProcessLaunchDName());
base::ScopedCFTypeRef<CFDictionaryRef> plist(
......
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