Commit 8e46b844 authored by Sami Kyostila's avatar Sami Kyostila Committed by Commit Bot

chrome/browser/media_galleries: Always specify thread affinity when posting tasks

*** Note: There is no behavior change from this patch. ***

The PostTask APIs will shortly be changed to require all tasks to explicitly
specify their thread affinity, i.e., whether the task should run on the thread
pool or a specific named thread such as a BrowserThread. This patch updates all
call sites with thread affinity annotation. We also remove the "WithTraits"
suffix to make the call sites more readable.

Before:

    // Thread pool task.
    base::PostTaskWithTraits(FROM_HERE, {...}, ...);

    // UI thread task.
    base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI, ...}, ...);

After:

    // Thread pool task.
    base::PostTask(FROM_HERE, {base::ThreadPool(), ...}, ...);

    // UI thread task.
    base::PostTask(FROM_HERE, {BrowserThread::UI, ...}, ...);

This patch was semi-automatically prepared with these steps:

    1. Patch in https://chromium-review.googlesource.com/c/chromium/src/+/1635827
       to make thread affinity a build-time requirement.
    2. Run an initial pass with a clang rewriter:
       https://chromium-review.googlesource.com/c/chromium/src/+/1635623
    3. ninja -C out/Debug | grep 'requested here' | cut -d: -f1-3 | sort | \
           uniq > errors.txt
    4. while read line; do
         f=$(echo $line | cut -d: -f 1)
         r=$(echo $line | cut -d: -f 2)
         c=$(echo $line | cut -d: -f 3)
         sed -i "${r}s/./&base::ThreadPool(),/$c" $f
       done < errors.txt
    5. GOTO 3 until build succeeds.
    6. Remove the "WithTraits" suffix from task API call sites:

       $ tools/git/mffr.py -i <(cat <<EOF
       [
         ["PostTaskWithTraits",                            "PostTask"],
         ["PostDelayedTaskWithTraits",                     "PostDelayedTask"],
         ["PostTaskWithTraitsAndReply",                    "PostTaskAndReply"],
         ["CreateTaskRunnerWithTraits",                    "CreateTaskRunner"],
         ["CreateSequencedTaskRunnerWithTraits",           "CreateSequencedTaskRunner"],
         ["CreateUpdateableSequencedTaskRunnerWithTraits", "CreateUpdateableSequencedTaskRunner"],
         ["CreateSingleThreadTaskRunnerWithTraits",        "CreateSingleThreadTaskRunner"],
         ["CreateCOMSTATaskRunnerWithTraits",              "CreateCOMSTATaskRunner"]
       ]
       EOF
       )

This CL was uploaded by git cl split.

R=reillyg@chromium.org

