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_PUBLIC_BROWSER_PLATFORM_NOTIFICATION_CONTEXT_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_PLATFORM_NOTIFICATION_CONTEXT_H_ |
6 #define CONTENT_PUBLIC_BROWSER_PLATFORM_NOTIFICATION_CONTEXT_H_ | 6 #define CONTENT_PUBLIC_BROWSER_PLATFORM_NOTIFICATION_CONTEXT_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <vector> |
9 | 10 |
10 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "content/public/browser/notification_database_data.h" |
11 | 13 |
12 class GURL; | 14 class GURL; |
13 | 15 |
14 namespace content { | 16 namespace content { |
15 | 17 |
16 struct NotificationDatabaseData; | |
17 | |
18 // Represents the storage context for persistent Web Notifications, specific to | 18 // Represents the storage context for persistent Web Notifications, specific to |
19 // the storage partition owning the instance. All methods defined in this | 19 // the storage partition owning the instance. All methods defined in this |
20 // interface may only be used on the IO thread. | 20 // interface may only be used on the IO thread. |
21 class PlatformNotificationContext { | 21 class PlatformNotificationContext { |
22 public: | 22 public: |
23 using ReadResultCallback = | 23 using ReadResultCallback = |
24 base::Callback<void(bool /* success */, | 24 base::Callback<void(bool /* success */, |
25 const NotificationDatabaseData&)>; | 25 const NotificationDatabaseData&)>; |
26 | 26 |
| 27 using ReadAllResultCallback = |
| 28 base::Callback<void(bool /* success */, |
| 29 const std::vector<NotificationDatabaseData>&)>; |
| 30 |
27 using WriteResultCallback = | 31 using WriteResultCallback = |
28 base::Callback<void(bool /* success */, | 32 base::Callback<void(bool /* success */, |
29 int64_t /* notification_id */)>; | 33 int64_t /* notification_id */)>; |
30 | 34 |
31 using DeleteResultCallback = base::Callback<void(bool /* success */)>; | 35 using DeleteResultCallback = base::Callback<void(bool /* success */)>; |
32 | 36 |
33 // Reads the data associated with |notification_id| belonging to |origin| | 37 // Reads the data associated with |notification_id| belonging to |origin| |
34 // from the database. |callback| will be invoked with the success status | 38 // from the database. |callback| will be invoked with the success status |
35 // and a reference to the notification database data when completed. | 39 // and a reference to the notification database data when completed. |
36 virtual void ReadNotificationData(int64_t notification_id, | 40 virtual void ReadNotificationData(int64_t notification_id, |
37 const GURL& origin, | 41 const GURL& origin, |
38 const ReadResultCallback& callback) = 0; | 42 const ReadResultCallback& callback) = 0; |
39 | 43 |
| 44 // Reads all data associated with |service_worker_registration_id| belonging |
| 45 // to |origin| from the database. |callback| will be invoked with the success |
| 46 // status and a vector with all read notification data when completed. |
| 47 virtual void ReadAllNotificationDataForServiceWorkerRegistration( |
| 48 const GURL& origin, |
| 49 int64_t service_worker_registration_id, |
| 50 const ReadAllResultCallback& callback) = 0; |
| 51 |
40 // Writes the data associated with a notification to a database. When this | 52 // Writes the data associated with a notification to a database. When this |
41 // action completed, |callback| will be invoked with the success status and | 53 // action completed, |callback| will be invoked with the success status and |
42 // the persistent notification id when written successfully. | 54 // the persistent notification id when written successfully. |
43 virtual void WriteNotificationData( | 55 virtual void WriteNotificationData( |
44 const GURL& origin, | 56 const GURL& origin, |
45 const NotificationDatabaseData& database_data, | 57 const NotificationDatabaseData& database_data, |
46 const WriteResultCallback& callback) = 0; | 58 const WriteResultCallback& callback) = 0; |
47 | 59 |
48 // Deletes all data associated with |notification_id| belonging to |origin| | 60 // Deletes all data associated with |notification_id| belonging to |origin| |
49 // from the database. |callback| will be invoked with the success status | 61 // from the database. |callback| will be invoked with the success status |
50 // when the operation has completed. | 62 // when the operation has completed. |
51 virtual void DeleteNotificationData(int64_t notification_id, | 63 virtual void DeleteNotificationData(int64_t notification_id, |
52 const GURL& origin, | 64 const GURL& origin, |
53 const DeleteResultCallback& callback) = 0; | 65 const DeleteResultCallback& callback) = 0; |
54 | 66 |
55 protected: | 67 protected: |
56 virtual ~PlatformNotificationContext() {} | 68 virtual ~PlatformNotificationContext() {} |
57 }; | 69 }; |
58 | 70 |
59 } // namespace content | 71 } // namespace content |
60 | 72 |
61 #endif // CONTENT_PUBLIC_BROWSER_PLATFORM_NOTIFICATION_CONTEXT_H_ | 73 #endif // CONTENT_PUBLIC_BROWSER_PLATFORM_NOTIFICATION_CONTEXT_H_ |
OLD | NEW |