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> |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 // ServiceWorkerContextObserver implementation. | 94 // ServiceWorkerContextObserver implementation. |
95 void OnRegistrationDeleted(int64_t registration_id, | 95 void OnRegistrationDeleted(int64_t registration_id, |
96 const GURL& pattern) override; | 96 const GURL& pattern) override; |
97 void OnStorageWiped() override; | 97 void OnStorageWiped() override; |
98 | 98 |
99 private: | 99 private: |
100 friend class PlatformNotificationContextTest; | 100 friend class PlatformNotificationContextTest; |
101 | 101 |
102 ~PlatformNotificationContextImpl() override; | 102 ~PlatformNotificationContextImpl() override; |
103 | 103 |
104 void InitializeOnIO(); | 104 void DidGetNotificationsOnUI( |
105 std::unique_ptr<std::set<std::string>> displayed_notifications, | |
106 bool notification_synchronization_supported); | |
107 void InitializeOnIO( | |
108 std::unique_ptr<std::set<std::string>> displayed_notifications, | |
109 bool notification_synchronization_supported); | |
105 void ShutdownOnIO(); | 110 void ShutdownOnIO(); |
106 void CreateServiceOnIO( | 111 void CreateServiceOnIO( |
107 int render_process_id, | 112 int render_process_id, |
108 ResourceContext* resource_context, | 113 ResourceContext* resource_context, |
109 mojo::InterfaceRequest<blink::mojom::NotificationService> request); | 114 mojo::InterfaceRequest<blink::mojom::NotificationService> request); |
110 | 115 |
111 // Initializes the database if neccesary. Must be called on the IO thread. | 116 // Initializes the database if neccesary. Must be called on the IO thread. |
112 // |success_closure| will be invoked on a the |task_runner_| thread when | 117 // |success_closure| will be invoked on a the |task_runner_| thread when |
113 // everything is available, or |failure_closure_| will be invoked on the | 118 // everything is available, or |failure_closure_| will be invoked on the |
114 // IO thread when initialization fails. | 119 // IO thread when initialization fails. |
115 void LazyInitialize(const base::Closure& success_closure, | 120 void LazyInitialize(const base::Closure& success_closure, |
116 const base::Closure& failure_closure); | 121 const base::Closure& failure_closure); |
117 | 122 |
118 // Opens the database. Must be called on the |task_runner_| thread. When the | 123 // Opens the database. Must be called on the |task_runner_| thread. When the |
119 // database has been opened, |success_closure| will be invoked on the task | 124 // database has been opened, |success_closure| will be invoked on the task |
120 // thread, otherwise |failure_closure_| will be invoked on the IO thread. | 125 // thread, otherwise |failure_closure_| will be invoked on the IO thread. |
121 void OpenDatabase(const base::Closure& success_closure, | 126 void OpenDatabase(const base::Closure& success_closure, |
122 const base::Closure& failure_closure); | 127 const base::Closure& failure_closure); |
123 | 128 |
124 // Actually reads the notification data from the database. Must only be | 129 // Actually reads the notification data from the database. Must only be |
125 // called on the |task_runner_| thread. |callback| will be invoked on the | 130 // called on the |task_runner_| thread. |callback| will be invoked on the |
126 // IO thread when the operation has completed. | 131 // IO thread when the operation has completed. |
127 void DoReadNotificationData(const std::string& notification_id, | 132 void DoReadNotificationData(const std::string& notification_id, |
128 const GURL& origin, | 133 const GURL& origin, |
129 const ReadResultCallback& callback); | 134 const ReadResultCallback& callback); |
130 | 135 |
131 // Updates the database (and the result callback) based on | 136 // Updates the database (and the result callback) based on |
132 // |displayed_notifications| | 137 // |displayed_notifications| |
133 // if |sync_supported|. Called on the IO thread. | 138 // if |sync_supported|. |
134 void SynchronizeDisplayedNotificationsForServiceWorkerRegistration( | 139 void SynchronizeDisplayedNotificationsForServiceWorkerRegistrationOnUI( |
135 const GURL& origin, | 140 const GURL& origin, |
136 int64_t service_worker_registration_id, | 141 int64_t service_worker_registration_id, |
137 const ReadAllResultCallback& callback, | 142 const ReadAllResultCallback& callback, |
143 std::unique_ptr<std::set<std::string>> displayed_notifications, | |
144 bool sync_supported); | |
145 | |
146 // Updates the database (and the result callback) based on | |
147 // |displayed_notifications| | |
148 // if |sync_supported|. | |
Peter Beverloo
2017/03/17 15:46:04
nit: fix weird line break (also on line 137)
Miguel Garcia
2017/03/20 14:11:21
Done.
| |
149 void SynchronizeDisplayedNotificationsForServiceWorkerRegistrationOnIO( | |
150 const GURL& origin, | |
151 int64_t service_worker_registration_id, | |
152 const ReadAllResultCallback& callback, | |
138 std::unique_ptr<std::set<std::string>> displayed_notifications, | 153 std::unique_ptr<std::set<std::string>> displayed_notifications, |
139 bool sync_supported); | 154 bool sync_supported); |
140 | 155 |
141 // Actually reads all notification data from the database. Must only be | 156 // Actually reads all notification data from the database. Must only be |
142 // called on the |task_runner_| thread. |callback| will be invoked on the | 157 // called on the |task_runner_| thread. |callback| will be invoked on the |
143 // IO thread when the operation has completed. | 158 // IO thread when the operation has completed. |
144 void DoReadAllNotificationDataForServiceWorkerRegistration( | 159 void DoReadAllNotificationDataForServiceWorkerRegistration( |
145 const GURL& origin, | 160 const GURL& origin, |
146 int64_t service_worker_registration_id, | 161 int64_t service_worker_registration_id, |
147 const ReadAllResultCallback& callback, | 162 const ReadAllResultCallback& callback, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
196 // The notification services are owned by the platform context, and will be | 211 // The notification services are owned by the platform context, and will be |
197 // removed when either this class is destroyed or the Mojo pipe disconnects. | 212 // removed when either this class is destroyed or the Mojo pipe disconnects. |
198 std::vector<std::unique_ptr<BlinkNotificationServiceImpl>> services_; | 213 std::vector<std::unique_ptr<BlinkNotificationServiceImpl>> services_; |
199 | 214 |
200 DISALLOW_COPY_AND_ASSIGN(PlatformNotificationContextImpl); | 215 DISALLOW_COPY_AND_ASSIGN(PlatformNotificationContextImpl); |
201 }; | 216 }; |
202 | 217 |
203 } // namespace content | 218 } // namespace content |
204 | 219 |
205 #endif // CONTENT_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_CONTEXT_IMPL_H_ | 220 #endif // CONTENT_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_CONTEXT_IMPL_H_ |
OLD | NEW |