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

Side by Side Diff: content/browser/notifications/platform_notification_context_impl.h

Issue 2878443002: Address a race condition in displaying notifications
Patch Set: Address a race condition in displaying notifications Created 3 years, 7 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #ifndef CONTENT_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_CONTEXT_IMPL_H_ 5 #ifndef CONTENT_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_CONTEXT_IMPL_H_
6 #define CONTENT_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_CONTEXT_IMPL_H_ 6 #define CONTENT_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_CONTEXT_IMPL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <memory> 9 #include <memory>
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 #include <utility>
12 #include <vector> 13 #include <vector>
13 14
14 #include "base/callback.h" 15 #include "base/callback.h"
15 #include "base/compiler_specific.h" 16 #include "base/compiler_specific.h"
16 #include "base/files/file_path.h" 17 #include "base/files/file_path.h"
17 #include "base/macros.h" 18 #include "base/macros.h"
18 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
20 #include "base/time/time.h"
19 #include "content/browser/notifications/notification_id_generator.h" 21 #include "content/browser/notifications/notification_id_generator.h"
20 #include "content/browser/service_worker/service_worker_context_observer.h" 22 #include "content/browser/service_worker/service_worker_context_observer.h"
21 #include "content/common/content_export.h" 23 #include "content/common/content_export.h"
22 #include "content/public/browser/browser_thread.h" 24 #include "content/public/browser/browser_thread.h"
23 #include "content/public/browser/platform_notification_context.h" 25 #include "content/public/browser/platform_notification_context.h"
24 #include "third_party/WebKit/public/platform/modules/notifications/notification_ service.mojom.h" 26 #include "third_party/WebKit/public/platform/modules/notifications/notification_ service.mojom.h"
25 27
26 class GURL; 28 class GURL;
27 29
28 namespace base { 30 namespace base {
31 class Clock;
29 class SequencedTaskRunner; 32 class SequencedTaskRunner;
30 } 33 }
31 34
32 namespace service_manager { 35 namespace service_manager {
33 struct BindSourceInfo; 36 struct BindSourceInfo;
34 } 37 }
35 38
36 namespace content { 39 namespace content {
37 40
38 class BlinkNotificationServiceImpl; 41 class BlinkNotificationServiceImpl;
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 base::FilePath path_; 203 base::FilePath path_;
201 BrowserContext* browser_context_; 204 BrowserContext* browser_context_;
202 205
203 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; 206 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_;
204 207
205 scoped_refptr<base::SequencedTaskRunner> task_runner_; 208 scoped_refptr<base::SequencedTaskRunner> task_runner_;
206 std::unique_ptr<NotificationDatabase> database_; 209 std::unique_ptr<NotificationDatabase> database_;
207 210
208 NotificationIdGenerator notification_id_generator_; 211 NotificationIdGenerator notification_id_generator_;
209 212
213 std::unique_ptr<base::Clock> clock_;
214
215 // Stores the recently displayed notification ids together with the time at
216 // which they were displayed.
217 std::map<std::string, base::Time> recent_notifications_;
218
210 // Indicates whether the database should be pruned when it's opened. 219 // Indicates whether the database should be pruned when it's opened.
211 bool prune_database_on_open_ = false; 220 bool prune_database_on_open_ = false;
212 221
213 // The notification services are owned by the platform context, and will be 222 // The notification services are owned by the platform context, and will be
214 // removed when either this class is destroyed or the Mojo pipe disconnects. 223 // removed when either this class is destroyed or the Mojo pipe disconnects.
215 std::vector<std::unique_ptr<BlinkNotificationServiceImpl>> services_; 224 std::vector<std::unique_ptr<BlinkNotificationServiceImpl>> services_;
216 225
217 DISALLOW_COPY_AND_ASSIGN(PlatformNotificationContextImpl); 226 DISALLOW_COPY_AND_ASSIGN(PlatformNotificationContextImpl);
218 }; 227 };
219 228
220 } // namespace content 229 } // namespace content
221 230
222 #endif // CONTENT_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_CONTEXT_IMPL_H_ 231 #endif // CONTENT_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_CONTEXT_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698