Commit 23d87be5 authored by Joe Mason's avatar Joe Mason Committed by Commit Bot

Run MigrateTaskbarPinsCallback in the foreground.

It calls MigrateShortcutsInPathInternal several time and each call may
or may not load DLL's, so the whole thing needs to be in the foreground
in case it needs the loader lock.

R=gab

Bug: 1047442
Change-Id: Id962af6556e312bf638066e33268fe4902e0110f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2032005Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Commit-Queue: Joe Mason <joenotcharles@chromium.org>
Cr-Commit-Position: refs/heads/master@{#737532}
parent 9af22179
......@@ -31,8 +31,8 @@
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/post_task.h"
#include "base/threading/platform_thread.h"
#include "base/threading/scoped_blocking_call.h"
#include "base/threading/scoped_thread_priority.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "base/win/registry.h"
......@@ -748,8 +748,18 @@ void MigrateTaskbarPins() {
return;
}
base::CreateCOMSTATaskRunner(
{base::ThreadPool(), base::MayBlock(), base::TaskPriority::BEST_EFFORT})
// MigrateTaskbarPinsCallback just calls MigrateShortcutsInPathInternal
// several times with different parameters. Each call may or may not load
// DLL's. Since the callback may take the loader lock several times, and this
// is the bulk of the callback's work, run the whole thing on a foreground
// thread.
//
// BEST_EFFORT means it will be scheduled after higher-priority tasks, but
// MUST_USE_FOREGROUND means that when it is scheduled it will run in the
// foregound.
base::CreateCOMSTATaskRunner({base::ThreadPool(), base::MayBlock(),
base::TaskPriority::BEST_EFFORT,
base::ThreadPolicy::MUST_USE_FOREGROUND})
->PostTask(FROM_HERE, base::BindOnce(&MigrateTaskbarPinsCallback,
taskbar_path, implicit_apps_path));
}
......@@ -782,9 +792,10 @@ void GetIsPinnedToTaskbarState(
int MigrateShortcutsInPathInternal(const base::FilePath& chrome_exe,
const base::FilePath& path) {
// Mitigate the issues caused by loading DLLs on a background thread
// (http://crbug/973868).
SCOPED_MAY_LOAD_LIBRARY_AT_BACKGROUND_PRIORITY();
// This function may load DLL's so ensure it is running in a foreground
// thread.
DCHECK_GT(base::PlatformThread::GetCurrentThreadPriority(),
base::ThreadPriority::BACKGROUND);
// Enumerate all pinned shortcuts in the given path directly.
base::FileEnumerator shortcuts_enum(
......
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