Commit 1c837f08 authored by Sami Kyostila's avatar Sami Kyostila Committed by Commit Bot

content/browser/notifications: 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=knollr@chromium.org

Bug: 968047
Change-Id: I6c06f32b24ff208b5020f45f70b3c09d08fd9881
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1728558
Auto-Submit: Sami Kyöstilä <skyostil@chromium.org>
Reviewed-by: default avatarRichard Knoll <knollr@chromium.org>
Commit-Queue: Sami Kyöstilä <skyostil@chromium.org>
Cr-Commit-Position: refs/heads/master@{#682745}
parent addf63d2
...@@ -350,9 +350,8 @@ NotificationDatabase::Status NotificationDatabase::DeleteNotificationData( ...@@ -350,9 +350,8 @@ NotificationDatabase::Status NotificationDatabase::DeleteNotificationData(
NotificationDatabaseData data; NotificationDatabaseData data;
Status status = ReadNotificationData(notification_id, origin, &data); Status status = ReadNotificationData(notification_id, origin, &data);
if (status == STATUS_OK && record_notification_to_ukm_callback_) { if (status == STATUS_OK && record_notification_to_ukm_callback_) {
base::PostTaskWithTraits( base::PostTask(FROM_HERE, {BrowserThread::UI},
FROM_HERE, {BrowserThread::UI}, base::BindOnce(record_notification_to_ukm_callback_, data));
base::BindOnce(record_notification_to_ukm_callback_, data));
} }
leveldb::WriteBatch batch; leveldb::WriteBatch batch;
...@@ -507,10 +506,9 @@ NotificationDatabase::DeleteAllNotificationDataInternal( ...@@ -507,10 +506,9 @@ NotificationDatabase::DeleteAllNotificationDataInternal(
} }
if (record_notification_to_ukm_callback_) { if (record_notification_to_ukm_callback_) {
base::PostTaskWithTraits( base::PostTask(FROM_HERE, {BrowserThread::UI},
FROM_HERE, {BrowserThread::UI}, base::BindOnce(record_notification_to_ukm_callback_,
base::BindOnce(record_notification_to_ukm_callback_, notification_database_data));
notification_database_data));
} }
std::string notification_id = notification_database_data.notification_id; std::string notification_id = notification_database_data.notification_id;
......
...@@ -87,7 +87,7 @@ void ServiceWorkerNotificationEventFinished( ...@@ -87,7 +87,7 @@ void ServiceWorkerNotificationEventFinished(
NotificationDispatchCompleteCallback dispatch_complete_callback, NotificationDispatchCompleteCallback dispatch_complete_callback,
blink::ServiceWorkerStatusCode service_worker_status) { blink::ServiceWorkerStatusCode service_worker_status) {
DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK_CURRENTLY_ON(BrowserThread::IO);
base::PostTaskWithTraits( base::PostTask(
FROM_HERE, {BrowserThread::UI}, FROM_HERE, {BrowserThread::UI},
base::BindOnce(std::move(dispatch_complete_callback), base::BindOnce(std::move(dispatch_complete_callback),
ConvertServiceWorkerStatus(service_worker_status))); ConvertServiceWorkerStatus(service_worker_status)));
...@@ -149,9 +149,8 @@ void DispatchNotificationEventOnRegistration( ...@@ -149,9 +149,8 @@ void DispatchNotificationEventOnRegistration(
break; break;
} }
base::PostTaskWithTraits( base::PostTask(FROM_HERE, {BrowserThread::UI},
FROM_HERE, {BrowserThread::UI}, base::BindOnce(std::move(dispatch_complete_callback), status));
base::BindOnce(std::move(dispatch_complete_callback), status));
} }
// Finds the ServiceWorkerRegistration associated with the |origin| and // Finds the ServiceWorkerRegistration associated with the |origin| and
...@@ -176,7 +175,7 @@ void FindServiceWorkerRegistration( ...@@ -176,7 +175,7 @@ void FindServiceWorkerRegistration(
return; return;
} }
base::PostTaskWithTraits( base::PostTask(
FROM_HERE, {BrowserThread::IO}, FROM_HERE, {BrowserThread::IO},
base::BindOnce(&ServiceWorkerContextWrapper::FindReadyRegistrationForId, base::BindOnce(&ServiceWorkerContextWrapper::FindReadyRegistrationForId,
service_worker_context, service_worker_context,
...@@ -248,7 +247,7 @@ void DoDispatchNotificationClickEvent( ...@@ -248,7 +247,7 @@ void DoDispatchNotificationClickEvent(
NotificationDispatchCompleteCallback dispatch_complete_callback) { NotificationDispatchCompleteCallback dispatch_complete_callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK_CURRENTLY_ON(BrowserThread::IO);
base::PostTaskWithTraits( base::PostTask(
FROM_HERE, {BrowserThread::UI}, FROM_HERE, {BrowserThread::UI},
base::BindOnce(&notifications::LogNotificationClickedEventToDevTools, base::BindOnce(&notifications::LogNotificationClickedEventToDevTools,
browser_context, notification_database_data, action_index, browser_context, notification_database_data, action_index,
...@@ -290,7 +289,7 @@ void DeleteNotificationDataFromDatabase( ...@@ -290,7 +289,7 @@ void DeleteNotificationDataFromDatabase(
NotificationDispatchCompleteCallback dispatch_complete_callback, NotificationDispatchCompleteCallback dispatch_complete_callback,
blink::ServiceWorkerStatusCode status_code) { blink::ServiceWorkerStatusCode status_code) {
DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK_CURRENTLY_ON(BrowserThread::IO);
base::PostTaskWithTraits( base::PostTask(
FROM_HERE, {BrowserThread::UI}, FROM_HERE, {BrowserThread::UI},
base::BindOnce( base::BindOnce(
&PlatformNotificationContext::DeleteNotificationData, &PlatformNotificationContext::DeleteNotificationData,
......
...@@ -242,10 +242,9 @@ void PlatformNotificationContextImpl::DoReadAllNotificationOrigins( ...@@ -242,10 +242,9 @@ void PlatformNotificationContextImpl::DoReadAllNotificationOrigins(
DCHECK(task_runner_->RunsTasksInCurrentSequence()); DCHECK(task_runner_->RunsTasksInCurrentSequence());
std::set<GURL> origins; std::set<GURL> origins;
if (!initialized) { if (!initialized) {
base::PostTaskWithTraits( base::PostTask(FROM_HERE, {BrowserThread::UI},
FROM_HERE, {BrowserThread::UI}, base::BindOnce(std::move(callback), /* success= */ false,
base::BindOnce(std::move(callback), /* success= */ false, std::move(origins)));
std::move(origins)));
return; return;
} }
...@@ -264,7 +263,7 @@ void PlatformNotificationContextImpl::DoReadAllNotificationOrigins( ...@@ -264,7 +263,7 @@ void PlatformNotificationContextImpl::DoReadAllNotificationOrigins(
if (status == NotificationDatabase::STATUS_ERROR_CORRUPTED) if (status == NotificationDatabase::STATUS_ERROR_CORRUPTED)
DestroyDatabase(); DestroyDatabase();
base::PostTaskWithTraits( base::PostTask(
FROM_HERE, {BrowserThread::UI}, FROM_HERE, {BrowserThread::UI},
base::BindOnce(std::move(callback), success, std::move(origins))); base::BindOnce(std::move(callback), success, std::move(origins)));
} }
...@@ -310,10 +309,9 @@ void PlatformNotificationContextImpl::DoDeleteAllNotificationDataForOrigins( ...@@ -310,10 +309,9 @@ void PlatformNotificationContextImpl::DoDeleteAllNotificationDataForOrigins(
bool initialized) { bool initialized) {
DCHECK(task_runner_->RunsTasksInCurrentSequence()); DCHECK(task_runner_->RunsTasksInCurrentSequence());
if (!initialized) { if (!initialized) {
base::PostTaskWithTraits( base::PostTask(FROM_HERE, {BrowserThread::UI},
FROM_HERE, {BrowserThread::UI}, base::BindOnce(std::move(callback), /* success= */ false,
base::BindOnce(std::move(callback), /* success= */ false, /* deleted_count= */ 0));
/* deleted_count= */ 0));
return; return;
} }
...@@ -344,9 +342,9 @@ void PlatformNotificationContextImpl::DoDeleteAllNotificationDataForOrigins( ...@@ -344,9 +342,9 @@ void PlatformNotificationContextImpl::DoDeleteAllNotificationDataForOrigins(
service_proxy_->CloseNotification(notification_id); service_proxy_->CloseNotification(notification_id);
} }
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI}, base::PostTask(FROM_HERE, {BrowserThread::UI},
base::BindOnce(std::move(callback), success, base::BindOnce(std::move(callback), success,
deleted_notification_ids.size())); deleted_notification_ids.size()));
} }
void PlatformNotificationContextImpl::ReadNotificationDataAndRecordInteraction( void PlatformNotificationContextImpl::ReadNotificationDataAndRecordInteraction(
...@@ -368,10 +366,9 @@ void PlatformNotificationContextImpl::DoReadNotificationData( ...@@ -368,10 +366,9 @@ void PlatformNotificationContextImpl::DoReadNotificationData(
bool initialized) { bool initialized) {
DCHECK(task_runner_->RunsTasksInCurrentSequence()); DCHECK(task_runner_->RunsTasksInCurrentSequence());
if (!initialized) { if (!initialized) {
base::PostTaskWithTraits( base::PostTask(FROM_HERE, {BrowserThread::UI},
FROM_HERE, {BrowserThread::UI}, base::BindOnce(std::move(callback), /* success= */ false,
base::BindOnce(std::move(callback), /* success= */ false, NotificationDatabaseData()));
NotificationDatabaseData()));
return; return;
} }
...@@ -384,10 +381,9 @@ void PlatformNotificationContextImpl::DoReadNotificationData( ...@@ -384,10 +381,9 @@ void PlatformNotificationContextImpl::DoReadNotificationData(
NotificationDatabase::STATUS_COUNT); NotificationDatabase::STATUS_COUNT);
if (status == NotificationDatabase::STATUS_OK) { if (status == NotificationDatabase::STATUS_OK) {
base::PostTaskWithTraits( base::PostTask(FROM_HERE, {BrowserThread::UI},
FROM_HERE, {BrowserThread::UI}, base::BindOnce(std::move(callback), /* success= */ true,
base::BindOnce(std::move(callback), /* success= */ true, database_data));
database_data));
return; return;
} }
...@@ -395,10 +391,9 @@ void PlatformNotificationContextImpl::DoReadNotificationData( ...@@ -395,10 +391,9 @@ void PlatformNotificationContextImpl::DoReadNotificationData(
if (status == NotificationDatabase::STATUS_ERROR_CORRUPTED) if (status == NotificationDatabase::STATUS_ERROR_CORRUPTED)
DestroyDatabase(); DestroyDatabase();
base::PostTaskWithTraits( base::PostTask(FROM_HERE, {BrowserThread::UI},
FROM_HERE, {BrowserThread::UI}, base::BindOnce(std::move(callback), /* success= */ false,
base::BindOnce(std::move(callback), /* success= */ false, NotificationDatabaseData()));
NotificationDatabaseData()));
} }
void PlatformNotificationContextImpl::TriggerNotifications() { void PlatformNotificationContextImpl::TriggerNotifications() {
...@@ -470,9 +465,8 @@ void PlatformNotificationContextImpl::DoWriteNotificationResources( ...@@ -470,9 +465,8 @@ void PlatformNotificationContextImpl::DoWriteNotificationResources(
bool initialized) { bool initialized) {
DCHECK(task_runner_->RunsTasksInCurrentSequence()); DCHECK(task_runner_->RunsTasksInCurrentSequence());
if (!initialized) { if (!initialized) {
base::PostTaskWithTraits( base::PostTask(FROM_HERE, {BrowserThread::UI},
FROM_HERE, {BrowserThread::UI}, base::BindOnce(std::move(callback), /* success= */ false));
base::BindOnce(std::move(callback), /* success= */ false));
return; return;
} }
...@@ -503,9 +497,8 @@ void PlatformNotificationContextImpl::DoWriteNotificationResources( ...@@ -503,9 +497,8 @@ void PlatformNotificationContextImpl::DoWriteNotificationResources(
} }
if (status == NotificationDatabase::STATUS_OK) { if (status == NotificationDatabase::STATUS_OK) {
base::PostTaskWithTraits( base::PostTask(FROM_HERE, {BrowserThread::UI},
FROM_HERE, {BrowserThread::UI}, base::BindOnce(std::move(callback), /* success= */ true));
base::BindOnce(std::move(callback), /* success= */ true));
return; return;
} }
...@@ -513,9 +506,8 @@ void PlatformNotificationContextImpl::DoWriteNotificationResources( ...@@ -513,9 +506,8 @@ void PlatformNotificationContextImpl::DoWriteNotificationResources(
if (status == NotificationDatabase::STATUS_ERROR_CORRUPTED) if (status == NotificationDatabase::STATUS_ERROR_CORRUPTED)
DestroyDatabase(); DestroyDatabase();
base::PostTaskWithTraits( base::PostTask(FROM_HERE, {BrowserThread::UI},
FROM_HERE, {BrowserThread::UI}, base::BindOnce(std::move(callback), /* success= */ false));
base::BindOnce(std::move(callback), /* success= */ false));
} }
void PlatformNotificationContextImpl::ReDisplayNotifications( void PlatformNotificationContextImpl::ReDisplayNotifications(
...@@ -537,9 +529,8 @@ void PlatformNotificationContextImpl::DoReDisplayNotifications( ...@@ -537,9 +529,8 @@ void PlatformNotificationContextImpl::DoReDisplayNotifications(
DCHECK(task_runner_->RunsTasksInCurrentSequence()); DCHECK(task_runner_->RunsTasksInCurrentSequence());
size_t display_count = 0; size_t display_count = 0;
if (!initialized) { if (!initialized) {
base::PostTaskWithTraits( base::PostTask(FROM_HERE, {BrowserThread::UI},
FROM_HERE, {BrowserThread::UI}, base::BindOnce(std::move(callback), display_count));
base::BindOnce(std::move(callback), display_count));
return; return;
} }
...@@ -581,9 +572,9 @@ void PlatformNotificationContextImpl::DoReDisplayNotifications( ...@@ -581,9 +572,9 @@ void PlatformNotificationContextImpl::DoReDisplayNotifications(
if (status == NotificationDatabase::STATUS_ERROR_CORRUPTED) if (status == NotificationDatabase::STATUS_ERROR_CORRUPTED)
DestroyDatabase(); DestroyDatabase();
base::PostTaskWithTraits( base::PostTask(FROM_HERE,
FROM_HERE, {BrowserThread::UI, base::TaskPriority::USER_VISIBLE}, {BrowserThread::UI, base::TaskPriority::USER_VISIBLE},
base::BindOnce(std::move(callback), display_count)); base::BindOnce(std::move(callback), display_count));
} }
void PlatformNotificationContextImpl::ReadNotificationResources( void PlatformNotificationContextImpl::ReadNotificationResources(
...@@ -603,10 +594,9 @@ void PlatformNotificationContextImpl::DoReadNotificationResources( ...@@ -603,10 +594,9 @@ void PlatformNotificationContextImpl::DoReadNotificationResources(
bool initialized) { bool initialized) {
DCHECK(task_runner_->RunsTasksInCurrentSequence()); DCHECK(task_runner_->RunsTasksInCurrentSequence());
if (!initialized) { if (!initialized) {
base::PostTaskWithTraits( base::PostTask(FROM_HERE, {BrowserThread::UI},
FROM_HERE, {BrowserThread::UI}, base::BindOnce(std::move(callback), /* success= */ false,
base::BindOnce(std::move(callback), /* success= */ false, blink::NotificationResources()));
blink::NotificationResources()));
return; return;
} }
...@@ -618,10 +608,9 @@ void PlatformNotificationContextImpl::DoReadNotificationResources( ...@@ -618,10 +608,9 @@ void PlatformNotificationContextImpl::DoReadNotificationResources(
status, NotificationDatabase::STATUS_COUNT); status, NotificationDatabase::STATUS_COUNT);
if (status == NotificationDatabase::STATUS_OK) { if (status == NotificationDatabase::STATUS_OK) {
base::PostTaskWithTraits( base::PostTask(FROM_HERE, {BrowserThread::UI},
FROM_HERE, {BrowserThread::UI}, base::BindOnce(std::move(callback), /* success= */ true,
base::BindOnce(std::move(callback), /* success= */ true, notification_resources));
notification_resources));
return; return;
} }
...@@ -629,10 +618,9 @@ void PlatformNotificationContextImpl::DoReadNotificationResources( ...@@ -629,10 +618,9 @@ void PlatformNotificationContextImpl::DoReadNotificationResources(
if (status == NotificationDatabase::STATUS_ERROR_CORRUPTED) if (status == NotificationDatabase::STATUS_ERROR_CORRUPTED)
DestroyDatabase(); DestroyDatabase();
base::PostTaskWithTraits( base::PostTask(FROM_HERE, {BrowserThread::UI},
FROM_HERE, {BrowserThread::UI}, base::BindOnce(std::move(callback), /* success= */ false,
base::BindOnce(std::move(callback), /* success= */ false, blink::NotificationResources()));
blink::NotificationResources()));
} }
void PlatformNotificationContextImpl:: void PlatformNotificationContextImpl::
...@@ -687,10 +675,9 @@ void PlatformNotificationContextImpl:: ...@@ -687,10 +675,9 @@ void PlatformNotificationContextImpl::
bool initialized) { bool initialized) {
DCHECK(task_runner_->RunsTasksInCurrentSequence()); DCHECK(task_runner_->RunsTasksInCurrentSequence());
if (!initialized) { if (!initialized) {
base::PostTaskWithTraits( base::PostTask(FROM_HERE, {BrowserThread::UI},
FROM_HERE, {BrowserThread::UI}, base::BindOnce(std::move(callback), /* success= */ false,
base::BindOnce(std::move(callback), /* success= */ false, std::vector<NotificationDatabaseData>()));
std::vector<NotificationDatabaseData>()));
return; return;
} }
...@@ -722,10 +709,9 @@ void PlatformNotificationContextImpl:: ...@@ -722,10 +709,9 @@ void PlatformNotificationContextImpl::
} }
} }
base::PostTaskWithTraits( base::PostTask(FROM_HERE, {BrowserThread::UI},
FROM_HERE, {BrowserThread::UI}, base::BindOnce(std::move(callback), /* success= */ true,
base::BindOnce(std::move(callback), /* success= */ true, notification_datas));
notification_datas));
// Remove notifications that are not actually on display anymore. // Remove notifications that are not actually on display anymore.
for (const auto& it : obsolete_notifications) for (const auto& it : obsolete_notifications)
...@@ -737,10 +723,9 @@ void PlatformNotificationContextImpl:: ...@@ -737,10 +723,9 @@ void PlatformNotificationContextImpl::
if (status == NotificationDatabase::STATUS_ERROR_CORRUPTED) if (status == NotificationDatabase::STATUS_ERROR_CORRUPTED)
DestroyDatabase(); DestroyDatabase();
base::PostTaskWithTraits( base::PostTask(FROM_HERE, {BrowserThread::UI},
FROM_HERE, {BrowserThread::UI}, base::BindOnce(std::move(callback), /* success= */ false,
base::BindOnce(std::move(callback), /* success= */ false, std::vector<NotificationDatabaseData>()));
std::vector<NotificationDatabaseData>()));
} }
void PlatformNotificationContextImpl::WriteNotificationData( void PlatformNotificationContextImpl::WriteNotificationData(
...@@ -788,10 +773,9 @@ void PlatformNotificationContextImpl::DoWriteNotificationData( ...@@ -788,10 +773,9 @@ void PlatformNotificationContextImpl::DoWriteNotificationData(
DCHECK(task_runner_->RunsTasksInCurrentSequence()); DCHECK(task_runner_->RunsTasksInCurrentSequence());
DCHECK(database_data.notification_id.empty()); DCHECK(database_data.notification_id.empty());
if (!initialized || !service_proxy_) { if (!initialized || !service_proxy_) {
base::PostTaskWithTraits( base::PostTask(FROM_HERE, {BrowserThread::UI},
FROM_HERE, {BrowserThread::UI}, base::BindOnce(std::move(callback), /* success= */ false,
base::BindOnce(std::move(callback), /* success= */ false, /* notification_id= */ ""));
/* notification_id= */ ""));
return; return;
} }
...@@ -824,10 +808,9 @@ void PlatformNotificationContextImpl::DoWriteNotificationData( ...@@ -824,10 +808,9 @@ void PlatformNotificationContextImpl::DoWriteNotificationData(
if (delete_status == NotificationDatabase::STATUS_ERROR_CORRUPTED) { if (delete_status == NotificationDatabase::STATUS_ERROR_CORRUPTED) {
DestroyDatabase(); DestroyDatabase();
base::PostTaskWithTraits( base::PostTask(FROM_HERE, {BrowserThread::UI},
FROM_HERE, {BrowserThread::UI}, base::BindOnce(std::move(callback), /* success= */ false,
base::BindOnce(std::move(callback), /* success= */ false, /* notification_id= */ ""));
/* notification_id= */ ""));
return; return;
} }
} }
...@@ -840,10 +823,9 @@ void PlatformNotificationContextImpl::DoWriteNotificationData( ...@@ -840,10 +823,9 @@ void PlatformNotificationContextImpl::DoWriteNotificationData(
if (CanTrigger(write_database_data) && if (CanTrigger(write_database_data) &&
!DoCheckNotificationTriggerQuota(origin)) { !DoCheckNotificationTriggerQuota(origin)) {
// TODO(knollr): Reply with a custom error so developers can handle this. // TODO(knollr): Reply with a custom error so developers can handle this.
base::PostTaskWithTraits( base::PostTask(FROM_HERE, {BrowserThread::UI},
FROM_HERE, {BrowserThread::UI}, base::BindOnce(std::move(callback), /* success= */ false,
base::BindOnce(std::move(callback), /* success= */ false, /* notification_id= */ ""));
/* notification_id= */ ""));
return; return;
} }
...@@ -866,10 +848,9 @@ void PlatformNotificationContextImpl::DoWriteNotificationData( ...@@ -866,10 +848,9 @@ void PlatformNotificationContextImpl::DoWriteNotificationData(
service_proxy_->ScheduleNotification(std::move(write_database_data)); service_proxy_->ScheduleNotification(std::move(write_database_data));
// Respond with success as this notification got scheduled successfully. // Respond with success as this notification got scheduled successfully.
base::PostTaskWithTraits( base::PostTask(FROM_HERE, {BrowserThread::UI},
FROM_HERE, {BrowserThread::UI}, base::BindOnce(std::move(callback), /* success= */ true,
base::BindOnce(std::move(callback), /* success= */ true, notification_id));
notification_id));
return; return;
} }
...@@ -885,10 +866,9 @@ void PlatformNotificationContextImpl::DoWriteNotificationData( ...@@ -885,10 +866,9 @@ void PlatformNotificationContextImpl::DoWriteNotificationData(
if (status == NotificationDatabase::STATUS_ERROR_CORRUPTED) if (status == NotificationDatabase::STATUS_ERROR_CORRUPTED)
DestroyDatabase(); DestroyDatabase();
base::PostTaskWithTraits( base::PostTask(FROM_HERE, {BrowserThread::UI},
FROM_HERE, {BrowserThread::UI}, base::BindOnce(std::move(callback), /* success= */ false,
base::BindOnce(std::move(callback), /* success= */ false, /* notification_id= */ ""));
/* notification_id= */ ""));
} }
void PlatformNotificationContextImpl::DeleteNotificationData( void PlatformNotificationContextImpl::DeleteNotificationData(
...@@ -918,8 +898,8 @@ void PlatformNotificationContextImpl::DoDeleteNotificationData( ...@@ -918,8 +898,8 @@ void PlatformNotificationContextImpl::DoDeleteNotificationData(
bool initialized) { bool initialized) {
DCHECK(task_runner_->RunsTasksInCurrentSequence()); DCHECK(task_runner_->RunsTasksInCurrentSequence());
if (!initialized) { if (!initialized) {
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI}, base::PostTask(FROM_HERE, {BrowserThread::UI},
base::BindOnce(std::move(callback), false)); base::BindOnce(std::move(callback), false));
return; return;
} }
...@@ -948,8 +928,8 @@ void PlatformNotificationContextImpl::DoDeleteNotificationData( ...@@ -948,8 +928,8 @@ void PlatformNotificationContextImpl::DoDeleteNotificationData(
success = true; success = true;
} }
base::PostTaskWithTraits(FROM_HERE, {BrowserThread::UI}, base::PostTask(FROM_HERE, {BrowserThread::UI},
base::BindOnce(std::move(callback), success)); base::BindOnce(std::move(callback), success));
} }
void PlatformNotificationContextImpl::OnRegistrationDeleted( void PlatformNotificationContextImpl::OnRegistrationDeleted(
...@@ -1009,8 +989,9 @@ void PlatformNotificationContextImpl::LazyInitialize( ...@@ -1009,8 +989,9 @@ void PlatformNotificationContextImpl::LazyInitialize(
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (!task_runner_) { if (!task_runner_) {
task_runner_ = base::CreateSequencedTaskRunnerWithTraits( task_runner_ =
{base::MayBlock(), base::TaskPriority::USER_VISIBLE}); base::CreateSequencedTaskRunner({base::ThreadPool(), base::MayBlock(),
base::TaskPriority::USER_VISIBLE});
} }
task_runner_->PostTask( task_runner_->PostTask(
......
...@@ -63,16 +63,16 @@ void PlatformNotificationServiceProxy::VerifyServiceWorkerScope( ...@@ -63,16 +63,16 @@ void PlatformNotificationServiceProxy::VerifyServiceWorkerScope(
DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (status == blink::ServiceWorkerStatusCode::kOk && if (status == blink::ServiceWorkerStatusCode::kOk &&
registration->scope().GetOrigin() == data.origin) { registration->scope().GetOrigin() == data.origin) {
base::PostTaskWithTraits( base::PostTask(
FROM_HERE, {BrowserThread::UI, base::TaskPriority::USER_VISIBLE}, FROM_HERE, {BrowserThread::UI, base::TaskPriority::USER_VISIBLE},
base::BindOnce(&PlatformNotificationServiceProxy::DoDisplayNotification, base::BindOnce(&PlatformNotificationServiceProxy::DoDisplayNotification,
AsWeakPtr(), data, registration->scope(), AsWeakPtr(), data, registration->scope(),
std::move(callback))); std::move(callback)));
} else { } else {
base::PostTaskWithTraits( base::PostTask(FROM_HERE,
FROM_HERE, {BrowserThread::UI, base::TaskPriority::USER_VISIBLE}, {BrowserThread::UI, base::TaskPriority::USER_VISIBLE},
base::BindOnce(std::move(callback), /* success= */ false, base::BindOnce(std::move(callback), /* success= */ false,
/* notification_id= */ "")); /* notification_id= */ ""));
} }
} }
...@@ -80,14 +80,14 @@ void PlatformNotificationServiceProxy::DisplayNotification( ...@@ -80,14 +80,14 @@ void PlatformNotificationServiceProxy::DisplayNotification(
const NotificationDatabaseData& data, const NotificationDatabaseData& data,
DisplayResultCallback callback) { DisplayResultCallback callback) {
if (!service_worker_context_) { if (!service_worker_context_) {
base::PostTaskWithTraits( base::PostTask(
FROM_HERE, {BrowserThread::UI, base::TaskPriority::USER_VISIBLE}, FROM_HERE, {BrowserThread::UI, base::TaskPriority::USER_VISIBLE},
base::BindOnce(&PlatformNotificationServiceProxy::DoDisplayNotification, base::BindOnce(&PlatformNotificationServiceProxy::DoDisplayNotification,
AsWeakPtr(), data, GURL(), std::move(callback))); AsWeakPtr(), data, GURL(), std::move(callback)));
return; return;
} }
base::PostTaskWithTraits( base::PostTask(
FROM_HERE, {BrowserThread::IO, base::TaskPriority::USER_VISIBLE}, FROM_HERE, {BrowserThread::IO, base::TaskPriority::USER_VISIBLE},
base::BindOnce( base::BindOnce(
&ServiceWorkerContextWrapper::FindReadyRegistrationForId, &ServiceWorkerContextWrapper::FindReadyRegistrationForId,
...@@ -102,7 +102,7 @@ void PlatformNotificationServiceProxy::CloseNotification( ...@@ -102,7 +102,7 @@ void PlatformNotificationServiceProxy::CloseNotification(
const std::string& notification_id) { const std::string& notification_id) {
if (!notification_service_) if (!notification_service_)
return; return;
base::PostTaskWithTraits( base::PostTask(
FROM_HERE, {BrowserThread::UI, base::TaskPriority::USER_VISIBLE}, FROM_HERE, {BrowserThread::UI, base::TaskPriority::USER_VISIBLE},
base::BindOnce(&PlatformNotificationServiceProxy::DoCloseNotification, base::BindOnce(&PlatformNotificationServiceProxy::DoCloseNotification,
AsWeakPtr(), notification_id)); AsWeakPtr(), notification_id));
...@@ -117,7 +117,7 @@ void PlatformNotificationServiceProxy::DoCloseNotification( ...@@ -117,7 +117,7 @@ void PlatformNotificationServiceProxy::DoCloseNotification(
void PlatformNotificationServiceProxy::ScheduleTrigger(base::Time timestamp) { void PlatformNotificationServiceProxy::ScheduleTrigger(base::Time timestamp) {
if (!notification_service_) if (!notification_service_)
return; return;
base::PostTaskWithTraits( base::PostTask(
FROM_HERE, {BrowserThread::UI, base::TaskPriority::USER_VISIBLE}, FROM_HERE, {BrowserThread::UI, base::TaskPriority::USER_VISIBLE},
base::BindOnce(&PlatformNotificationServiceProxy::DoScheduleTrigger, base::BindOnce(&PlatformNotificationServiceProxy::DoScheduleTrigger,
AsWeakPtr(), timestamp)); AsWeakPtr(), timestamp));
...@@ -133,7 +133,7 @@ void PlatformNotificationServiceProxy::ScheduleNotification( ...@@ -133,7 +133,7 @@ void PlatformNotificationServiceProxy::ScheduleNotification(
DCHECK(data.notification_data.show_trigger_timestamp.has_value()); DCHECK(data.notification_data.show_trigger_timestamp.has_value());
if (!notification_service_) if (!notification_service_)
return; return;
base::PostTaskWithTraits( base::PostTask(
FROM_HERE, {BrowserThread::UI, base::TaskPriority::USER_VISIBLE}, FROM_HERE, {BrowserThread::UI, base::TaskPriority::USER_VISIBLE},
base::BindOnce(&PlatformNotificationServiceProxy::DoScheduleNotification, base::BindOnce(&PlatformNotificationServiceProxy::DoScheduleNotification,
AsWeakPtr(), data)); AsWeakPtr(), data));
...@@ -172,10 +172,10 @@ bool PlatformNotificationServiceProxy::ShouldLogClose(const GURL& origin) { ...@@ -172,10 +172,10 @@ bool PlatformNotificationServiceProxy::ShouldLogClose(const GURL& origin) {
void PlatformNotificationServiceProxy::LogClose( void PlatformNotificationServiceProxy::LogClose(
const NotificationDatabaseData& data) { const NotificationDatabaseData& data) {
base::PostTaskWithTraits( base::PostTask(FROM_HERE,
FROM_HERE, {BrowserThread::UI, base::TaskPriority::BEST_EFFORT}, {BrowserThread::UI, base::TaskPriority::BEST_EFFORT},
base::BindOnce(&PlatformNotificationServiceProxy::DoLogClose, AsWeakPtr(), base::BindOnce(&PlatformNotificationServiceProxy::DoLogClose,
data)); AsWeakPtr(), data));
} }
void PlatformNotificationServiceProxy::DoLogClose( void PlatformNotificationServiceProxy::DoLogClose(
......
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