Index: content/browser/notifications/notification_database.h |
diff --git a/content/browser/notifications/notification_database.h b/content/browser/notifications/notification_database.h |
index 85b855a0bd56dd433f9d661edaa0ec22bfb24e64..1acfe6b01a9e06fcfab202af85cb65504c3e8419 100644 |
--- a/content/browser/notifications/notification_database.h |
+++ b/content/browser/notifications/notification_database.h |
@@ -12,6 +12,8 @@ |
#include "base/sequence_checker.h" |
#include "content/common/content_export.h" |
+class GURL; |
+ |
namespace leveldb { |
class DB; |
class Env; |
@@ -20,6 +22,8 @@ class WriteBatch; |
namespace content { |
+struct NotificationDatabaseData; |
+ |
// Implementation of the persistent notification database. |
// |
// This class can be constructed on any thread, but method calls must only be |
@@ -32,8 +36,8 @@ class CONTENT_EXPORT NotificationDatabase { |
enum Status { |
STATUS_OK = 0, |
- // The database, or the key associated with the operation, could not be |
- // found. |
+ // The database, a notification, or a LevelDB key associated with the |
+ // operation could not be found. |
STATUS_ERROR_NOT_FOUND = 1, |
// The database, or data in the database, could not be parsed as valid data. |
@@ -52,9 +56,26 @@ class CONTENT_EXPORT NotificationDatabase { |
// |create_if_missing| determines whether to create the database if necessary. |
Status Open(bool create_if_missing); |
- // Returns whether the next available notification id could be read, and |
- // stores the id in |notification_id| if the read was successful. |
- Status GetNextNotificationId(int64_t* notification_id) const; |
+ // Reads the notification data for the notification identified by |
+ // |notification_id| and belonging to |origin| from the database, and stores |
+ // it in |notification_database_data|. Returns the status code. |
+ Status ReadNotificationData( |
+ int64_t notification_id, |
+ const GURL& origin, |
+ NotificationDatabaseData* notification_database_data) const; |
+ |
+ // Writes the |notification_database_data| for a new notification belonging to |
+ // |origin| to the database, and returns the status code of the writing |
+ // operation. The id of the new notification will be set in |notification_id|. |
+ Status WriteNotificationData( |
+ const GURL& origin, |
+ const NotificationDatabaseData& notification_database_data, |
+ int64_t* notification_id); |
+ |
+ // Deletes all data associated with the notification identified by |
+ // |notification_id| belonging to |origin| from the database. Returns the |
+ // status code of the deletion operation. |
+ Status DeleteNotificationData(int64_t notification_id, const GURL& origin); |
// Completely destroys the contents of this database. |
Status Destroy(); |
@@ -70,9 +91,11 @@ class CONTENT_EXPORT NotificationDatabase { |
STATE_DISABLED, |
}; |
- // Writes the next available notification id as a put operation to |batch|. |
- void WriteNextNotificationId(leveldb::WriteBatch* batch, |
- int64_t next_notification_id) const; |
+ // Returns whether the next available notification id could be read, and |
+ // stores the id in |notification_id| if the read was successful. A put |
+ // operation will be written to |batch| to increment the id. |
+ Status GetAndIncrementNextNotificationId(leveldb::WriteBatch* batch, |
+ int64_t* notification_id) const; |
// Returns whether the database has been opened. |
bool IsOpen() const { return db_ != nullptr; } |