| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_BROWSER_NOTIFICATIONS_NOTIFICATION_DATABASE_H_ | 5 #ifndef CONTENT_BROWSER_NOTIFICATIONS_NOTIFICATION_DATABASE_H_ |
| 6 #define CONTENT_BROWSER_NOTIFICATIONS_NOTIFICATION_DATABASE_H_ | 6 #define CONTENT_BROWSER_NOTIFICATIONS_NOTIFICATION_DATABASE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/callback.h" | |
| 11 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 12 #include "base/sequence_checker.h" | 11 #include "base/sequence_checker.h" |
| 13 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
| 14 | 13 |
| 15 class GURL; | 14 class GURL; |
| 16 | 15 |
| 17 namespace leveldb { | 16 namespace leveldb { |
| 18 class DB; | 17 class DB; |
| 19 class Env; | 18 class Env; |
| 20 class WriteBatch; | 19 class WriteBatch; |
| 21 } | 20 } |
| 22 | 21 |
| 23 namespace content { | 22 namespace content { |
| 24 | 23 |
| 25 struct NotificationDatabaseData; | 24 struct NotificationDatabaseData; |
| 26 | 25 |
| 27 // Implementation of the persistent notification database. | 26 // Implementation of the persistent notification database. |
| 28 // | 27 // |
| 29 // This class can be constructed on any thread, but method calls must only be | 28 // The database is built on top of a LevelDB database, either in memory or on |
| 30 // made on a thread or sequenced task runner that allows file I/O. The same | 29 // the filesystem depending on the path passed to the constructor. When writing |
| 31 // thread or task runner must be used for all method calls. | 30 // a new notification, it will be assigned an id guaranteed to be unique for the |
| 31 // lifetime of the database. |
| 32 // |
| 33 // This class must only be used on a thread or sequenced task runner that allows |
| 34 // file I/O. The same thread or task runner must be used for all method calls. |
| 32 class CONTENT_EXPORT NotificationDatabase { | 35 class CONTENT_EXPORT NotificationDatabase { |
| 33 public: | 36 public: |
| 34 // Result status codes for interations with the database. Will be used for | 37 // Result status codes for interations with the database. Will be used for |
| 35 // UMA, so the assigned ids must remain stable. | 38 // UMA, so the assigned ids must remain stable. |
| 36 enum Status { | 39 enum Status { |
| 37 STATUS_OK = 0, | 40 STATUS_OK = 0, |
| 38 | 41 |
| 39 // The database, a notification, or a LevelDB key associated with the | 42 // The database, a notification, or a LevelDB key associated with the |
| 40 // operation could not be found. | 43 // operation could not be found. |
| 41 STATUS_ERROR_NOT_FOUND = 1, | 44 STATUS_ERROR_NOT_FOUND = 1, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 State state_; | 120 State state_; |
| 118 | 121 |
| 119 base::SequenceChecker sequence_checker_; | 122 base::SequenceChecker sequence_checker_; |
| 120 | 123 |
| 121 DISALLOW_COPY_AND_ASSIGN(NotificationDatabase); | 124 DISALLOW_COPY_AND_ASSIGN(NotificationDatabase); |
| 122 }; | 125 }; |
| 123 | 126 |
| 124 } // namespace content | 127 } // namespace content |
| 125 | 128 |
| 126 #endif // CONTENT_BROWSER_NOTIFICATIONS_NOTIFICATION_DATABASE_H_ | 129 #endif // CONTENT_BROWSER_NOTIFICATIONS_NOTIFICATION_DATABASE_H_ |
| OLD | NEW |