Commit f9f5576d authored by Xing Liu's avatar Xing Liu Committed by Commit Bot

Notification scheduler: Polish collection store interface.

The collection store will be used by notification store and impression
store. They both loads data into memory and keep in-memory data synced
with the underlying storage.

The icon store will not use this because it only moves data through the
pipeline and never held by classes in memory.

This CL tweaks the collection store interface to better fit the need
of notification store and impression store.

Bug: 930968
Change-Id: Ia113c3ca9a4074f1673c957e08e82fda6208bdd5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1548633Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Commit-Queue: Xing Liu <xingliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#646636}
parent 46d10cd9
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
namespace notifications { namespace notifications {
// A storage interface which loads a collection of data type T into memory // A storage interface which loads a collection of data type T into memory
// during initialization. // during initialization. When updating the data, T will be copied to the actual
// storage layer since the caller will keep in memory data as well.
template <typename T> template <typename T>
class CollectionStore { class CollectionStore {
public: public:
...@@ -24,20 +25,19 @@ class CollectionStore { ...@@ -24,20 +25,19 @@ class CollectionStore {
using InitCallback = base::OnceCallback<void(bool)>; using InitCallback = base::OnceCallback<void(bool)>;
using UpdateCallback = base::OnceCallback<void(bool)>; using UpdateCallback = base::OnceCallback<void(bool)>;
// Initializes the database.
virtual void Init(InitCallback callback) = 0;
// Initializes the database and loads all entries into memory. // Initializes the database and loads all entries into memory.
virtual void InitAndLoad(LoadCallback callback) = 0; virtual void InitAndLoad(LoadCallback callback) = 0;
// Loads one entry into memory.
virtual void Load(const std::string& key, LoadCallback callback) = 0;
// Adds an entry to the storage. // Adds an entry to the storage.
virtual void Add(const std::string& key, virtual void Add(const std::string& key,
T& entry, const T& entry,
UpdateCallback callback) = 0; UpdateCallback callback) = 0;
// Updates an entry.
virtual void Update(const std::string& key,
const T& entry,
UpdateCallback callback) = 0;
// Deletes an entry from storage. // Deletes an entry from storage.
virtual void Delete(const std::string& key, UpdateCallback callback) = 0; virtual void Delete(const std::string& key, UpdateCallback callback) = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment