| 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 supports_synchronization); |
| 107 void InitializeOnIO( |
| 108 std::unique_ptr<std::set<std::string>> displayed_notifications, |
| 109 bool supports_synchronization); |
| 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| if |supports_synchronization|. |
| 133 // if |sync_supported|. Called on the IO thread. | 138 void SynchronizeDisplayedNotificationsForServiceWorkerRegistrationOnUI( |
| 134 void SynchronizeDisplayedNotificationsForServiceWorkerRegistration( | |
| 135 const GURL& origin, | 139 const GURL& origin, |
| 136 int64_t service_worker_registration_id, | 140 int64_t service_worker_registration_id, |
| 137 const ReadAllResultCallback& callback, | 141 const ReadAllResultCallback& callback, |
| 138 std::unique_ptr<std::set<std::string>> displayed_notifications, | 142 std::unique_ptr<std::set<std::string>> displayed_notifications, |
| 139 bool sync_supported); | 143 bool supports_synchronization); |
| 144 |
| 145 // Updates the database (and the result callback) based on |
| 146 // |displayed_notifications| if |supports_synchronization|. |
| 147 void SynchronizeDisplayedNotificationsForServiceWorkerRegistrationOnIO( |
| 148 const GURL& origin, |
| 149 int64_t service_worker_registration_id, |
| 150 const ReadAllResultCallback& callback, |
| 151 std::unique_ptr<std::set<std::string>> displayed_notifications, |
| 152 bool supports_synchronization); |
| 140 | 153 |
| 141 // Actually reads all notification data from the database. Must only be | 154 // Actually reads all notification data from the database. Must only be |
| 142 // called on the |task_runner_| thread. |callback| will be invoked on the | 155 // called on the |task_runner_| thread. |callback| will be invoked on the |
| 143 // IO thread when the operation has completed. | 156 // IO thread when the operation has completed. |
| 144 void DoReadAllNotificationDataForServiceWorkerRegistration( | 157 void DoReadAllNotificationDataForServiceWorkerRegistration( |
| 145 const GURL& origin, | 158 const GURL& origin, |
| 146 int64_t service_worker_registration_id, | 159 int64_t service_worker_registration_id, |
| 147 const ReadAllResultCallback& callback, | 160 const ReadAllResultCallback& callback, |
| 148 std::unique_ptr<std::set<std::string>> displayed_notifications, | 161 std::unique_ptr<std::set<std::string>> displayed_notifications, |
| 149 bool synchronization_supported); | 162 bool supports_synchronization); |
| 150 | 163 |
| 151 // Actually writes the notification database to the database. Must only be | 164 // Actually writes the notification database to the database. Must only be |
| 152 // called on the |task_runner_| thread. |callback| will be invoked on the | 165 // called on the |task_runner_| thread. |callback| will be invoked on the |
| 153 // IO thread when the operation has completed. | 166 // IO thread when the operation has completed. |
| 154 void DoWriteNotificationData(const GURL& origin, | 167 void DoWriteNotificationData(const GURL& origin, |
| 155 const NotificationDatabaseData& database_data, | 168 const NotificationDatabaseData& database_data, |
| 156 const WriteResultCallback& callback); | 169 const WriteResultCallback& callback); |
| 157 | 170 |
| 158 // Actually deletes the notification information from the database. Must only | 171 // Actually deletes the notification information from the database. Must only |
| 159 // be called on the |task_runner_| thread. |callback| will be invoked on the | 172 // be called on the |task_runner_| thread. |callback| will be invoked on the |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 // The notification services are owned by the platform context, and will be | 209 // 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. | 210 // removed when either this class is destroyed or the Mojo pipe disconnects. |
| 198 std::vector<std::unique_ptr<BlinkNotificationServiceImpl>> services_; | 211 std::vector<std::unique_ptr<BlinkNotificationServiceImpl>> services_; |
| 199 | 212 |
| 200 DISALLOW_COPY_AND_ASSIGN(PlatformNotificationContextImpl); | 213 DISALLOW_COPY_AND_ASSIGN(PlatformNotificationContextImpl); |
| 201 }; | 214 }; |
| 202 | 215 |
| 203 } // namespace content | 216 } // namespace content |
| 204 | 217 |
| 205 #endif // CONTENT_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_CONTEXT_IMPL_H_ | 218 #endif // CONTENT_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_CONTEXT_IMPL_H_ |
| OLD | NEW |