Commit 3d58bbd0 authored by Etienne Bergeron's avatar Etienne Bergeron Committed by Commit Bot

Add Location annotation ScopedBlockingCall

This CL is adding the FROM_HERE location of the call sites to each
ScopedBlockingCall. This modification will provide the
detailed location to the trace events and allow developpers do
understand cause of janks of long tasks.

This CL is adding manually the cases not caught by the previous CL:
  https://chromium-review.googlesource.com/c/chromium/src/+/1483834


TBR=gab@chromium.org

Bug: 934302
Change-Id: Id2b959ef007fd7fec6d5b7cf8373f93e816c8195
Reviewed-on: https://chromium-review.googlesource.com/c/1491896Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Commit-Queue: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#636086}
parent 5a253e2d
......@@ -497,6 +497,7 @@ bool ReadFromFD(int fd, char* buffer, size_t bytes) {
int CreateAndOpenFdForTemporaryFileInDir(const FilePath& directory,
FilePath* path) {
ScopedBlockingCall scoped_blocking_call(
FROM_HERE,
BlockingType::MAY_BLOCK); // For call to mkstemp().
*path = directory.Append(TempFileName());
const std::string& tmpdir_string = path->value();
......@@ -633,7 +634,7 @@ FilePath GetHomeDir() {
bool CreateTemporaryFile(FilePath* path) {
ScopedBlockingCall scoped_blocking_call(
BlockingType::MAY_BLOCK); // For call to close().
FROM_HERE, BlockingType::MAY_BLOCK); // For call to close().
FilePath directory;
if (!GetTempDir(&directory))
return false;
......@@ -657,7 +658,7 @@ FILE* CreateAndOpenTemporaryFileInDir(const FilePath& dir, FilePath* path) {
bool CreateTemporaryFileInDir(const FilePath& dir, FilePath* temp_file) {
ScopedBlockingCall scoped_blocking_call(
BlockingType::MAY_BLOCK); // For call to close().
FROM_HERE, BlockingType::MAY_BLOCK); // For call to close().
int fd = CreateAndOpenFdForTemporaryFileInDir(dir, temp_file);
return ((fd >= 0) && !IGNORE_EINTR(close(fd)));
}
......@@ -666,7 +667,7 @@ static bool CreateTemporaryDirInDirImpl(const FilePath& base_dir,
const FilePath::StringType& name_tmpl,
FilePath* new_dir) {
ScopedBlockingCall scoped_blocking_call(
BlockingType::MAY_BLOCK); // For call to mkdtemp().
FROM_HERE, BlockingType::MAY_BLOCK); // For call to mkdtemp().
DCHECK(name_tmpl.find("XXXXXX") != FilePath::StringType::npos)
<< "Directory name template must contain \"XXXXXX\".";
......@@ -704,7 +705,7 @@ bool CreateNewTempDirectory(const FilePath::StringType& prefix,
bool CreateDirectoryAndGetError(const FilePath& full_path,
File::Error* error) {
ScopedBlockingCall scoped_blocking_call(
BlockingType::MAY_BLOCK); // For call to mkdir().
FROM_HERE, BlockingType::MAY_BLOCK); // For call to mkdir().
std::vector<FilePath> subpaths;
// Collect a list of all parent directories.
......
......@@ -94,7 +94,7 @@ class Restrictions {
std::unique_ptr<PrinterView> SetData(std::unique_ptr<std::string> data) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
base::ScopedBlockingCall scoped_blocking_call(
base::BlockingType::MAY_BLOCK);
FROM_HERE, base::BlockingType::MAY_BLOCK);
printers_cache_ = ParsePrinters(std::move(data));
return ComputePrinters();
}
......
......@@ -53,7 +53,7 @@ void SaveToDiskOnWorkerThread(const base::FilePath& predictor_filename,
bool write_result;
{
base::ScopedBlockingCall scoped_blocking_call(
base::BlockingType::MAY_BLOCK);
FROM_HERE, base::BlockingType::MAY_BLOCK);
write_result = base::ImportantFileWriter::WriteFileAtomically(
predictor_filename, proto_str, "AppSearchResultRanker");
}
......
......@@ -43,7 +43,7 @@ void SaveProtoToDisk(const base::FilePath& filepath,
bool write_result;
{
base::ScopedBlockingCall scoped_blocking_call(
base::BlockingType::MAY_BLOCK);
FROM_HERE, base::BlockingType::MAY_BLOCK);
write_result = base::ImportantFileWriter::WriteFileAtomically(
filepath, proto_str, "RecurrenceRanker");
}
......
......@@ -231,7 +231,7 @@ class ChromeOSTermsHandler
void LoadOemEulaFileAsync() {
base::ScopedBlockingCall scoped_blocking_call(
base::BlockingType::MAY_BLOCK);
FROM_HERE, base::BlockingType::MAY_BLOCK);
const chromeos::StartupCustomizationDocument* customization =
chromeos::StartupCustomizationDocument::GetInstance();
......@@ -249,7 +249,7 @@ class ChromeOSTermsHandler
void LoadEulaFileAsync() {
base::ScopedBlockingCall scoped_blocking_call(
base::BlockingType::MAY_BLOCK);
FROM_HERE, base::BlockingType::MAY_BLOCK);
std::string file_path =
base::StringPrintf(chrome::kEULAPathFormat, locale_.c_str());
......@@ -266,7 +266,7 @@ class ChromeOSTermsHandler
void LoadArcPrivacyPolicyFileAsync() {
base::ScopedBlockingCall scoped_blocking_call(
base::BlockingType::MAY_BLOCK);
FROM_HERE, base::BlockingType::MAY_BLOCK);
for (const auto& locale : CreateArcLocaleLookupArray()) {
// Offline ARC privacy policis are only available during demo mode setup.
......@@ -288,7 +288,7 @@ class ChromeOSTermsHandler
void LoadArcTermsFileAsync() {
base::ScopedBlockingCall scoped_blocking_call(
base::BlockingType::MAY_BLOCK);
FROM_HERE, base::BlockingType::MAY_BLOCK);
for (const auto& locale : CreateArcLocaleLookupArray()) {
// Offline ARC TOS are only available during demo mode setup.
......
......@@ -116,7 +116,7 @@ base::Optional<ArcFeatures> ReadOnFileThread(const base::FilePath& file_path) {
std::string input_json;
{
base::ScopedBlockingCall scoped_blocking_call(
base::BlockingType::MAY_BLOCK);
FROM_HERE, base::BlockingType::MAY_BLOCK);
if (!base::ReadFileToString(file_path, &input_json)) {
PLOG(ERROR) << "Cannot read file " << file_path.value()
<< " into string.";
......
......@@ -339,7 +339,7 @@ class NSSInitSingleton {
// increments the thread pool capacity for the duration of the TPM
// initialization.
base::ScopedBlockingCall scoped_blocking_call(
base::BlockingType::WILL_BLOCK);
FROM_HERE, base::BlockingType::WILL_BLOCK);
if (!tpm_args->chaps_module) {
ScopedChapsLoadFixup chaps_loader;
......
......@@ -473,7 +473,7 @@ void Bus::ShutdownAndBlock() {
// Private connection should be closed.
if (connection_) {
base::ScopedBlockingCall scoped_blocking_call(
base::BlockingType::MAY_BLOCK);
FROM_HERE, base::BlockingType::MAY_BLOCK);
// Remove Disconnected watcher.
ScopedDBusError error;
......
......@@ -304,7 +304,7 @@ void ObjectProxy::Detach() {
for (auto* pending_call : pending_calls_) {
base::ScopedBlockingCall scoped_blocking_call(
base::BlockingType::MAY_BLOCK);
FROM_HERE, base::BlockingType::MAY_BLOCK);
dbus_pending_call_cancel(pending_call);
dbus_pending_call_unref(pending_call);
......
......@@ -338,7 +338,7 @@ void UsbDeviceHandleUsbfs::BlockingTaskHelper::OnFileCanWriteWithoutBlocking() {
urbs.reserve(MAX_URBS_PER_EVENT);
for (size_t i = 0; i < MAX_URBS_PER_EVENT; ++i) {
base::ScopedBlockingCall scoped_blocking_call(
base::BlockingType::MAY_BLOCK);
FROM_HERE, base::BlockingType::MAY_BLOCK);
usbdevfs_urb* urb;
int rc = HANDLE_EINTR(ioctl(fd_.get(), USBDEVFS_REAPURBNDELAY, &urb));
if (rc) {
......
......@@ -296,7 +296,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.
blocking_call.emplace(base::BlockingType::MAY_BLOCK);
blocking_call.emplace(FROM_HERE, base::BlockingType::MAY_BLOCK);
}
for (;;) {
......
......@@ -366,7 +366,7 @@ class DnsConfigServicePosix::HostsReader : public SerialWorker {
void DoWork() override {
base::TimeTicks start_time = base::TimeTicks::Now();
base::ScopedBlockingCall scoped_blocking_call(
base::BlockingType::MAY_BLOCK);
FROM_HERE, base::BlockingType::MAY_BLOCK);
success_ = ParseHostsFile(file_path_hosts_, &hosts_);
UMA_HISTOGRAM_BOOLEAN("AsyncDNS.HostParseResult", success_);
UMA_HISTOGRAM_TIMES("AsyncDNS.HostsParseDuration",
......
......@@ -62,7 +62,7 @@ class HidConnectionLinux::BlockingTaskHelper {
WriteCallback callback) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
base::ScopedBlockingCall scoped_blocking_call(
base::BlockingType::MAY_BLOCK);
FROM_HERE, base::BlockingType::MAY_BLOCK);
ssize_t result =
HANDLE_EINTR(write(fd_.get(), buffer->front(), buffer->size()));
......@@ -85,7 +85,7 @@ class HidConnectionLinux::BlockingTaskHelper {
ReadCallback callback) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
base::ScopedBlockingCall scoped_blocking_call(
base::BlockingType::MAY_BLOCK);
FROM_HERE, base::BlockingType::MAY_BLOCK);
int result = HANDLE_EINTR(
ioctl(fd_.get(), HIDIOCGFEATURE(buffer->size()), buffer->front()));
......@@ -115,7 +115,7 @@ class HidConnectionLinux::BlockingTaskHelper {
WriteCallback callback) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
base::ScopedBlockingCall scoped_blocking_call(
base::BlockingType::MAY_BLOCK);
FROM_HERE, base::BlockingType::MAY_BLOCK);
int result = HANDLE_EINTR(
ioctl(fd_.get(), HIDIOCSFEATURE(buffer->size()), buffer->front()));
......
......@@ -94,7 +94,7 @@ class HidServiceLinux::BlockingTaskHelper : public UdevWatcher::Observer {
void OnDeviceAdded(ScopedUdevDevicePtr device) override {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
base::ScopedBlockingCall scoped_blocking_call(
base::BlockingType::MAY_BLOCK);
FROM_HERE, base::BlockingType::MAY_BLOCK);
const char* device_path = udev_device_get_syspath(device.get());
if (!device_path)
......@@ -171,7 +171,7 @@ class HidServiceLinux::BlockingTaskHelper : public UdevWatcher::Observer {
void OnDeviceRemoved(ScopedUdevDevicePtr device) override {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
base::ScopedBlockingCall scoped_blocking_call(
base::BlockingType::MAY_BLOCK);
FROM_HERE, base::BlockingType::MAY_BLOCK);
const char* device_path = udev_device_get_syspath(device.get());
if (device_path) {
......
......@@ -94,7 +94,7 @@ class TimeZoneMonitorLinuxImpl
base::RetainedRef(this));
base::ScopedBlockingCall scoped_blocking_call(
base::BlockingType::MAY_BLOCK);
FROM_HERE, base::BlockingType::MAY_BLOCK);
// There is no true standard for where time zone information is actually
// stored. glibc uses /etc/localtime, uClibc uses /etc/TZ, and some older
......
......@@ -40,7 +40,7 @@ DrmDeviceHandle::DrmDeviceHandle() {
DrmDeviceHandle::~DrmDeviceHandle() {
if (file_.is_valid()) {
base::ScopedBlockingCall scoped_blocking_call(
base::BlockingType::MAY_BLOCK);
FROM_HERE, base::BlockingType::MAY_BLOCK);
file_.reset();
}
}
......
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