[TaskScheduler]: Use ScopedBlockingCall to mark blocking tasks.
This CL uses ScopedBlockingCall to mark blocking calls in /chrome/browser/shell_integration_linux.cc.
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.
[email protected]
Bug: 874080
Change-Id: I64920670d2ccb62299815969d324003f462d8ecd
Reviewed-on: https://chromium-review.googlesource.com/1191801
Reviewed-by: Thomas Anderson <[email protected]>
Commit-Queue: Etienne Pierre-Doray <[email protected]>
Cr-Commit-Position: refs/heads/master@{#586720}
diff --git a/chrome/browser/shell_integration_linux.cc b/chrome/browser/shell_integration_linux.cc
index c5a8c3e..d7bc172 100644
--- a/chrome/browser/shell_integration_linux.cc
+++ b/chrome/browser/shell_integration_linux.cc
@@ -38,6 +38,7 @@
#include "base/strings/string_tokenizer.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 "build/build_config.h"
@@ -139,7 +140,7 @@
#if defined(OS_CHROMEOS)
return shell_integration::UNKNOWN_DEFAULT;
#else
- base::AssertBlockingAllowed();
+ base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
std::unique_ptr<base::Environment> env(base::Environment::Create());
@@ -297,7 +298,7 @@
}
std::vector<base::FilePath> GetDataSearchLocations(base::Environment* env) {
- base::AssertBlockingAllowed();
+ base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
std::vector<base::FilePath> search_paths;
base::FilePath write_location = GetDataWriteLocation(env);
@@ -447,7 +448,7 @@
bool GetExistingShortcutContents(base::Environment* env,
const base::FilePath& desktop_filename,
std::string* output) {
- base::AssertBlockingAllowed();
+ base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
std::vector<base::FilePath> search_paths = GetDataSearchLocations(env);
@@ -491,7 +492,7 @@
std::vector<base::FilePath> GetExistingProfileShortcutFilenames(
const base::FilePath& profile_path,
const base::FilePath& directory) {
- base::AssertBlockingAllowed();
+ base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
// Use a prefix, because xdg-desktop-menu requires it.
std::string prefix(chrome::kBrowserProcessExecutableName);
@@ -657,7 +658,7 @@
bool CreateAppListDesktopShortcut(
const std::string& wm_class,
const std::string& title) {
- base::AssertBlockingAllowed();
+ base::ScopedBlockingCall scoped_blocking_call(base::BlockingType::MAY_BLOCK);
base::FilePath desktop_name(kAppListDesktopName);
base::FilePath shortcut_filename = desktop_name.AddExtension("desktop");