Chromium Code Reviews| 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..49ebb9166218c004b3c563551649e3e13345309f 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); |
|
cmumford
2015/03/12 02:09:37
Should we be using int64 instead of int64_t?
Peter Beverloo
2015/03/12 02:13:56
Using just int64 is deprecated, see basictypes.h.
|
| + |
| // Completely destroys the contents of this database. |
| Status Destroy(); |
| @@ -63,12 +70,20 @@ class CONTENT_EXPORT NotificationDatabase { |
| STATE_DISABLED, |
| }; |
| + // Increments the next available notification id, and writes a put operation |
| + // to |batch| so that this can be written to the database. |
| + void IncrementNextNotificationId(leveldb::WriteBatch* batch); |
| + |
| // 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() { return db_.get(); } |
|
cmumford
2015/03/12 02:09:37
const method?
Peter Beverloo
2015/03/12 02:13:56
I'll apply this in the morning.
Peter Beverloo
2015/03/12 14:28:59
Done.
|
| + |
| base::FilePath path_; |
| // The declaration order for these members matters, as |db_| depends on |env_| |
| @@ -76,6 +91,8 @@ class CONTENT_EXPORT NotificationDatabase { |
| scoped_ptr<leveldb::Env> env_; |
| scoped_ptr<leveldb::DB> db_; |
| + int64_t next_notification_id_; |
| + |
| State state_; |
| base::SequenceChecker sequence_checker_; |