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

Unified Diff: chrome/browser/notifications/message_center_display_service.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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/notifications/message_center_display_service.cc
diff --git a/chrome/browser/notifications/message_center_display_service.cc b/chrome/browser/notifications/message_center_display_service.cc
index 4ff6195539679db6630ccdf322ab00255048b322..8041092eea15db09ff5ecd405160c7d3cb4df00f 100644
--- a/chrome/browser/notifications/message_center_display_service.cc
+++ b/chrome/browser/notifications/message_center_display_service.cc
@@ -2,11 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <set>
+#include <string>
+
#include "chrome/browser/notifications/message_center_display_service.h"
#include "chrome/browser/notifications/notification.h"
#include "chrome/browser/notifications/notification_ui_manager.h"
#include "chrome/browser/profiles/profile.h"
+#include "content/public/browser/browser_thread.h"
MessageCenterDisplayService::MessageCenterDisplayService(
Profile* profile,
@@ -32,12 +36,14 @@ void MessageCenterDisplayService::Close(
NotificationUIManager::GetProfileID(profile_));
}
-bool MessageCenterDisplayService::GetDisplayed(
- std::set<std::string>* notifications) const {
- DCHECK(notifications);
- for (auto notification_id : ui_manager_->GetAllIdsByProfile(
- NotificationUIManager::GetProfileID(profile_))) {
- notifications->insert(notification_id);
- }
- return true;
+void MessageCenterDisplayService::GetDisplayed(
+ const DisplayedNotificationsCallback& callback) const {
+ auto displayed_notifications =
+ base::MakeUnique<std::set<std::string>>(ui_manager_->GetAllIdsByProfile(
+ NotificationUIManager::GetProfileID(profile_)));
+
+ content::BrowserThread::PostTask(
+ content::BrowserThread::UI, FROM_HERE,
+ base::Bind(callback, base::Passed(&displayed_notifications),
+ true /* supports_synchronization */));
}

Powered by Google App Engine
This is Rietveld 408576698