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

Side by Side Diff: chrome/browser/notifications/platform_notification_service_impl.cc

Issue 2749453002: Make GetDisplayedNotifications asynchronous. (Closed)
Patch Set: review 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/notifications/platform_notification_service_impl.h" 5 #include "chrome/browser/notifications/platform_notification_service_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 372
373 Profile* profile = Profile::FromBrowserContext(browser_context); 373 Profile* profile = Profile::FromBrowserContext(browser_context);
374 DCHECK(profile); 374 DCHECK(profile);
375 375
376 closed_notifications_.insert(notification_id); 376 closed_notifications_.insert(notification_id);
377 377
378 GetNotificationDisplayService(profile)->Close(NotificationCommon::PERSISTENT, 378 GetNotificationDisplayService(profile)->Close(NotificationCommon::PERSISTENT,
379 notification_id); 379 notification_id);
380 } 380 }
381 381
382 bool PlatformNotificationServiceImpl::GetDisplayedNotifications( 382 void PlatformNotificationServiceImpl::GetDisplayedNotifications(
383 BrowserContext* browser_context, 383 BrowserContext* browser_context,
384 std::set<std::string>* displayed_notifications) { 384 const DisplayedNotificationsCallback& callback) {
385 DCHECK(displayed_notifications);
386 DCHECK_CURRENTLY_ON(BrowserThread::UI); 385 DCHECK_CURRENTLY_ON(BrowserThread::UI);
387 386
388 Profile* profile = Profile::FromBrowserContext(browser_context); 387 Profile* profile = Profile::FromBrowserContext(browser_context);
389 if (!profile || profile->AsTestingProfile()) 388 // Tests will not have a message center.
390 return false; // Tests will not have a message center. 389 if (!profile || profile->AsTestingProfile()) {
391 390 auto displayed_notifications = base::MakeUnique<std::set<std::string>>();
392 return GetNotificationDisplayService(profile)->GetDisplayed( 391 callback.Run(std::move(displayed_notifications),
393 displayed_notifications); 392 false /* supports_synchronization */);
393 return;
394 }
395 GetNotificationDisplayService(profile)->GetDisplayed(callback);
394 } 396 }
395 397
396 void PlatformNotificationServiceImpl::OnClickEventDispatchComplete( 398 void PlatformNotificationServiceImpl::OnClickEventDispatchComplete(
397 content::PersistentNotificationStatus status) { 399 content::PersistentNotificationStatus status) {
398 UMA_HISTOGRAM_ENUMERATION( 400 UMA_HISTOGRAM_ENUMERATION(
399 "Notifications.PersistentWebNotificationClickResult", status, 401 "Notifications.PersistentWebNotificationClickResult", status,
400 content::PersistentNotificationStatus:: 402 content::PersistentNotificationStatus::
401 PERSISTENT_NOTIFICATION_STATUS_MAX); 403 PERSISTENT_NOTIFICATION_STATUS_MAX);
402 #if BUILDFLAG(ENABLE_BACKGROUND) 404 #if BUILDFLAG(ENABLE_BACKGROUND)
403 DCHECK_GT(pending_click_dispatch_events_, 0); 405 DCHECK_GT(pending_click_dispatch_events_, 0);
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 } 524 }
523 #endif 525 #endif
524 526
525 return base::string16(); 527 return base::string16();
526 } 528 }
527 529
528 void PlatformNotificationServiceImpl::SetNotificationDisplayServiceForTesting( 530 void PlatformNotificationServiceImpl::SetNotificationDisplayServiceForTesting(
529 NotificationDisplayService* display_service) { 531 NotificationDisplayService* display_service) {
530 test_display_service_ = display_service; 532 test_display_service_ = display_service;
531 } 533 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698