0

[TaskScheduler]: Deprecate AssertBlockingAllowed.

Usage of AssertBlockingAllowed outside of base:: is being replaced by
ScopedBlockingCall.

This CL puts AssertBlockingAllowed() into base::internal and
adds AssertBlockingAllowedDeprecated for compatibility with current usage.
This is a purely mechanical change with no side-effects.

TBR=fdoray@chromium.org

Bug: 874080
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:ios-simulator-cronet;luci.chromium.try:ios-simulator-full-configs;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: I2b482a5ca217a563052dcae4afc45553626aa3d3
Reviewed-on: https://chromium-review.googlesource.com/c/1278540
Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
Reviewed-by: Etienne Pierre-Doray <etiennep@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Reviewed-by: François Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#600793}
This commit is contained in:
Etienne Pierre-doray
2018-10-18 16:36:42 +00:00
committed by Commit Bot
parent 8fc0be7641
commit a4195e59f5
48 changed files with 109 additions and 105 deletions
android_webview/browser
base
chrome
components/download/quarantine
content
ios/chrome/browser/sessions
media
net
printing
services/device
sql
storage/browser
third_party/leveldatabase
ui
base
events
ozone
platform

@ -342,7 +342,7 @@ namespace {
std::unique_ptr<AwWebResourceResponse> RunShouldInterceptRequest(
const AwWebResourceRequest& request,
JavaObjectWeakGlobalRef ref) {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
JNIEnv* env = AttachCurrentThread();
base::android::ScopedJavaLocalRef<jobject> obj = ref.get(env);

@ -18,7 +18,7 @@ namespace {
// Gets the version number to use for variations seed simulation. Must be called
// on a thread where IO is allowed.
base::Version GetVersionForSimulation() {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
return version_info::GetVersion();
}

@ -34,9 +34,9 @@
#include "base/test/test_simple_task_runner.h"
#include "base/test/test_timeouts.h"
#include "base/threading/platform_thread.h"
#include "base/threading/scoped_blocking_call.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "base/threading/simple_thread.h"
#include "base/threading/thread_restrictions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@ -486,7 +486,8 @@ TEST_P(TaskSchedulerTaskTrackerTest, IOAllowed) {
ThreadRestrictions::SetIOAllowed(false);
Task task_with_may_block(FROM_HERE, Bind([]() {
// Shouldn't fail.
AssertBlockingAllowed();
ScopedBlockingCall scope_blocking_call(
BlockingType::WILL_BLOCK);
}),
TimeDelta());
TaskTraits traits_with_may_block = TaskTraits(MayBlock(), GetParam());
@ -499,8 +500,11 @@ TEST_P(TaskSchedulerTaskTrackerTest, IOAllowed) {
// task without the MayBlock() trait.
ThreadRestrictions::SetIOAllowed(true);
Task task_without_may_block(
FROM_HERE,
Bind([]() { EXPECT_DCHECK_DEATH({ AssertBlockingAllowed(); }); }),
FROM_HERE, Bind([]() {
EXPECT_DCHECK_DEATH({
ScopedBlockingCall scope_blocking_call(BlockingType::WILL_BLOCK);
});
}),
TimeDelta());
TaskTraits traits_without_may_block = TaskTraits(GetParam());
EXPECT_TRUE(tracker_.WillPostTask(

@ -243,7 +243,7 @@ void PlatformThread::Join(PlatformThreadHandle thread_handle) {
// Joining another thread may block the current thread for a long time, since
// the thread referred to by |thread_handle| may still be running long-lived /
// blocking tasks.
// AssertBlockingAllowed();
// AssertBlockingAllowedDeprecated();
DWORD thread_id = 0;
thread_id = ::GetThreadId(thread_handle.platform_handle());

@ -57,7 +57,7 @@ UncheckedScopedBlockingCall::~UncheckedScopedBlockingCall() {
ScopedBlockingCall::ScopedBlockingCall(BlockingType blocking_type)
: UncheckedScopedBlockingCall(blocking_type) {
base::AssertBlockingAllowed();
internal::AssertBlockingAllowed();
}
namespace internal {

@ -28,6 +28,8 @@ LazyInstance<ThreadLocalBoolean>::Leaky g_cpu_intensive_work_disallowed =
} // namespace
namespace internal {
void AssertBlockingAllowed() {
DCHECK(!g_blocking_disallowed.Get().Get())
<< "Function marked as blocking was called from a scope that disallows "
@ -37,6 +39,12 @@ void AssertBlockingAllowed() {
"ScopedAllowBlocking (see its documentation for best practices).";
}
} // namespace internal
void AssertBlockingAllowedDeprecated() {
internal::AssertBlockingAllowed();
}
void DisallowBlocking() {
g_blocking_disallowed.Get().Set(true);
}

@ -163,38 +163,32 @@ class ThreadTestHelper;
{}
#endif
// TODO(etiennep): Add a meta-comment which collapses all of the comments below.
// A "blocking call" refers to any call that causes the calling thread to wait
// off-CPU. It includes but is not limited to calls that wait on synchronous
// file I/O operations: read or write a file from disk, interact with a pipe or
// a socket, rename or delete a file, enumerate files in a directory, etc.
// Acquiring a low contention lock is not considered a blocking call.
// Asserts that blocking calls are allowed in the current scope. Prefer using
// ScopedBlockingCall instead, which also serves as a precise annotation of the
// scope that may/will block.
//
// Style tip: It's best if you put AssertBlockingAllowed() checks as close to
// the blocking call as possible. For example:
//
// void ReadFile() {
// PreWork();
//
// base::AssertBlockingAllowed();
// fopen(...);
//
// PostWork();
// }
//
// void Bar() {
// ReadFile();
// }
//
// void Foo() {
// Bar();
// }
namespace internal {
// Asserts that blocking calls are allowed in the current scope. This is an
// internal call, external code should use ScopedBlockingCall instead, which
// serves as a precise annotation of the scope that may/will block.
INLINE_IF_DCHECK_IS_OFF void AssertBlockingAllowed()
EMPTY_BODY_IF_DCHECK_IS_OFF;
} // namespace internal
// Asserts that blocking calls are allowed in the current scope.
//
// DEPRECATED: Use ScopedBlockingCall, which serves as a precise annotation of
// the scope that may/will block.
// TODO(etiennep): Complete migration and delete this method.
INLINE_IF_DCHECK_IS_OFF void AssertBlockingAllowedDeprecated()
EMPTY_BODY_IF_DCHECK_IS_OFF;
// Disallows blocking on the current thread.
INLINE_IF_DCHECK_IS_OFF void DisallowBlocking() EMPTY_BODY_IF_DCHECK_IS_OFF;

@ -30,33 +30,33 @@ class ThreadRestrictionsTest : public testing::Test {
} // namespace
TEST_F(ThreadRestrictionsTest, BlockingAllowedByDefault) {
AssertBlockingAllowed();
internal::AssertBlockingAllowed();
}
TEST_F(ThreadRestrictionsTest, ScopedDisallowBlocking) {
{
ScopedDisallowBlocking scoped_disallow_blocking;
EXPECT_DCHECK_DEATH({ AssertBlockingAllowed(); });
EXPECT_DCHECK_DEATH({ internal::AssertBlockingAllowed(); });
}
AssertBlockingAllowed();
internal::AssertBlockingAllowed();
}
TEST_F(ThreadRestrictionsTest, ScopedAllowBlocking) {
ScopedDisallowBlocking scoped_disallow_blocking;
{
ScopedAllowBlocking scoped_allow_blocking;
AssertBlockingAllowed();
internal::AssertBlockingAllowed();
}
EXPECT_DCHECK_DEATH({ AssertBlockingAllowed(); });
EXPECT_DCHECK_DEATH({ internal::AssertBlockingAllowed(); });
}
TEST_F(ThreadRestrictionsTest, ScopedAllowBlockingForTesting) {
ScopedDisallowBlocking scoped_disallow_blocking;
{
ScopedAllowBlockingForTesting scoped_allow_blocking_for_testing;
AssertBlockingAllowed();
internal::AssertBlockingAllowed();
}
EXPECT_DCHECK_DEATH({ AssertBlockingAllowed(); });
EXPECT_DCHECK_DEATH({ internal::AssertBlockingAllowed(); });
}
TEST_F(ThreadRestrictionsTest, BaseSyncPrimitivesAllowedByDefault) {}
@ -140,7 +140,7 @@ TEST_F(ThreadRestrictionsTest, LongCPUWorkAllowedByDefault) {
TEST_F(ThreadRestrictionsTest, DisallowUnresponsiveTasks) {
DisallowUnresponsiveTasks();
EXPECT_DCHECK_DEATH(AssertBlockingAllowed());
EXPECT_DCHECK_DEATH(internal::AssertBlockingAllowed());
EXPECT_DCHECK_DEATH(internal::AssertBaseSyncPrimitivesAllowed());
EXPECT_DCHECK_DEATH(AssertLongCPUWorkAllowed());
}

@ -276,7 +276,7 @@ bool StoreUpdateRequestToFileInBackground(
const std::map<std::string, std::string>& icon_url_to_murmur2_hash,
bool is_manifest_stale,
WebApkUpdateReason update_reason) {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
std::unique_ptr<std::string> proto = BuildProtoInBackground(
shortcut_info, primary_icon, badge_icon, package_name, version,
@ -293,7 +293,7 @@ bool StoreUpdateRequestToFileInBackground(
// Reads |file| and returns contents. Must be called on a background thread.
std::unique_ptr<std::string> ReadFileInBackground(const base::FilePath& file) {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
std::unique_ptr<std::string> update_request = std::make_unique<std::string>();
base::ReadFileToString(file, update_request.get());
return update_request;

@ -179,7 +179,7 @@ void RecordLastRunAppBundlePath() {
// real, user-visible app bundle directory. (The alternatives give either the
// framework's path or the initial app's path, which may be an app mode shim
// or a unit test.)
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
base::FilePath app_bundle_path =
chrome::GetVersionedDirectory().DirName().DirName().DirName();

@ -48,7 +48,7 @@ const char* const kNetDeviceNamePrefixes[] = {
typedef std::map<base::FilePath, base::FilePath> DiskEntries;
std::string GetDiskUuid() {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
DiskEntries disk_uuids;
base::FileEnumerator files(base::FilePath(kDiskByUuidDirectoryName),
@ -149,7 +149,7 @@ class MacAddressProcessor {
std::string GetMacAddress(
const IsValidMacAddressCallback& is_valid_mac_address) {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
struct ifaddrs* ifaddrs;
int rv = getifaddrs(&ifaddrs);
@ -171,7 +171,7 @@ std::string GetMacAddress(
void GetRawDeviceIdImpl(const IsValidMacAddressCallback& is_valid_mac_address,
const DeviceId::IdCallback& callback) {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
std::string disk_id = GetDiskUuid();
std::string mac_address = GetMacAddress(is_valid_mac_address);

@ -102,7 +102,7 @@ std::string GetVolumeUUIDFromBSDName(const std::string& bsd_name) {
// Return Volume UUID property of disk mounted as "/".
std::string GetVolumeUUID() {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
std::string result;
std::string bsd_name = FindBSDNameOfSystemDisk();
@ -163,7 +163,7 @@ class MacAddressProcessor {
std::string GetMacAddress(
const IsValidMacAddressCallback& is_valid_mac_address) {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
mach_port_t master_port;
kern_return_t kr = IOMasterPort(MACH_PORT_NULL, &master_port);
@ -213,7 +213,7 @@ std::string GetMacAddress(
void GetRawDeviceIdImpl(const IsValidMacAddressCallback& is_valid_mac_address,
const DeviceId::IdCallback& callback) {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
std::string raw_device_id;
std::string mac_address = GetMacAddress(is_valid_mac_address);

@ -89,7 +89,7 @@ class MacAddressProcessor {
std::string GetMacAddressFromGetAdaptersAddresses(
const IsValidMacAddressCallback& is_valid_mac_address) {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
// MS recommends a default size of 15k.
ULONG bufferSize = 15 * 1024;
@ -124,7 +124,7 @@ std::string GetMacAddressFromGetAdaptersAddresses(
std::string GetMacAddressFromGetIfTable2(
const IsValidMacAddressCallback& is_valid_mac_address) {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
// This is available on Vista+ only.
base::ScopedNativeLibrary library(base::FilePath(L"Iphlpapi.dll"));
@ -162,7 +162,7 @@ std::string GetMacAddressFromGetIfTable2(
void GetMacAddress(const IsValidMacAddressCallback& is_valid_mac_address,
const DeviceId::IdCallback& callback) {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
std::string mac_address =
GetMacAddressFromGetAdaptersAddresses(is_valid_mac_address);

@ -358,8 +358,6 @@ class ProcessDataCollectorTest : public testing::Test {
// Represents the root of the simulated procfs.
base::ScopedTempDir proc_dir_;
// Makes sure that the |base::AssertBlockingAllowed| calls from
// |ProcessDataCollector| work.
base::test::ScopedTaskEnvironment scoped_task_environment_;
// The current time step, used in testing functions.

@ -43,7 +43,7 @@ constexpr base::FilePath::CharType kExternalExtensionJson[] =
std::set<base::FilePath> GetPrefsCandidateFilesFromFolder(
const base::FilePath& external_extension_search_path) {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
std::set<base::FilePath> external_extension_paths;
@ -235,7 +235,7 @@ ExternalPrefLoader::ExtractExtensionPrefs(base::ValueDeserializer* deserializer,
}
void ExternalPrefLoader::LoadOnFileThread() {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
auto prefs = std::make_unique<base::DictionaryValue>();
@ -273,7 +273,7 @@ void ExternalPrefLoader::LoadOnFileThread() {
void ExternalPrefLoader::ReadExternalExtensionPrefFile(
base::DictionaryValue* prefs) {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
CHECK(NULL != prefs);
base::FilePath json_file = base_path_.Append(kExternalExtensionJson);
@ -311,7 +311,7 @@ void ExternalPrefLoader::ReadExternalExtensionPrefFile(
void ExternalPrefLoader::ReadStandaloneExtensionPrefFiles(
base::DictionaryValue* prefs) {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
CHECK(NULL != prefs);
// First list the potential .json candidates.

@ -79,7 +79,7 @@ void ExternalRegistryLoader::StartLoading() {
std::unique_ptr<base::DictionaryValue>
ExternalRegistryLoader::LoadPrefsOnBlockingThread() {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
auto prefs = std::make_unique<base::DictionaryValue>();
// A map of IDs, to weed out duplicates between HKCU and HKLM.

@ -241,7 +241,7 @@ int UnpackedInstaller::GetFlags() {
bool UnpackedInstaller::LoadExtension(Manifest::Location location,
int flags,
std::string* error) {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
// Clean up the kMetadataFolder if necessary. This prevents spurious
// warnings/errors and ensures we don't treat a user provided file as one by
@ -267,7 +267,7 @@ bool UnpackedInstaller::LoadExtension(Manifest::Location location,
bool UnpackedInstaller::IndexAndPersistRulesIfNeeded(std::string* error) {
DCHECK(extension());
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
const ExtensionResource* resource =
declarative_net_request::DNRManifestData::GetRulesetResource(extension());
@ -301,7 +301,7 @@ bool UnpackedInstaller::IsLoadingUnpackedAllowed() const {
}
void UnpackedInstaller::GetAbsolutePath() {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
extension_path_ = base::MakeAbsoluteFilePath(extension_path_);
@ -326,7 +326,7 @@ void UnpackedInstaller::CheckExtensionFileAccess() {
}
void UnpackedInstaller::LoadWithFileAccess(int flags) {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
std::string error;
if (!LoadExtension(Manifest::UNPACKED, flags, &error)) {

@ -113,7 +113,7 @@ base::FilePath* g_download_directory_for_tests = NULL;
base::FilePath GetDownloadFilePath(const base::FilePath& download_directory,
const std::string& id) {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
// Ensure the download directory exists. TODO(asargent) - make this use
// common code from the downloads system.
if (!base::DirectoryExists(download_directory) &&

@ -41,7 +41,7 @@ std::unique_ptr<AppLaunchPredictor> CreatePredictor(
// Save |proto| to |predictor_filename|.
void SaveToDiskOnWorkerThread(const base::FilePath& predictor_filename,
const AppLaunchPredictorProto& proto) {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
std::string proto_str;
if (!proto.SerializeToString(&proto_str))
@ -55,7 +55,7 @@ void SaveToDiskOnWorkerThread(const base::FilePath& predictor_filename,
std::unique_ptr<AppLaunchPredictor> LoadPredictorFromDiskOnWorkerThread(
const base::FilePath& predictor_filename,
const std::string predictor_name) {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
// Loads proto string from local disk.
std::string proto_str;

@ -349,7 +349,7 @@ void ResolveLanguageListInThreadPool(
language_switch_result,
const scoped_refptr<base::TaskRunner> task_runner,
const UILanguageListResolvedCallback& resolved_callback) {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
std::string selected_language;
if (!language_switch_result) {

@ -701,7 +701,7 @@ void ReportInstalledExtensions(JsonParserAPI* json_parser) {
// mode. This isn't catastrophic since the cleanup tool doesn't have a UI and
// the system report is collected at the end of the process. We also assert
// blocking is allowed here since it will block the thread.
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
base::ScopedAllowBaseSyncPrimitivesForTesting allow_sync;
ReportForcelistExtensions();

@ -21,7 +21,7 @@ namespace download {
namespace {
std::string GetExtendedFileAttribute(const char* path, const char* name) {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
ssize_t len = getxattr(path, name, nullptr, 0);
if (len <= 0)
return std::string();

@ -20,7 +20,7 @@ namespace download {
bool IsFileQuarantined(const base::FilePath& file,
const GURL& expected_source_url,
const GURL& referrer_url) {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
if (!base::PathExists(file))
return false;

@ -90,7 +90,7 @@ class FileTraceDataEndpoint : public TracingController::TraceDataEndpoint {
}
bool OpenFileIfNeededOnBlockingThread() {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
if (file_ != nullptr)
return true;
file_ = base::OpenFile(file_path_, "w");

@ -27,7 +27,7 @@ namespace {
std::unique_ptr<FontLoader::ResultInternal> LoadFontOnFileThread(
const base::string16& font_name,
const float font_point_size) {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
NSString* font_name_ns = base::SysUTF16ToNSString(font_name);
NSFont* font_to_encode =

@ -169,7 +169,7 @@ NSString* const kRootObjectKey = @"root"; // Key for the root object.
NSString* sessionPath = [[self class] sessionPathForDirectory:directory];
_taskRunner->PostTaskAndReply(
FROM_HERE, base::BindOnce(^{
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
NSFileManager* fileManager = [NSFileManager defaultManager];
if (![fileManager fileExistsAtPath:sessionPath])
return;
@ -220,7 +220,7 @@ NSString* const kRootObjectKey = @"root"; // Key for the root object.
- (void)performSaveSessionData:(NSData*)sessionData
sessionPath:(NSString*)sessionPath {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
NSFileManager* fileManager = [NSFileManager defaultManager];
NSString* directory = [sessionPath stringByDeletingLastPathComponent];

@ -252,7 +252,7 @@ void AudioDebugFileWriter::AudioFileWriter::WriteHeader() {
void AudioDebugFileWriter::AudioFileWriter::StartRecording(base::File file) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(!file_.IsValid());
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
file_ = std::move(file);
WriteHeader();

@ -29,7 +29,7 @@ base::FilePath GetFilePathFromCommandLine() {
std::unique_ptr<VideoCaptureDevice> FileVideoCaptureDeviceFactory::CreateDevice(
const VideoCaptureDeviceDescriptor& device_descriptor) {
DCHECK(thread_checker_.CalledOnValidThread());
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
#if defined(OS_WIN)
return std::unique_ptr<VideoCaptureDevice>(new FileVideoCaptureDevice(
base::FilePath(base::SysUTF8ToWide(device_descriptor.display_name()))));
@ -67,7 +67,7 @@ void FileVideoCaptureDeviceFactory::GetSupportedFormats(
const VideoCaptureDeviceDescriptor& device_descriptor,
VideoCaptureFormats* supported_formats) {
DCHECK(thread_checker_.CalledOnValidThread());
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
VideoCaptureFormat capture_format;
if (!FileVideoCaptureDevice::GetVideoCaptureFormat(

@ -297,7 +297,7 @@ void AddressTrackerLinux::ReadMessages(bool* address_changed,
if (tracking_) {
// If the loop below takes a long time to run, a new thread should added
// to the current thread pool to ensure forward progress of all tasks.
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
blocking_call.emplace(base::BlockingType::MAY_BLOCK);
}

@ -214,7 +214,7 @@ bool GetNetworkList(NetworkInterfaceList* networks, int policy) {
return false;
// getifaddrs() may require IO operations.
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
ifaddrs* interfaces;
if (getifaddrs(&interfaces) < 0) {

@ -214,7 +214,7 @@ bool GetNetworkList(NetworkInterfaceList* networks, int policy) {
std::unique_ptr<char[]> buf;
// GetAdaptersAddresses() may require IO operations.
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
IP_ADAPTER_ADDRESSES* adapters =
reinterpret_cast<IP_ADAPTER_ADDRESSES*>(&initial_buf);

@ -122,7 +122,7 @@ class RegistryReader {
// Wrapper for GetAdaptersAddresses. Returns NULL if failed.
std::unique_ptr<IP_ADAPTER_ADDRESSES, base::FreeDeleter> ReadIpHelper(
ULONG flags) {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
std::unique_ptr<IP_ADAPTER_ADDRESSES, base::FreeDeleter> out;
ULONG len = 15000; // As recommended by MSDN for GetAdaptersAddresses.

@ -380,7 +380,7 @@ ScopedIppPtr GetPrinterAttributes(http_t* http,
int num_attributes,
const char* const* attributes,
ipp_status_t* status) {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
DCHECK(http);
// CUPS expects a leading slash for resource names. Add one if it's missing.
@ -434,7 +434,7 @@ bool GetPrinterInfo(const std::string& address,
const std::string& resource,
bool encrypted,
PrinterInfo* printer_info) {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
ScopedHttpPtr http = ScopedHttpPtr(httpConnect2(
address.c_str(), port, nullptr, AF_INET,
@ -470,7 +470,7 @@ bool GetPrinterInfo(const std::string& address,
bool GetPrinterStatus(http_t* http,
const std::string& printer_id,
PrinterStatus* printer_status) {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
ipp_status_t status;
const std::string printer_uri = PrinterUriFromName(printer_id);
@ -492,7 +492,7 @@ bool GetCupsJobs(http_t* http,
int limit,
JobCompletionState which,
std::vector<CupsJob>* jobs) {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
DCHECK(http);
auto request = WrapIpp(ippNewRequest(IPP_OP_GET_JOBS));

@ -47,7 +47,7 @@ base::LazyInstance<base::FilePath>::Leaky g_debug_dump_info =
#if defined(OS_WIN)
void DebugDumpPageTask(const base::string16& doc_name,
const PrintedPage* page) {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
DCHECK(PrintedDocument::HasDebugDumpPath());
@ -64,7 +64,7 @@ void DebugDumpPageTask(const base::string16& doc_name,
#else
void DebugDumpTask(const base::string16& doc_name,
const MetafilePlayer* metafile) {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
DCHECK(PrintedDocument::HasDebugDumpPath());
@ -82,7 +82,7 @@ void DebugDumpTask(const base::string16& doc_name,
void DebugDumpDataTask(const base::string16& doc_name,
const base::FilePath::StringType& extension,
const base::RefCountedMemory* data) {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
base::FilePath path =
PrintedDocument::CreateDebugDumpPath(doc_name, extension);

@ -33,7 +33,7 @@ SensorDeviceManager::~SensorDeviceManager() {
void SensorDeviceManager::Start(Delegate* delegate) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
DCHECK(!delegate_);
delegate_ = delegate;

@ -131,7 +131,7 @@ std::unique_ptr<SensorReader> SensorReader::Create(
const SensorInfoLinux* sensor_device,
base::WeakPtr<PlatformSensorLinux> sensor,
scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
// TODO(maksims): implement triggered reading. At the moment,
// only polling read is supported.
return std::make_unique<PollingSensorReader>(sensor_device, sensor,

@ -52,7 +52,7 @@ class HidConnectionLinux::BlockingTaskHelper {
// Must be called on a thread that has a base::MessageLoopForIO.
void Start() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
file_watcher_ = base::FileDescriptorWatcher::WatchReadable(
fd_.get(), base::Bind(&BlockingTaskHelper::OnFileCanReadWithoutBlocking,

@ -80,7 +80,7 @@ class HidServiceLinux::BlockingTaskHelper : public UdevWatcher::Observer {
}
void Start() {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
watcher_ = UdevWatcher::StartWatching(this);
@ -266,7 +266,7 @@ void HidServiceLinux::OnPathOpenError(const std::string& device_path,
// static
void HidServiceLinux::OpenOnBlockingThread(
std::unique_ptr<ConnectParams> params) {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
scoped_refptr<base::SequencedTaskRunner> task_runner = params->task_runner;
base::FilePath device_path(params->device_info->device_node());
@ -299,7 +299,7 @@ void HidServiceLinux::OpenOnBlockingThread(
// static
void HidServiceLinux::FinishOpen(std::unique_ptr<ConnectParams> params) {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
scoped_refptr<base::SequencedTaskRunner> task_runner = params->task_runner;
if (!base::SetNonBlocking(params->fd.get())) {

@ -101,7 +101,7 @@ class InputServiceLinuxImpl : public InputServiceLinux,
};
InputServiceLinuxImpl::InputServiceLinuxImpl() : observer_(this) {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
DeviceMonitorLinux* monitor = DeviceMonitorLinux::GetInstance();
observer_.Add(monitor);

@ -88,7 +88,7 @@ class TimeZoneMonitorLinuxImpl
~TimeZoneMonitorLinuxImpl() { DCHECK(!owner_); }
void StartWatchingOnFileThread() {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
DCHECK(file_task_runner_->RunsTasksInCurrentSequence());
// There is no true standard for where time zone information is actually

@ -1139,7 +1139,7 @@ void Database::Poison() {
//
// static
bool Database::Delete(const base::FilePath& path) {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
base::FilePath journal_path = Database::JournalPath(path);
base::FilePath wal_path = Database::WriteAheadLogPath(path);

@ -551,7 +551,7 @@ class SQL_EXPORT Database {
// official build.
void AssertIOAllowed() const {
if (!in_memory_)
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
}
// Internal helper for Does*Exist() functions.

@ -145,7 +145,7 @@ EmptyFilesResult CreateEmptyFiles(
DiskSpaceFuncPtr disk_space_function,
scoped_refptr<base::TaskRunner> file_task_runner,
std::vector<base::FilePath> file_paths) {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
File::Error dir_create_status = CreateBlobDirectory(blob_storage_dir);
if (dir_create_status != File::FILE_OK) {
@ -186,7 +186,7 @@ std::pair<FileCreationInfo, int64_t> CreateFileAndWriteItems(
size_t total_size_bytes) {
DCHECK_NE(0u, total_size_bytes);
UMA_HISTOGRAM_MEMORY_KB("Storage.Blob.PageFileSize", total_size_bytes / 1024);
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
FileCreationInfo creation_info;
creation_info.file_deletion_runner = std::move(file_task_runner);

@ -26,7 +26,7 @@ int64_t RandomizeByPercent(int64_t value, int percent) {
base::Optional<storage::QuotaSettings> CalculateNominalDynamicSettings(
const base::FilePath& partition_path,
bool is_incognito) {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
const int64_t kMBytes = 1024 * 1024;
const int kRandomizedPercentage = 10;

@ -73,7 +73,7 @@ static const char kDatabaseNameSuffixForRebuildDB[] = "__tmp_for_rebuild";
static base::File::Error GetDirectoryEntries(const FilePath& dir_param,
std::vector<FilePath>* result) {
TRACE_EVENT0("leveldb", "ChromiumEnv::GetDirectoryEntries");
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
result->clear();
#if defined(OS_WIN)
FilePath dir_filepath = dir_param.Append(FILE_PATH_LITERAL("*"));

@ -42,7 +42,7 @@ bool InvokeShellExecute(const base::string16 path,
const base::string16 args,
const base::string16 verb,
DWORD mask) {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
SHELLEXECUTEINFO sei = {sizeof(sei)};
sei.fMask = mask;
sei.nShow = SW_SHOWNORMAL;

@ -19,7 +19,7 @@ base::FilePath GetInputPathInSys(const base::FilePath& path) {
}
InputDeviceType GetInputDeviceTypeFromPath(const base::FilePath& path) {
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
std::string event_node = path.BaseName().value();
if (event_node.empty() ||
!base::StartsWith(event_node, "event",

@ -39,7 +39,7 @@ DrmDeviceHandle::DrmDeviceHandle() {
DrmDeviceHandle::~DrmDeviceHandle() {
if (file_.is_valid())
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
}
bool DrmDeviceHandle::Initialize(const base::FilePath& dev_path,
@ -48,7 +48,7 @@ bool DrmDeviceHandle::Initialize(const base::FilePath& dev_path,
// expected path, so use a CHECK instead of a DCHECK. The sys_path is only
// used a label and is otherwise unvalidated.
CHECK(dev_path.DirName() == base::FilePath("/dev/dri"));
base::AssertBlockingAllowed();
base::AssertBlockingAllowedDeprecated();
int num_auth_attempts = 0;
bool logged_warning = false;