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"
11 #include "base/memory/ref_counted.h"
17 struct NotificationDatabaseData
;
19 // Represents the storage context for persistent Web Notifications, specific to
20 // the storage partition owning the instance. All methods defined in this
21 // interface may only be used on the IO thread.
22 class PlatformNotificationContext
23 : public base::RefCountedThreadSafe
<PlatformNotificationContext
> {
25 using ReadResultCallback
=
26 base::Callback
<void(bool /* success */,
27 const NotificationDatabaseData
&)>;
29 using WriteResultCallback
=
30 base::Callback
<void(bool /* success */,
31 int64_t /* notification_id */)>;
33 using DeleteResultCallback
= base::Callback
<void(bool /* success */)>;
35 // Reads the data associated with |notification_id| belonging to |origin|
36 // from the database. |callback| will be invoked with the success status
37 // and a reference to the notification database data when completed.
38 virtual void ReadNotificationData(int64_t notification_id
,
40 const ReadResultCallback
& callback
) = 0;
42 // Writes the data associated with a notification to a database. When this
43 // action completed, |callback| will be invoked with the success status and
44 // the persistent notification id when written successfully.
45 virtual void WriteNotificationData(
47 const NotificationDatabaseData
& database_data
,
48 const WriteResultCallback
& callback
) = 0;
50 // Deletes all data associated with |notification_id| belonging to |origin|
51 // from the database. |callback| will be invoked with the success status
52 // when the operation has completed.
53 virtual void DeleteNotificationData(int64_t notification_id
,
55 const DeleteResultCallback
& callback
) = 0;
58 friend class base::RefCountedThreadSafe
<PlatformNotificationContext
>;
60 virtual ~PlatformNotificationContext() {}
63 } // namespace content
65 #endif // CONTENT_PUBLIC_BROWSER_PLATFORM_NOTIFICATION_CONTEXT_H_