From 95b27a6674e8de232590fd85d39ad6cb2567e6c3 Mon Sep 17 00:00:00 2001 From: Sami Kyostila Date: Thu, 1 Aug 2019 19:39:17 +0000 Subject: [PATCH] ppapi: Always specify thread affinity when posting tasks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit *** 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 < Reviewed-by: Bill Budge Commit-Queue: Bill Budge Cr-Commit-Position: refs/heads/master@{#683273} --- ppapi/host/resource_message_filter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ppapi/host/resource_message_filter.h b/ppapi/host/resource_message_filter.h index 0b50cb049420b7..b9c4b74fb31ad2 100644 --- a/ppapi/host/resource_message_filter.h +++ b/ppapi/host/resource_message_filter.h @@ -52,7 +52,7 @@ struct PPAPI_HOST_EXPORT ResourceMessageFilterDeleteTraits { // scoped_refptr OverrideTaskRunnerForMessage( // const IPC::Message& message) override { // if (message.type() == MyMessage::ID) { -// return base::CreateSingleThreadTaskRunnerWithTraits( +// return base::CreateSingleThreadTaskRunner( // {BrowserThread::UI}); // } // return NULL;