OLD | NEW |
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 int64_t service_worker_registration_id, | 98 int64_t service_worker_registration_id, |
96 const ReadAllResultCallback& callback) override; | 99 const ReadAllResultCallback& callback) override; |
97 | 100 |
98 // ServiceWorkerContextObserver implementation. | 101 // ServiceWorkerContextObserver implementation. |
99 void OnRegistrationDeleted(int64_t registration_id, | 102 void OnRegistrationDeleted(int64_t registration_id, |
100 const GURL& pattern) override; | 103 const GURL& pattern) override; |
101 void OnStorageWiped() override; | 104 void OnStorageWiped() override; |
102 | 105 |
103 private: | 106 private: |
104 friend class PlatformNotificationContextTest; | 107 friend class PlatformNotificationContextTest; |
| 108 FRIEND_TEST_ALL_PREFIXES(PlatformNotificationContextTest, |
| 109 SynchronizeNotificationsDisplayRace); |
105 | 110 |
106 ~PlatformNotificationContextImpl() override; | 111 ~PlatformNotificationContextImpl() override; |
107 | 112 |
108 void DidGetNotificationsOnUI( | 113 void DidGetNotificationsOnUI( |
109 std::unique_ptr<std::set<std::string>> displayed_notifications, | 114 std::unique_ptr<std::set<std::string>> displayed_notifications, |
110 bool supports_synchronization); | 115 bool supports_synchronization); |
111 void InitializeOnIO( | 116 void InitializeOnIO( |
112 std::unique_ptr<std::set<std::string>> displayed_notifications, | 117 std::unique_ptr<std::set<std::string>> displayed_notifications, |
113 bool supports_synchronization); | 118 bool supports_synchronization); |
114 void ShutdownOnIO(); | 119 void ShutdownOnIO(); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 base::FilePath path_; | 205 base::FilePath path_; |
201 BrowserContext* browser_context_; | 206 BrowserContext* browser_context_; |
202 | 207 |
203 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; | 208 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; |
204 | 209 |
205 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 210 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
206 std::unique_ptr<NotificationDatabase> database_; | 211 std::unique_ptr<NotificationDatabase> database_; |
207 | 212 |
208 NotificationIdGenerator notification_id_generator_; | 213 NotificationIdGenerator notification_id_generator_; |
209 | 214 |
| 215 std::unique_ptr<base::Clock> clock_; |
| 216 |
| 217 // Stores the recently displayed notification ids together with the time at |
| 218 // which they were displayed. |
| 219 std::map<std::string, base::Time> recent_notifications_; |
| 220 |
210 // Indicates whether the database should be pruned when it's opened. | 221 // Indicates whether the database should be pruned when it's opened. |
211 bool prune_database_on_open_ = false; | 222 bool prune_database_on_open_ = false; |
212 | 223 |
213 // The notification services are owned by the platform context, and will be | 224 // 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. | 225 // removed when either this class is destroyed or the Mojo pipe disconnects. |
215 std::vector<std::unique_ptr<BlinkNotificationServiceImpl>> services_; | 226 std::vector<std::unique_ptr<BlinkNotificationServiceImpl>> services_; |
216 | 227 |
217 DISALLOW_COPY_AND_ASSIGN(PlatformNotificationContextImpl); | 228 DISALLOW_COPY_AND_ASSIGN(PlatformNotificationContextImpl); |
218 }; | 229 }; |
219 | 230 |
220 } // namespace content | 231 } // namespace content |
221 | 232 |
222 #endif // CONTENT_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_CONTEXT_IMPL_H_ | 233 #endif // CONTENT_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_CONTEXT_IMPL_H_ |
OLD | NEW |