Re-subimission of https://codereview.chromium.org/1041213003/
[chromium-blink-merge.git] / content / public / browser / platform_notification_context.h
blob660ff19d018b5d43af7851f9bfc45878c91065ea
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_
8 #include <stdint.h>
10 #include "base/callback.h"
12 class GURL;
14 namespace content {
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 {
22 public:
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,
37 const GURL& origin,
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(
44 const GURL& origin,
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,
52 const GURL& origin,
53 const DeleteResultCallback& callback) = 0;
55 protected:
56 virtual ~PlatformNotificationContext() {}
59 } // namespace content
61 #endif // CONTENT_PUBLIC_BROWSER_PLATFORM_NOTIFICATION_CONTEXT_H_