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