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

Side by Side Diff: content/test/mock_platform_notification_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 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 "content/test/mock_platform_notification_service.h" 5 #include "content/test/mock_platform_notification_service.h"
6 6
7 #include "base/guid.h" 7 #include "base/guid.h"
8 #include "base/strings/nullable_string16.h" 8 #include "base/strings/nullable_string16.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 } 73 }
74 74
75 void MockPlatformNotificationService::ClosePersistentNotification( 75 void MockPlatformNotificationService::ClosePersistentNotification(
76 BrowserContext* browser_context, 76 BrowserContext* browser_context,
77 const std::string& notification_id) { 77 const std::string& notification_id) {
78 DCHECK_CURRENTLY_ON(BrowserThread::UI); 78 DCHECK_CURRENTLY_ON(BrowserThread::UI);
79 79
80 persistent_notifications_.erase(notification_id); 80 persistent_notifications_.erase(notification_id);
81 } 81 }
82 82
83 bool MockPlatformNotificationService::GetDisplayedNotifications( 83 void MockPlatformNotificationService::GetDisplayedNotifications(
84 BrowserContext* browser_context, 84 BrowserContext* browser_context,
85 std::set<std::string>* displayed_notifications) { 85 const base::Callback<void(std::unique_ptr<std::set<std::string>>,
86 bool /* supports synchronization */)>& callback) {
Peter Beverloo 2017/03/15 18:07:51 dito
Miguel Garcia 2017/03/16 14:57:43 Done.
86 DCHECK_CURRENTLY_ON(BrowserThread::UI); 87 DCHECK_CURRENTLY_ON(BrowserThread::UI);
87 DCHECK(displayed_notifications); 88 std::unique_ptr<std::set<std::string>> displayed_notifications =
89 base::MakeUnique<std::set<std::string>>();
88 90
89 for (const auto& kv : persistent_notifications_) 91 for (const auto& kv : persistent_notifications_)
90 displayed_notifications->insert(kv.first); 92 displayed_notifications->insert(kv.first);
91 93
92 return true; 94 content::BrowserThread::PostTask(
95 content::BrowserThread::UI, FROM_HERE,
Peter Beverloo 2017/03/15 18:07:51 nit: same, drop content::
Miguel Garcia 2017/03/16 14:57:43 Done.
96 base::Bind(callback, base::Passed(&displayed_notifications),
97 true /* supports synchronization */));
93 } 98 }
94 99
95 void MockPlatformNotificationService::SimulateClick( 100 void MockPlatformNotificationService::SimulateClick(
96 const std::string& title, 101 const std::string& title,
97 int action_index, 102 int action_index,
98 const base::NullableString16& reply) { 103 const base::NullableString16& reply) {
99 DCHECK_CURRENTLY_ON(BrowserThread::UI); 104 DCHECK_CURRENTLY_ON(BrowserThread::UI);
100 105
101 const auto notification_id_iter = notification_id_map_.find(title); 106 const auto notification_id_iter = notification_id_map_.find(title);
102 if (notification_id_iter == notification_id_map_.end()) 107 if (notification_id_iter == notification_id_map_.end())
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 non_persistent_notifications_.erase(non_persistent_iter); 192 non_persistent_notifications_.erase(non_persistent_iter);
188 } 193 }
189 } 194 }
190 195
191 blink::mojom::PermissionStatus MockPlatformNotificationService::CheckPermission( 196 blink::mojom::PermissionStatus MockPlatformNotificationService::CheckPermission(
192 const GURL& origin) { 197 const GURL& origin) {
193 return blink::mojom::PermissionStatus::GRANTED; 198 return blink::mojom::PermissionStatus::GRANTED;
194 } 199 }
195 200
196 } // namespace content 201 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698