Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_BROWSER_NOTIFICATIONS_NOTIFICATION_DATABASE_H_ | |
| 6 #define CONTENT_BROWSER_NOTIFICATIONS_NOTIFICATION_DATABASE_H_ | |
| 7 | |
| 8 #include "base/callback.h" | |
| 9 #include "base/files/file_path.h" | |
| 10 #include "base/sequence_checker.h" | |
| 11 #include "content/common/content_export.h" | |
| 12 | |
| 13 namespace leveldb { | |
| 14 class DB; | |
| 15 class Env; | |
| 16 } | |
| 17 | |
| 18 namespace content { | |
| 19 | |
| 20 // Implementation of the persistent notification database. | |
| 21 // | |
| 22 // This class must be constructed on the IO thread. All other methods must be | |
|
Bernhard Bauer
2015/03/11 17:15:22
There doesn't seem to anything that requires the c
Peter Beverloo
2015/03/11 18:01:26
Done.
| |
| 23 // called on a sequenced task runner because they may cause file I/O, which | |
|
Bernhard Bauer
2015/03/11 17:15:22
Nit: I would phrase it as "All other methods must
Peter Beverloo
2015/03/11 18:01:26
Done.
| |
| 24 // should not be done on any of the default threads. | |
| 25 class CONTENT_EXPORT NotificationDatabase { | |
| 26 using InitCallback = base::Callback<void(bool /* success */)>; | |
|
Bernhard Bauer
2015/03/11 17:15:22
Is this used somewhere? And in any case, public: s
Peter Beverloo
2015/03/11 18:01:26
Removed.
| |
| 27 | |
| 28 public: | |
| 29 explicit NotificationDatabase(const base::FilePath& path); | |
| 30 ~NotificationDatabase(); | |
| 31 | |
| 32 enum Status { | |
|
Bernhard Bauer
2015/03/11 17:15:22
Enum declarations should come before methods.
Peter Beverloo
2015/03/11 18:01:26
Done.
| |
| 33 STATUS_OK, | |
| 34 STATUS_ERROR_NOT_FOUND, | |
| 35 STATUS_ERROR_FAILED | |
|
Bernhard Bauer
2015/03/11 17:15:22
Can you explain what these mean? Also, you might w
Peter Beverloo
2015/03/11 18:01:26
Done.
| |
| 36 }; | |
| 37 | |
| 38 // Opens the database located in |path|. If |path| does not contain a valid | |
| 39 // path, the database will be opened in memory instead. |create_if_missing| | |
|
Bernhard Bauer
2015/03/11 17:15:22
"If path is non-empty, [...]"?
Peter Beverloo
2015/03/11 18:01:26
Done, rephrased this comment.
| |
| 40 // indicates whether to create the database if it does not exist. | |
| 41 Status Open(bool create_if_missing); | |
| 42 | |
| 43 // Completely destroys the contents of this database. | |
| 44 Status Destroy(); | |
| 45 | |
| 46 private: | |
| 47 friend class NotificationDatabaseTest; | |
| 48 | |
| 49 // Returns whether the database has been opened. | |
| 50 bool IsOpen() const { return db_ != nullptr; } | |
| 51 | |
| 52 // Returns whether the database should only exist in memory. | |
| 53 bool IsInMemoryDatabase() const { return path_.empty(); } | |
| 54 | |
| 55 base::FilePath path_; | |
| 56 scoped_ptr<leveldb::Env> env_; | |
| 57 scoped_ptr<leveldb::DB> db_; | |
| 58 | |
| 59 enum State { | |
|
Bernhard Bauer
2015/03/11 17:15:22
Move the enum to the beginning of the private sect
Peter Beverloo
2015/03/11 18:01:26
It seems like we can't use enum class values in DC
| |
| 60 STATE_UNINITIALIZED, | |
| 61 STATE_INITIALIZED, | |
| 62 STATE_DISABLED | |
|
Bernhard Bauer
2015/03/11 17:15:22
Also add a trailing comma here.
Peter Beverloo
2015/03/11 18:01:26
Done.
| |
| 63 }; | |
| 64 | |
| 65 State state_; | |
| 66 | |
| 67 base::SequenceChecker sequence_checker_; | |
|
Bernhard Bauer
2015/03/11 17:15:22
DISALLOW_COPY_AND_ASSIGN?
Peter Beverloo
2015/03/11 18:01:26
Oops. Done.
| |
| 68 }; | |
| 69 | |
| 70 } // namespace content | |
| 71 | |
| 72 #endif // CONTENT_BROWSER_NOTIFICATIONS_NOTIFICATION_DATABASE_H_ | |
| OLD | NEW |