Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(811)

Unified Diff: content/browser/notifications/notification_database.h

Issue 2300093002: Make //content responsible for generating notification Ids (Closed)
Patch Set: Make //content responsible for generating notification Ids Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/notifications/notification_database.h
diff --git a/content/browser/notifications/notification_database.h b/content/browser/notifications/notification_database.h
index c08dbfeba7a32615603e92a5eecd301bb743446f..79ab732fe7bb107729cdb1980433f8dabc29fa5f 100644
--- a/content/browser/notifications/notification_database.h
+++ b/content/browser/notifications/notification_database.h
@@ -78,11 +78,16 @@ class CONTENT_EXPORT NotificationDatabase {
// |create_if_missing| determines whether to create the database if necessary.
Status Open(bool create_if_missing);
+ // Gets the next assignable notification ID. Subsequent calls to this method
johnme 2016/09/07 17:13:14 persistent notification ID
Peter Beverloo 2016/09/08 13:18:56 Done.
+ // will yield unique identifiers for the same database. The last used ID will
+ // be written to the database when a notification is created.
+ int64_t GetNextNotificationId();
johnme 2016/09/07 17:13:14 GetNextPersistentNotificationId
Peter Beverloo 2016/09/08 13:18:56 Done.
+
// 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.
+ // it in |*notification_database_data|. Returns the status code.
Status ReadNotificationData(
- int64_t notification_id,
+ const std::string& notification_id,
const GURL& origin,
NotificationDatabaseData* notification_database_data) const;
johnme 2016/09/07 17:13:14 Nit: notification_data since you renamed it in Wri
Peter Beverloo 2016/09/08 13:18:56 Done.
@@ -105,28 +110,28 @@ class CONTENT_EXPORT NotificationDatabase {
int64_t service_worker_registration_id,
std::vector<NotificationDatabaseData>* notification_data_vector) 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|.
+ // Writes the |notification_data| for a new notification belonging to |origin|
+ // to the database, and returns the status code of the writing operation. The
+ // notification's ID must have been set in the |notification_data|.
Status WriteNotificationData(
const GURL& origin,
- const NotificationDatabaseData& notification_database_data,
- int64_t* notification_id);
+ const NotificationDatabaseData& notification_data);
// 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. Note that it is not considered a
// failure if the to-be-deleted notification does not exist.
- Status DeleteNotificationData(int64_t notification_id, const GURL& origin);
+ Status DeleteNotificationData(const std::string& notification_id,
+ const GURL& origin);
// Deletes all data associated with |origin| from the database, optionally
// filtered by the |tag|, and appends the deleted notification ids to
- // |deleted_notification_set|. Returns the status code of the deletion
+ // |deleted_notification_ids|. Returns the status code of the deletion
// operation.
Status DeleteAllNotificationDataForOrigin(
const GURL& origin,
const std::string& tag,
- std::set<int64_t>* deleted_notification_set);
+ std::set<std::string>* deleted_notification_ids);
// Deletes all data associated with the |service_worker_registration_id|
// belonging to |origin| from the database, and appends the deleted
@@ -135,7 +140,7 @@ class CONTENT_EXPORT NotificationDatabase {
Status DeleteAllNotificationDataForServiceWorkerRegistration(
const GURL& origin,
int64_t service_worker_registration_id,
- std::set<int64_t>* deleted_notification_set);
+ std::set<std::string>* deleted_notification_ids);
// Completely destroys the contents of this database.
Status Destroy();
@@ -170,12 +175,12 @@ class CONTENT_EXPORT NotificationDatabase {
// always be set - use Destroy() when the goal is to empty the database. If
// |service_worker_registration_id| is invalid, all notification data for the
// |origin| will be deleted, optionally filtered by the |tag| when non-empty.
- // All deleted notification ids will be written to |deleted_notification_set|.
+ // All deleted notification ids will be written to |deleted_notification_ids|.
Status DeleteAllNotificationDataInternal(
const GURL& origin,
const std::string& tag,
int64_t service_worker_registration_id,
- std::set<int64_t>* deleted_notification_set);
+ std::set<std::string>* deleted_notification_ids);
// Returns whether the database has been opened.
bool IsOpen() const { return db_ != nullptr; }
@@ -189,7 +194,8 @@ class CONTENT_EXPORT NotificationDatabase {
base::FilePath path_;
- int64_t next_notification_id_ = 0;
+ int64_t next_persistent_notification_id_ = 0;
+ int64_t written_persistent_notification_id_ = 0;
std::unique_ptr<const leveldb::FilterPolicy> filter_policy_;

Powered by Google App Engine
This is Rietveld 408576698