Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(348)

Side by Side Diff: content/browser/notifications/platform_notification_context_impl.cc

Issue 2714743002: Retrive displayed notifications asynchronously
Patch Set: apply review comments from https://codereview.chromium.org/2709213005/ Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/notifications/platform_notification_context_impl.h" 5 #include "content/browser/notifications/platform_notification_context_impl.h"
6 6
7 #include "base/bind_helpers.h" 7 #include "base/bind_helpers.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 GetContentClient()->browser()->GetPlatformNotificationService(); 212 GetContentClient()->browser()->GetPlatformNotificationService();
213 213
214 if (!service) { 214 if (!service) {
215 // Rely on the database only 215 // Rely on the database only
216 SynchronizeDisplayedNotificationsForServiceWorkerRegistration( 216 SynchronizeDisplayedNotificationsForServiceWorkerRegistration(
217 origin, service_worker_registration_id, callback, 217 origin, service_worker_registration_id, callback,
218 std::move(notification_ids), false /* sync_supported */); 218 std::move(notification_ids), false /* sync_supported */);
219 return; 219 return;
220 } 220 }
221 221
222 std::set<std::string>* notification_ids_ptr = notification_ids.get(); 222 BrowserThread::PostTask(
223
224 BrowserThread::PostTaskAndReplyWithResult(
225 BrowserThread::UI, FROM_HERE, 223 BrowserThread::UI, FROM_HERE,
226 base::Bind(&PlatformNotificationService::GetDisplayedNotifications,
227 base::Unretained(service), browser_context_,
228 notification_ids_ptr),
229 base::Bind( 224 base::Bind(
230 &PlatformNotificationContextImpl:: 225 &PlatformNotificationService::GetDisplayedNotificationsAsync,
231 SynchronizeDisplayedNotificationsForServiceWorkerRegistration, 226 base::Unretained(service), browser_context_,
232 this, origin, service_worker_registration_id, callback, 227 base::Bind(
233 base::Passed(&notification_ids))); 228 &PlatformNotificationContextImpl::
229 SynchronizeDisplayedNotificationsForServiceWorkerRegistration,
230 this, origin, service_worker_registration_id, callback)));
234 } 231 }
235 232
236 void PlatformNotificationContextImpl:: 233 void PlatformNotificationContextImpl::
237 DoReadAllNotificationDataForServiceWorkerRegistration( 234 DoReadAllNotificationDataForServiceWorkerRegistration(
238 const GURL& origin, 235 const GURL& origin,
239 int64_t service_worker_registration_id, 236 int64_t service_worker_registration_id,
240 const ReadAllResultCallback& callback, 237 const ReadAllResultCallback& callback,
241 std::unique_ptr<std::set<std::string>> displayed_notifications, 238 std::unique_ptr<std::set<std::string>> displayed_notifications,
242 bool synchronization_supported) { 239 bool synchronization_supported) {
243 DCHECK(task_runner_->RunsTasksOnCurrentThread()); 240 DCHECK(task_runner_->RunsTasksOnCurrentThread());
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 536
540 return path_.Append(kPlatformNotificationsDirectory); 537 return path_.Append(kPlatformNotificationsDirectory);
541 } 538 }
542 539
543 void PlatformNotificationContextImpl::SetTaskRunnerForTesting( 540 void PlatformNotificationContextImpl::SetTaskRunnerForTesting(
544 const scoped_refptr<base::SequencedTaskRunner>& task_runner) { 541 const scoped_refptr<base::SequencedTaskRunner>& task_runner) {
545 task_runner_ = task_runner; 542 task_runner_ = task_runner;
546 } 543 }
547 544
548 } // namespace content 545 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698