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

Unified Diff: chrome/browser/notifications/stub_notification_platform_bridge.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/stub_notification_platform_bridge.cc
diff --git a/chrome/browser/notifications/stub_notification_platform_bridge.cc b/chrome/browser/notifications/stub_notification_platform_bridge.cc
index 13ebe20db4cd5cbb00bb91da2460a97bfea1994e..c07ae20a2e5ef8b582b48b3cc5343d50f500c8b7 100644
--- a/chrome/browser/notifications/stub_notification_platform_bridge.cc
+++ b/chrome/browser/notifications/stub_notification_platform_bridge.cc
@@ -4,6 +4,9 @@
#include "chrome/browser/notifications/stub_notification_platform_bridge.h"
+#include "base/memory/ptr_util.h"
+#include "content/public/browser/browser_thread.h"
+
StubNotificationPlatformBridge::StubNotificationPlatformBridge()
: NotificationPlatformBridge() {}
@@ -18,6 +21,14 @@ Notification StubNotificationPlatformBridge::GetNotificationAt(
return notifications_[profile_id][index];
}
+size_t StubNotificationPlatformBridge::GetNotificationCount() {
+ int count = 0;
+ for (const auto& pair : notifications_) {
+ count += pair.second.size();
+ }
+ return count;
+}
+
void StubNotificationPlatformBridge::Display(
NotificationCommon::Type notification_type,
const std::string& notification_id,
@@ -43,16 +54,21 @@ void StubNotificationPlatformBridge::Close(const std::string& profile_id,
}
}
-bool StubNotificationPlatformBridge::GetDisplayed(
+void StubNotificationPlatformBridge::GetDisplayed(
const std::string& profile_id,
bool incognito,
- std::set<std::string>* notifications) const {
- if (notifications_.find(profile_id) == notifications_.end())
- return true;
+ const DisplayedNotificationsCallback& callback) const {
+ auto displayed_notifications = base::MakeUnique<std::set<std::string>>();
+
+ if (notifications_.find(profile_id) != notifications_.end()) {
+ const std::vector<Notification>& profile_notifications =
+ notifications_.at(profile_id);
+ for (auto notification : profile_notifications)
+ displayed_notifications->insert(notification.id());
+ }
- const std::vector<Notification>& profile_notifications =
- notifications_.at(profile_id);
- for (auto notification : profile_notifications)
- notifications->insert(notification.id());
- return true;
+ 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