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_
10 #include "base/callback.h"
16 struct NotificationDatabaseData
;
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 WriteResultCallback
=
28 base::Callback
<void(bool /* success */,
29 int64_t /* notification_id */)>;
31 using DeleteResultCallback
= base::Callback
<void(bool /* success */)>;
33 // Reads the data associated with |notification_id| belonging to |origin|
34 // from the database. |callback| will be invoked with the success status
35 // and a reference to the notification database data when completed.
36 virtual void ReadNotificationData(int64_t notification_id
,
38 const ReadResultCallback
& callback
) = 0;
40 // Writes the data associated with a notification to a database. When this
41 // action completed, |callback| will be invoked with the success status and
42 // the persistent notification id when written successfully.
43 virtual void WriteNotificationData(
45 const NotificationDatabaseData
& database_data
,
46 const WriteResultCallback
& callback
) = 0;
48 // Deletes all data associated with |notification_id| belonging to |origin|
49 // from the database. |callback| will be invoked with the success status
50 // when the operation has completed.
51 virtual void DeleteNotificationData(int64_t notification_id
,
53 const DeleteResultCallback
& callback
) = 0;
56 virtual ~PlatformNotificationContext() {}
59 } // namespace content
61 #endif // CONTENT_PUBLIC_BROWSER_PLATFORM_NOTIFICATION_CONTEXT_H_