Bug: 968047
Change-Id: I5202fae8fa6ac5c7567ca9a46cb42a0716eda2e7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1729249
Auto-Submit: Sami Kyöstilä <skyostil@chromium.org>
Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Commit-Queue: Reilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#682825}
parent 998b28fe
......@@ -379,10 +379,11 @@ void CloseFileDescriptor(const int file_descriptor) {
// Deletes a temporary file |file_path|.
void DeleteTemporaryFile(const base::FilePath& file_path) {
base::PostTaskWithTraits(FROM_HERE,
{base::MayBlock(), base::TaskPriority::BEST_EFFORT},
base::BindOnce(base::IgnoreResult(base::DeleteFile),
file_path, false /* not recursive*/));
base::PostTask(
FROM_HERE,
{base::ThreadPool(), base::MayBlock(), base::TaskPriority::BEST_EFFORT},
base::BindOnce(base::IgnoreResult(base::DeleteFile), file_path,
false /* not recursive*/));
}
// A fake callback to be passed as CopyFileProgressCallback.
......@@ -679,9 +680,9 @@ void MTPDeviceDelegateImplLinux::CopyFileLocal(
DCHECK(!device_file_path.empty());
// Create a temporary file for creating a copy of source file on local.
base::PostTaskWithTraitsAndReplyWithResult(
base::PostTaskAndReplyWithResult(
FROM_HERE,
{base::MayBlock(), base::TaskPriority::BEST_EFFORT,
{base::ThreadPool(), base::MayBlock(), base::TaskPriority::BEST_EFFORT,
base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN},
create_temporary_file_callback,
base::Bind(
......@@ -850,10 +851,9 @@ void MTPDeviceDelegateImplLinux::NotifyFileChange(
void MTPDeviceDelegateImplLinux::CancelPendingTasksAndDeleteDelegate() {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
// To cancel all the pending tasks, destroy the MTPDeviceTaskHelper object.
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&CloseStorageAndDestroyTaskHelperOnUIThread, storage_name_,
read_only_));
base::PostTask(FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&CloseStorageAndDestroyTaskHelperOnUIThread,
storage_name_, read_only_));
delete this;
}
......@@ -976,7 +976,7 @@ void MTPDeviceDelegateImplLinux::ReadDirectoryInternal(
base::Bind(&GetFileInfoOnUIThread, storage_name_, read_only_, *dir_id,
success_callback_wrapper, error_callback_wrapper);
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::UI}, closure);
base::PostTask(FROM_HERE, {content::BrowserThread::UI}, closure);
}
void MTPDeviceDelegateImplLinux::CreateSnapshotFileInternal(
......@@ -1300,7 +1300,7 @@ void MTPDeviceDelegateImplLinux::EnsureInitAndRunTask(
if (init_state_ == UNINITIALIZED) {
init_state_ = PENDING_INIT;
task_in_progress_ = true;
base::PostTaskWithTraits(
base::PostTask(
FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&OpenStorageOnUIThread, storage_name_, read_only_,
base::Bind(&MTPDeviceDelegateImplLinux::OnInitCompleted,
......@@ -1326,8 +1326,7 @@ void MTPDeviceDelegateImplLinux::RunTask(const PendingTaskInfo& task_info) {
}
}
base::PostTaskWithTraits(task_info.location, {task_info.thread_id},
task_info.task);
base::PostTask(task_info.location, {task_info.thread_id}, task_info.task);
}
void MTPDeviceDelegateImplLinux::WriteDataIntoSnapshotFile(
......@@ -1351,8 +1350,7 @@ void MTPDeviceDelegateImplLinux::WriteDataIntoSnapshotFile(
read_only_,
request_info,
file_info);
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::UI},
task_closure);
base::PostTask(FROM_HERE, {content::BrowserThread::UI}, task_closure);
}
void MTPDeviceDelegateImplLinux::PendingRequestDone() {
......@@ -1452,8 +1450,7 @@ void MTPDeviceDelegateImplLinux::OnDidGetFileInfoToReadDirectory(
weak_ptr_factory_.GetWeakPtr(), dir_id, success_callback),
base::Bind(&MTPDeviceDelegateImplLinux::HandleDeviceFileError,
weak_ptr_factory_.GetWeakPtr(), error_callback, dir_id));
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::UI},
task_closure);
base::PostTask(FROM_HERE, {content::BrowserThread::UI}, task_closure);
}
void MTPDeviceDelegateImplLinux::OnDidGetFileInfoToCreateSnapshotFile(
......@@ -1513,8 +1510,9 @@ void MTPDeviceDelegateImplLinux::OnGetDestFileInfoErrorToCopyFileFromLocal(
return;
}
base::PostTaskWithTraitsAndReplyWithResult(
FROM_HERE, {base::MayBlock(), base::TaskPriority::BEST_EFFORT},
base::PostTaskAndReplyWithResult(
FROM_HERE,
{base::ThreadPool(), base::MayBlock(), base::TaskPriority::BEST_EFFORT},
base::Bind(&OpenFileDescriptor, source_file_path, O_RDONLY),
base::Bind(&MTPDeviceDelegateImplLinux::OnDidOpenFDToCopyFileFromLocal,
weak_ptr_factory_.GetWeakPtr(), device_file_path,
......@@ -1744,8 +1742,10 @@ void MTPDeviceDelegateImplLinux::OnDidCopyFileFromLocal(
const base::Closure closure = base::Bind(&CloseFileDescriptor,
source_file_descriptor);
base::PostTaskWithTraits(
FROM_HERE, {base::MayBlock(), base::TaskPriority::BEST_EFFORT}, closure);
base::PostTask(
FROM_HERE,
{base::ThreadPool(), base::MayBlock(), base::TaskPriority::BEST_EFFORT},
closure);
success_callback.Run();
NotifyFileChange(file_path.DirName(),
......@@ -1772,8 +1772,10 @@ void MTPDeviceDelegateImplLinux::HandleCopyFileFromLocalError(
const base::Closure closure = base::Bind(&CloseFileDescriptor,
source_file_descriptor);
base::PostTaskWithTraits(
FROM_HERE, {base::MayBlock(), base::TaskPriority::BEST_EFFORT}, closure);
base::PostTask(
FROM_HERE,
{base::ThreadPool(), base::MayBlock(), base::TaskPriority::BEST_EFFORT},
closure);
error_callback.Run(error);
PendingRequestDone();
......
......@@ -93,7 +93,7 @@ void MTPDeviceTaskHelper::OpenStorage(const std::string& storage_name,
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
DCHECK(!storage_name.empty());
if (!device_handle_.empty()) {
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO},
base::PostTask(FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(callback, true));
return;
}
......@@ -256,7 +256,7 @@ void MTPDeviceTaskHelper::OnDidOpenStorage(
bool error) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
device_handle_ = device_handle;
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO},
base::PostTask(FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(completion_callback, !error));
}
......@@ -271,10 +271,9 @@ void MTPDeviceTaskHelper::OnGetFileInfo(
base::File::FILE_ERROR_NOT_FOUND);
}
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(success_callback,
FileInfoFromMTPFileEntry(std::move(entries[0]))));
base::PostTask(FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(success_callback, FileInfoFromMTPFileEntry(
std::move(entries[0]))));
}
void MTPDeviceTaskHelper::OnCreateDirectory(
......@@ -283,14 +282,13 @@ void MTPDeviceTaskHelper::OnCreateDirectory(
const bool error) const {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
if (error) {
base::PostTaskWithTraits(
base::PostTask(
FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(error_callback, base::File::FILE_ERROR_FAILED));
return;
}
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO},
success_callback);
base::PostTask(FROM_HERE, {content::BrowserThread::IO}, success_callback);
}
void MTPDeviceTaskHelper::OnReadDirectoryEntryIdsToReadDirectory(
......@@ -304,7 +302,7 @@ void MTPDeviceTaskHelper::OnReadDirectoryEntryIdsToReadDirectory(
return HandleDeviceError(error_callback, base::File::FILE_ERROR_FAILED);
if (file_ids.empty()) {
base::PostTaskWithTraits(
base::PostTask(
FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(success_callback, MTPEntries(), /*has_more=*/false));
return;
......@@ -362,7 +360,7 @@ void MTPDeviceTaskHelper::OnGotDirectoryEntries(
bool has_more = !file_ids_to_read.empty();
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO},
base::PostTask(FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(success_callback, entries, has_more));
if (!has_more)
......@@ -390,8 +388,7 @@ void MTPDeviceTaskHelper::OnCheckedDirectoryEmpty(
if (error)
return HandleDeviceError(error_callback, base::File::FILE_ERROR_FAILED);
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::IO},
base::PostTask(FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(std::move(success_callback), file_ids.empty()));
}
......@@ -420,8 +417,7 @@ void MTPDeviceTaskHelper::OnGetFileInfoToReadBytes(
base::File::FILE_ERROR_FAILED);
}
if (request.offset == file_info.size) {
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::IO},
base::PostTask(FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(request.success_callback, file_info, 0u));
return;
}
......@@ -451,7 +447,7 @@ void MTPDeviceTaskHelper::OnDidReadBytes(
CHECK_LE(base::checked_cast<int>(data.length()), request.buf_len);
std::copy(data.begin(), data.end(), request.buf->data());
base::PostTaskWithTraits(
base::PostTask(
FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(request.success_callback, file_info, data.length()));
}
......@@ -462,14 +458,13 @@ void MTPDeviceTaskHelper::OnRenameObject(
const bool error) const {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
if (error) {
base::PostTaskWithTraits(
base::PostTask(
FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(error_callback, base::File::FILE_ERROR_FAILED));
return;
}
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO},
success_callback);
base::PostTask(FROM_HERE, {content::BrowserThread::IO}, success_callback);
}
void MTPDeviceTaskHelper::OnCopyFileFromLocal(
......@@ -478,14 +473,13 @@ void MTPDeviceTaskHelper::OnCopyFileFromLocal(
const bool error) const {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
if (error) {
base::PostTaskWithTraits(
base::PostTask(
FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(error_callback, base::File::FILE_ERROR_FAILED));
return;
}
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO},
success_callback);
base::PostTask(FROM_HERE, {content::BrowserThread::IO}, success_callback);
}
void MTPDeviceTaskHelper::OnDeleteObject(
......@@ -494,20 +488,19 @@ void MTPDeviceTaskHelper::OnDeleteObject(
const bool error) const {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
if (error) {
base::PostTaskWithTraits(
base::PostTask(
FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(error_callback, base::File::FILE_ERROR_FAILED));
return;
}
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO},
success_callback);
base::PostTask(FROM_HERE, {content::BrowserThread::IO}, success_callback);
}
void MTPDeviceTaskHelper::HandleDeviceError(
const ErrorCallback& error_callback,
base::File::Error error) const {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO},
base::PostTask(FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(error_callback, error));
}
......@@ -91,8 +91,9 @@ void MTPReadFileWorker::OnDidReadDataChunkFromDeviceFile(
// To avoid calling |snapshot_file_details| methods and passing ownership of
// |snapshot_file_details| in the same_line.
SnapshotFileDetails* snapshot_file_details_ptr = snapshot_file_details.get();
base::PostTaskWithTraitsAndReplyWithResult(
FROM_HERE, {base::MayBlock(), base::TaskPriority::BEST_EFFORT},
base::PostTaskAndReplyWithResult(
FROM_HERE,
{base::ThreadPool(), base::MayBlock(), base::TaskPriority::BEST_EFFORT},
base::Bind(&WriteDataChunkIntoSnapshotFileOnFileThread,
snapshot_file_details_ptr->snapshot_file_path(), data),
base::Bind(&MTPReadFileWorker::OnDidWriteDataChunkIntoSnapshotFile,
......@@ -122,14 +123,12 @@ void MTPReadFileWorker::OnDidWriteIntoSnapshotFile(
DCHECK(snapshot_file_details.get());
if (snapshot_file_details->error_occurred()) {
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::IO},
base::PostTask(FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(snapshot_file_details->error_callback(),
base::File::FILE_ERROR_FAILED));
return;
}
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::IO},
base::PostTask(FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(snapshot_file_details->success_callback(),
snapshot_file_details->file_info(),
snapshot_file_details->snapshot_file_path()));
......
......@@ -48,8 +48,8 @@ void AVScanningFileValidator::StartPostWriteValidation(
#if defined(OS_WIN)
base::PostTaskAndReplyWithResult(
base::CreateCOMSTATaskRunnerWithTraits(
{base::MayBlock(), base::TaskPriority::USER_VISIBLE})
base::CreateCOMSTATaskRunner({base::ThreadPool(), base::MayBlock(),
base::TaskPriority::USER_VISIBLE})
.get(),
FROM_HERE, base::Bind(&ScanFile, dest_platform_path), result_callback);
#else
......
......@@ -71,7 +71,7 @@ void OnPreferencesInit(
base::OnceCallback<void(base::File::Error result)> callback) {
content::WebContents* contents = web_contents_getter.Run();
if (!contents) {
base::PostTaskWithTraits(
base::PostTask(
FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(std::move(callback), base::File::FILE_ERROR_FAILED));
return;
......@@ -120,7 +120,7 @@ void AttemptAutoMountOnUIThread(
}
}
base::PostTaskWithTraits(
base::PostTask(
FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(std::move(callback), base::File::FILE_ERROR_NOT_FOUND));
}
......@@ -207,7 +207,7 @@ bool MediaFileSystemBackend::AttemptAutoMountForURLRequest(
content::WebContents::Getter web_contents_getter = base::BindRepeating(
&GetWebContentsFromFrameTreeNodeID, request_info.content_id);
base::PostTaskWithTraits(
base::PostTask(
FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&AttemptAutoMountOnUIThread, web_contents_getter,
request_info.storage_domain, mount_point,
......
......@@ -84,8 +84,7 @@ class MediaFileValidatorTest : public InProcessBrowserTest {
bool expected_result) {
base::RunLoop run_loop;
quit_closure_ = run_loop.QuitClosure();
base::PostTaskWithTraits(
FROM_HERE, {base::MayBlock()},
base::PostTask(FROM_HERE, {base::ThreadPool(), base::MayBlock()},
base::BindOnce(&MediaFileValidatorTest::SetupBlocking,
base::Unretained(this), filename, content,
expected_result));
......@@ -98,8 +97,8 @@ class MediaFileValidatorTest : public InProcessBrowserTest {
const base::FilePath& source, bool expected_result) {
base::RunLoop run_loop;
quit_closure_ = run_loop.QuitClosure();
base::PostTaskWithTraits(
FROM_HERE, {base::MayBlock()},
base::PostTask(
FROM_HERE, {base::ThreadPool(), base::MayBlock()},
base::BindOnce(&MediaFileValidatorTest::SetupFromFileBlocking,
base::Unretained(this), filename, source,
expected_result));
......@@ -127,7 +126,7 @@ class MediaFileValidatorTest : public InProcessBrowserTest {
std::vector<std::unique_ptr<storage::FileSystemBackend>>
additional_providers;
file_system_runner_ =
base::CreateSequencedTaskRunnerWithTraits({base::MayBlock()});
base::CreateSequencedTaskRunner({base::ThreadPool(), base::MayBlock()});
additional_providers.push_back(
std::make_unique<content::TestFileSystemBackend>(
file_system_runner_.get(), src_path));
......@@ -135,8 +134,7 @@ class MediaFileValidatorTest : public InProcessBrowserTest {
std::make_unique<MediaFileSystemBackend>(base));
file_system_context_ =
content::CreateFileSystemContextWithAdditionalProvidersForTesting(
base::CreateSingleThreadTaskRunnerWithTraits(
{content::BrowserThread::IO})
base::CreateSingleThreadTaskRunner({content::BrowserThread::IO})
.get(),
file_system_runner_.get(), NULL, std::move(additional_providers),
base);
......@@ -166,7 +164,7 @@ class MediaFileValidatorTest : public InProcessBrowserTest {
move_dest_ = file_system_context_->CrackURL(GURL(
dest_root_fs_url + "move_dest" + extension));
base::PostTaskWithTraits(
base::PostTask(
FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(&MediaFileValidatorTest::CheckFiles,
base::Unretained(this), true,
......
......@@ -535,8 +535,7 @@ void NativeMediaFileUtil::Core::GetFileInfoOnTaskRunnerThread(
base::File::Info file_info;
base::File::Error error =
GetFileInfoSync(context.get(), url, &file_info, NULL);
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::IO},
base::PostTask(FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(std::move(callback), error, file_info));
}
......@@ -548,9 +547,9 @@ void NativeMediaFileUtil::Core::ReadDirectoryOnTaskRunnerThread(
DCHECK(IsOnTaskRunnerThread(context.get()));
EntryList entry_list;
base::File::Error error = ReadDirectorySync(context.get(), url, &entry_list);
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(std::move(callback), error,
entry_list, false /* has_more */));
base::PostTask(FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(std::move(callback), error, entry_list,
false /* has_more */));
}
void NativeMediaFileUtil::Core::CreateSnapshotFileOnTaskRunnerThread(
......@@ -564,7 +563,7 @@ void NativeMediaFileUtil::Core::CreateSnapshotFileOnTaskRunnerThread(
scoped_refptr<storage::ShareableFileReference> file_ref;
base::File::Error error = CreateSnapshotFileSync(
context.get(), url, &file_info, &platform_path, &file_ref);
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO},
base::PostTask(FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(std::move(callback), error, file_info,
platform_path, file_ref));
}
......
......@@ -134,9 +134,7 @@ class NativeMediaFileUtilTest : public testing::Test {
std::make_unique<MediaFileSystemBackend>(data_dir_.GetPath()));
file_system_context_ = new storage::FileSystemContext(
base::CreateSingleThreadTaskRunnerWithTraits(
{content::BrowserThread::IO})
.get(),
base::CreateSingleThreadTaskRunner({content::BrowserThread::IO}).get(),
base::SequencedTaskRunnerHandle::Get().get(),
storage::ExternalMountPoints::CreateRefCounted().get(),
storage_policy.get(), NULL, std::move(additional_providers),
......
......@@ -79,7 +79,7 @@ void SupportedAudioVideoChecker::StartPreWriteValidation(
DCHECK(callback_.is_null());
callback_ = result_callback;
base::PostTaskWithTraits(
base::PostTask(
FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&SupportedAudioVideoChecker::RetrieveConnectorOnUIThread,
weak_factory_.GetWeakPtr()));
......@@ -96,7 +96,7 @@ void SupportedAudioVideoChecker::RetrieveConnectorOnUIThread(
// We need a fresh connector so that we can use it on the IO thread. It has
// to be retrieved from the UI thread. We must use static method and pass a
// WeakPtr around as WeakPtrs are not thread-safe.
base::PostTaskWithTraits(
base::PostTask(
FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(&SupportedAudioVideoChecker::OnConnectorRetrieved,
this_ptr, content::GetSystemConnector()->Clone()));
......@@ -110,8 +110,9 @@ void SupportedAudioVideoChecker::OnConnectorRetrieved(
if (!this_ptr)
return;
base::PostTaskWithTraitsAndReplyWithResult(
FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE},
base::PostTaskAndReplyWithResult(
FROM_HERE,
{base::ThreadPool(), base::MayBlock(), base::TaskPriority::USER_VISIBLE},
base::BindOnce(&OpenBlocking, this_ptr->path_),
base::BindOnce(&SupportedAudioVideoChecker::OnFileOpen, this_ptr,
std::move(connector)));
......
......@@ -107,8 +107,9 @@ void SupportedImageTypeValidator::StartPreWriteValidation(
DCHECK(callback_.is_null());
callback_ = result_callback;
base::PostTaskWithTraitsAndReplyWithResult(
FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE},
base::PostTaskAndReplyWithResult(
FROM_HERE,
{base::ThreadPool(), base::MayBlock(), base::TaskPriority::USER_VISIBLE},
base::Bind(&ReadOnFileThread, path_),
base::Bind(&SupportedImageTypeValidator::OnFileOpen,
weak_factory_.GetWeakPtr()));
......
......@@ -121,7 +121,7 @@ void GalleryWatchManager::FileWatchManager::AddFileWatch(
// This can occur if the GalleryWatchManager attempts to watch the same path
// again before recieving the callback. It's benign.
if (base::Contains(watchers_, path)) {
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::PostTask(FROM_HERE, {BrowserThread::UI},
base::BindOnce(callback, false));
return;
}
......@@ -135,7 +135,7 @@ void GalleryWatchManager::FileWatchManager::AddFileWatch(
if (success)
watchers_[path] = std::move(watcher);
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::PostTask(FROM_HERE, {BrowserThread::UI},
base::BindOnce(callback, success));
}
......@@ -159,7 +159,7 @@ void GalleryWatchManager::FileWatchManager::OnFilePathChanged(
if (error)
RemoveFileWatch(path);
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
base::PostTask(FROM_HERE, {BrowserThread::UI},
base::BindOnce(callback_, path, error));
}
......@@ -188,8 +188,9 @@ GalleryWatchManager::NotificationInfo::~NotificationInfo() {
GalleryWatchManager::GalleryWatchManager()
: storage_monitor_observed_(false),
watch_manager_task_runner_(base::CreateSequencedTaskRunnerWithTraits(
{base::MayBlock(), base::TaskPriority::BEST_EFFORT})) {
watch_manager_task_runner_(
base::CreateSequencedTaskRunner({base::ThreadPool(), base::MayBlock(),
base::TaskPriority::BEST_EFFORT})) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
watch_manager_.reset(new FileWatchManager(base::Bind(
&GalleryWatchManager::OnFilePathChanged, weak_factory_.GetWeakPtr())));
......@@ -432,7 +433,7 @@ void GalleryWatchManager::OnFilePathChanged(const base::FilePath& path,
notification_info->second.last_notify_time +
base::TimeDelta::FromSeconds(kMinNotificationDelayInSeconds) -
base::Time::Now();
base::PostDelayedTaskWithTraits(
base::PostDelayedTask(
FROM_HERE, {BrowserThread::UI},
base::BindOnce(&GalleryWatchManager::OnFilePathChanged,
weak_factory_.GetWeakPtr(), path, error),
......
......@@ -139,7 +139,7 @@ MTPDeviceDelegateImplMac::MTPDeviceDelegateImplMac(
file_info_[root_path_.value()] = info;
camera_interface_.reset(new DeviceListener(this));
base::PostTaskWithTraits(
base::PostTask(
FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&DeviceListener::OpenCameraSession,
base::Unretained(camera_interface_.get()), device_id_));
......@@ -170,7 +170,7 @@ void MTPDeviceDelegateImplMac::GetFileInfo(
base::File::Info* info = new base::File::Info;
base::File::Error* error = new base::File::Error;
// Note: ownership of these objects passed into the reply callback.
base::PostTaskWithTraitsAndReply(
base::PostTaskAndReply(
FROM_HERE, {content::BrowserThread::UI},
base::Bind(&MTPDeviceDelegateImplMac::GetFileInfoImpl,
base::Unretained(this), file_path, info, error),
......@@ -191,8 +191,7 @@ void MTPDeviceDelegateImplMac::ReadDirectory(
const base::FilePath& root,
const ReadDirectorySuccessCallback& success_callback,
const ErrorCallback& error_callback) {
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI},
base::PostTask(FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&MTPDeviceDelegateImplMac::ReadDirectoryImpl,
base::Unretained(this), root, success_callback,
error_callback));
......@@ -203,11 +202,10 @@ void MTPDeviceDelegateImplMac::CreateSnapshotFile(
const base::FilePath& local_path,
const CreateSnapshotFileSuccessCallback& success_callback,
const ErrorCallback& error_callback) {
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI},
base::PostTask(FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&MTPDeviceDelegateImplMac::DownloadFile,
base::Unretained(this), device_file_path, local_path,
success_callback, error_callback));
base::Unretained(this), device_file_path,
local_path, success_callback, error_callback));
}
bool MTPDeviceDelegateImplMac::IsStreaming() {
......@@ -290,8 +288,7 @@ void MTPDeviceDelegateImplMac::RemoveWatcher(
}
void MTPDeviceDelegateImplMac::CancelPendingTasksAndDeleteDelegate() {
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI},
base::PostTask(FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&MTPDeviceDelegateImplMac::CancelAndDelete,
base::Unretained(this)));
}
......@@ -325,7 +322,7 @@ void MTPDeviceDelegateImplMac::ReadDirectoryImpl(
}
// Schedule a timeout in case the directory read doesn't complete.
base::PostDelayedTaskWithTraits(
base::PostDelayedTask(
FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&MTPDeviceDelegateImplMac::ReadDirectoryTimeout,
weak_factory_.GetWeakPtr(), root),
......@@ -359,7 +356,7 @@ void MTPDeviceDelegateImplMac::DownloadFile(
base::File::Info info;
GetFileInfoImpl(device_file_path, &info, &error);
if (error != base::File::FILE_OK) {
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO},
base::PostTask(FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(error_callback, error));
return;
}
......@@ -385,8 +382,7 @@ void MTPDeviceDelegateImplMac::CancelAndDelete() {
// Schedule the camera session to be closed and the interface deleted.
// This will cancel any downloads in progress.
camera_interface_->ResetDelegate();
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::UI},
base::PostTask(FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&DeviceListener::CloseCameraSessionAndDelete,
base::Unretained(camera_interface_.release())));
......@@ -397,7 +393,7 @@ void MTPDeviceDelegateImplMac::CancelDownloads() {
// Cancel any outstanding callbacks.
for (ReadFileTransactionList::iterator iter = read_file_transactions_.begin();
iter != read_file_transactions_.end(); ++iter) {
base::PostTaskWithTraits(
base::PostTask(
FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(iter->error_callback, base::File::FILE_ERROR_ABORT));
}
......@@ -405,7 +401,7 @@ void MTPDeviceDelegateImplMac::CancelDownloads() {
for (ReadDirTransactionList::iterator iter = read_dir_transactions_.begin();
iter != read_dir_transactions_.end(); ++iter) {
base::PostTaskWithTraits(
base::PostTask(
FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(iter->error_callback, base::File::FILE_ERROR_ABORT));
}
......@@ -477,12 +473,10 @@ void MTPDeviceDelegateImplMac::NotifyReadDir() {
}
if (found_path) {
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::IO},
base::PostTask(FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(iter->success_callback, entry_list, false));
} else {
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::IO},
base::PostTask(FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(iter->error_callback,
base::File::FILE_ERROR_NOT_FOUND));
}
......@@ -510,7 +504,7 @@ void MTPDeviceDelegateImplMac::DownloadedFile(
return;
if (error != base::File::FILE_OK) {
base::PostTaskWithTraits(FROM_HERE, {content::BrowserThread::IO},
base::PostTask(FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(iter->error_callback, error));
read_file_transactions_.erase(iter);
return;
......@@ -527,7 +521,7 @@ void MTPDeviceDelegateImplMac::DownloadedFile(
}
base::File::Info info = file_info_[item_filename.value()];
base::PostTaskWithTraits(
base::PostTask(
FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(iter->success_callback, info, iter->snapshot_file));
read_file_transactions_.erase(iter);
......
......@@ -462,7 +462,7 @@ class ExtensionGalleriesHost
rph_refs_.Reset();
CleanUp();
}
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::IO},
base::PostTask(FROM_HERE, {BrowserThread::IO},
base::BindOnce(std::move(callback), result));
}
......@@ -556,7 +556,7 @@ void MediaFileSystemRegistry::RegisterMediaFileSystemForExtension(
if (gallery == preferences->known_galleries().end() ||
!base::Contains(permitted_galleries, pref_id)) {
base::PostTaskWithTraits(
base::PostTask(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(std::move(callback), base::File::FILE_ERROR_NOT_FOUND));
return;
......@@ -664,7 +664,7 @@ class MediaFileSystemRegistry::MediaFileSystemContextImpl
ExternalMountPoints::GetSystemInstance()->RevokeFileSystem(fs_name);
#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS)
base::PostTaskWithTraits(
base::PostTask(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&MTPDeviceMapService::RevokeMTPFileSystem,
base::Unretained(MTPDeviceMapService::GetInstance()),
......@@ -714,7 +714,7 @@ class MediaFileSystemRegistry::MediaFileSystemContextImpl
storage::FileSystemMountOption(),
path);
CHECK(result);
base::PostTaskWithTraits(
base::PostTask(
FROM_HERE, {BrowserThread::IO},
base::BindOnce(&MTPDeviceMapService::RegisterMTPFileSystem,
base::Unretained(MTPDeviceMapService::GetInstance()),
......
......@@ -320,7 +320,7 @@ void CreateMTPDeviceAsyncDelegate(
DCHECK(!device_location.empty());
base::string16* pnp_device_id = new base::string16;
base::string16* storage_object_id = new base::string16;
base::PostTaskWithTraitsAndReplyWithResult(
base::PostTaskAndReplyWithResult(
FROM_HERE, {content::BrowserThread::UI},
base::Bind(&GetStorageInfoOnUIThread, device_location,
base::Unretained(pnp_device_id),
......
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