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

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

Issue 1004493002: Store the next notification id in the notification database. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@n-db-NotificationDatabase
Patch Set: Created 5 years, 9 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 8fb9ce01bf736405d83828a5046f27a0ed5ca3a3..8de0d9cf82c638feec069ce331a082a13b2700eb 100644
--- a/content/browser/notifications/notification_database.h
+++ b/content/browser/notifications/notification_database.h
@@ -5,6 +5,8 @@
#ifndef CONTENT_BROWSER_NOTIFICATIONS_NOTIFICATION_DATABASE_H_
#define CONTENT_BROWSER_NOTIFICATIONS_NOTIFICATION_DATABASE_H_
+#include <stdint.h>
+
#include "base/callback.h"
#include "base/files/file_path.h"
#include "base/sequence_checker.h"
@@ -13,6 +15,7 @@
namespace leveldb {
class DB;
class Env;
+class WriteBatch;
}
namespace content {
@@ -49,6 +52,10 @@ 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);
+
// Completely destroys the contents of this database.
Status Destroy();
@@ -63,18 +70,30 @@ class CONTENT_EXPORT NotificationDatabase {
STATE_DISABLED,
};
+ // Increments the available notification id to |current_notification_id| + 1.
+ // |current_notification_id| must be equal to or higher than the last id
+ // returned by GetNextNotificationId(). The value will be written to |batch|.
+ void IncrementNextNotificationId(leveldb::WriteBatch* batch,
+ int64_t current_notification_id);
+
// Returns whether the database has been opened.
bool IsOpen() const { return db_ != nullptr; }
// Returns whether the database should only exist in memory.
bool IsInMemoryDatabase() const { return path_.empty(); }
+ // Exposes the LevelDB database used to back this notification database.
+ // Should only be used for testing purposes.
+ leveldb::DB* db() { return db_.get(); }
Bernhard Bauer 2015/03/11 22:02:38 Name this GetDBForTesting(), so the presubmit chec
Peter Beverloo 2015/03/11 22:33:33 Done.
+
base::FilePath path_;
// These members depend on the declaration order for destruction.
scoped_ptr<leveldb::Env> env_;
scoped_ptr<leveldb::DB> db_;
+ int64_t next_available_notification_id_;
+
State state_;
base::SequenceChecker sequence_checker_;

Powered by Google App Engine
This is Rietveld 408576698