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
3 // found in the LICENSE file.
5 #ifndef CONTENT_PUBLIC_BROWSER_PLATFORM_NOTIFICATION_CONTEXT_H_
6 #define CONTENT_PUBLIC_BROWSER_PLATFORM_NOTIFICATION_CONTEXT_H_
11 #include "base/callback.h"
12 #include "content/public/browser/notification_database_data.h"
18 // Represents the storage context for persistent Web Notifications, specific to
19 // the storage partition owning the instance. All methods defined in this
20 // interface may only be used on the IO thread.
21 class PlatformNotificationContext
{
23 using ReadResultCallback
=
24 base::Callback
<void(bool /* success */,
25 const NotificationDatabaseData
&)>;
27 using ReadAllResultCallback
=
28 base::Callback
<void(bool /* success */,
29 const std::vector
<NotificationDatabaseData
>&)>;
31 using WriteResultCallback
=
32 base::Callback
<void(bool /* success */,
33 int64_t /* notification_id */)>;
35 using DeleteResultCallback
= base::Callback
<void(bool /* success */)>;
37 // Reads the data associated with |notification_id| belonging to |origin|
38 // from the database. |callback| will be invoked with the success status
39 // and a reference to the notification database data when completed.
40 virtual void ReadNotificationData(int64_t notification_id
,
42 const ReadResultCallback
& callback
) = 0;
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(
49 int64_t service_worker_registration_id
,
50 const ReadAllResultCallback
& callback
) = 0;
52 // Writes the data associated with a notification to a database. When this
53 // action completed, |callback| will be invoked with the success status and
54 // the persistent notification id when written successfully.
55 virtual void WriteNotificationData(
57 const NotificationDatabaseData
& database_data
,
58 const WriteResultCallback
& callback
) = 0;
60 // Deletes all data associated with |notification_id| belonging to |origin|
61 // from the database. |callback| will be invoked with the success status
62 // when the operation has completed.
63 virtual void DeleteNotificationData(int64_t notification_id
,
65 const DeleteResultCallback
& callback
) = 0;
68 virtual ~PlatformNotificationContext() {}
71 } // namespace content
73 #endif // CONTENT_PUBLIC_BROWSER_PLATFORM_NOTIFICATION_CONTEXT_H_