content: 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.

[email protected], [email protected]

Bug: 968047
Change-Id: I65f388a01112b7ece4ddd77d839ff28b3c22c554
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1728665
Auto-Submit: Sami Kyöstilä <[email protected]>
Reviewed-by: Kinuko Yasuda <[email protected]>
Commit-Queue: Sami Kyöstilä <[email protected]>
Cr-Commit-Position: refs/heads/master@{#683196}
diff --git a/content/shell/browser/shell_download_manager_delegate.cc b/content/shell/browser/shell_download_manager_delegate.cc
index a181f0e..9c8ff8bb 100644
--- a/content/shell/browser/shell_download_manager_delegate.cc
+++ b/content/shell/browser/shell_download_manager_delegate.cc
@@ -83,15 +83,15 @@
       &ShellDownloadManagerDelegate::OnDownloadPathGenerated,
       weak_ptr_factory_.GetWeakPtr(), download->GetId(), callback);
 
-  PostTaskWithTraits(
-      FROM_HERE,
-      {base::MayBlock(), base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN,
-       base::TaskPriority::USER_VISIBLE},
-      base::BindOnce(&ShellDownloadManagerDelegate::GenerateFilename,
-                     download->GetURL(), download->GetContentDisposition(),
-                     download->GetSuggestedFilename(), download->GetMimeType(),
-                     default_download_path_,
-                     std::move(filename_determined_callback)));
+  PostTask(FROM_HERE,
+           {base::ThreadPool(), base::MayBlock(),
+            base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN,
+            base::TaskPriority::USER_VISIBLE},
+           base::BindOnce(&ShellDownloadManagerDelegate::GenerateFilename,
+                          download->GetURL(), download->GetContentDisposition(),
+                          download->GetSuggestedFilename(),
+                          download->GetMimeType(), default_download_path_,
+                          std::move(filename_determined_callback)));
   return true;
 }
 
@@ -126,8 +126,8 @@
     base::CreateDirectory(suggested_directory);
 
   base::FilePath suggested_path(suggested_directory.Append(generated_name));
-  base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI},
-                           base::BindOnce(std::move(callback), suggested_path));
+  base::PostTask(FROM_HERE, {BrowserThread::UI},
+                 base::BindOnce(std::move(callback), suggested_path));
 }
 
 void ShellDownloadManagerDelegate::OnDownloadPathGenerated(