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

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

Issue 2749453002: Make GetDisplayedNotifications asynchronous. (Closed)
Patch Set: - 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/message_center_display_service.h" 5 #include "chrome/browser/notifications/message_center_display_service.h"
6 6
7 #include "chrome/browser/notifications/notification.h" 7 #include "chrome/browser/notifications/notification.h"
8 #include "chrome/browser/notifications/notification_ui_manager.h" 8 #include "chrome/browser/notifications/notification_ui_manager.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "content/public/browser/browser_thread.h"
10 11
11 MessageCenterDisplayService::MessageCenterDisplayService( 12 MessageCenterDisplayService::MessageCenterDisplayService(
12 Profile* profile, 13 Profile* profile,
13 NotificationUIManager* ui_manager) 14 NotificationUIManager* ui_manager)
14 : profile_(profile), ui_manager_(ui_manager) {} 15 : profile_(profile), ui_manager_(ui_manager) {}
15 16
16 MessageCenterDisplayService::~MessageCenterDisplayService() {} 17 MessageCenterDisplayService::~MessageCenterDisplayService() {}
17 18
18 void MessageCenterDisplayService::Display( 19 void MessageCenterDisplayService::Display(
19 NotificationCommon::Type notification_type, 20 NotificationCommon::Type notification_type,
20 const std::string& notification_id, 21 const std::string& notification_id,
21 const Notification& notification) { 22 const Notification& notification) {
22 // TODO(miguelg): MCDS should stop relying on the |notification|'s delegate 23 // TODO(miguelg): MCDS should stop relying on the |notification|'s delegate
23 // for Close/Click operations once the Notification object becomes a mojom 24 // for Close/Click operations once the Notification object becomes a mojom
24 // type. 25 // type.
25 ui_manager_->Add(notification, profile_); 26 ui_manager_->Add(notification, profile_);
26 } 27 }
27 28
28 void MessageCenterDisplayService::Close( 29 void MessageCenterDisplayService::Close(
29 NotificationCommon::Type notification_type, 30 NotificationCommon::Type notification_type,
30 const std::string& notification_id) { 31 const std::string& notification_id) {
31 ui_manager_->CancelById(notification_id, 32 ui_manager_->CancelById(notification_id,
32 NotificationUIManager::GetProfileID(profile_)); 33 NotificationUIManager::GetProfileID(profile_));
33 } 34 }
34 35
35 bool MessageCenterDisplayService::GetDisplayed( 36 void MessageCenterDisplayService::GetDisplayed(
36 std::set<std::string>* notifications) const { 37 const NotificationResultCallback& callback) const {
37 DCHECK(notifications); 38 std::unique_ptr<std::set<std::string>> displayed_notifications =
39 base::MakeUnique<std::set<std::string>>();
Peter Beverloo 2017/03/15 18:07:50 note: I think `auto` is a reasonable thing for thi
Miguel Garcia 2017/03/16 14:57:42 Done.
38 for (auto notification_id : ui_manager_->GetAllIdsByProfile( 40 for (auto notification_id : ui_manager_->GetAllIdsByProfile(
39 NotificationUIManager::GetProfileID(profile_))) { 41 NotificationUIManager::GetProfileID(profile_))) {
40 notifications->insert(notification_id); 42 displayed_notifications->insert(notification_id);
41 } 43 }
42 return true; 44 content::BrowserThread::PostTask(
45 content::BrowserThread::UI, FROM_HERE,
46 base::Bind(callback, base::Passed(&displayed_notifications),
47 true /* supports sync */));
43 } 48 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698