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

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
« no previous file with comments | « no previous file | content/browser/notifications/notification_database.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/notifications/notification_database.h
diff --git a/content/browser/notifications/notification_database.h b/content/browser/notifications/notification_database.h
index 54eca073277887293d1fb55e676579354523fb9b..85b855a0bd56dd433f9d661edaa0ec22bfb24e64 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) const;
+
// Completely destroys the contents of this database.
Status Destroy();
@@ -63,12 +70,20 @@ 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 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* GetDBForTesting() const { return db_.get(); }
+
base::FilePath path_;
// The declaration order for these members matters, as |db_| depends on |env_|
« no previous file with comments | « no previous file | content/browser/notifications/notification_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698