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

Unified Diff: components/ntp_snippets/ntp_snippets_database.h

Issue 2033723002: NTPSnippetsDatabase: support multiple concurrent loads (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@leveldb
Patch Set: Created 4 years, 7 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 | components/ntp_snippets/ntp_snippets_database.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/ntp_snippets/ntp_snippets_database.h
diff --git a/components/ntp_snippets/ntp_snippets_database.h b/components/ntp_snippets/ntp_snippets_database.h
index 24e98d7b1e513897c350a61a6deeb35e43334d70..f421b209cacc6da62cce0d088b62561a72a309fe 100644
--- a/components/ntp_snippets/ntp_snippets_database.h
+++ b/components/ntp_snippets/ntp_snippets_database.h
@@ -6,6 +6,7 @@
#define COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_DATABASE_H_
#include <memory>
+#include <string>
#include <vector>
#include "base/callback.h"
@@ -33,9 +34,7 @@ class NTPSnippetsDatabase {
scoped_refptr<base::SequencedTaskRunner> file_task_runner);
~NTPSnippetsDatabase();
- // Loads all snippets from storage and passes them to |callback|. Only one
- // concurrent fetch is supported; it is only legal to call this again after
- // the first load has completed.
+ // Loads all snippets from storage and passes them to |callback|.
void Load(const SnippetsLoadedCallback& callback);
// Adds or updates the given snippet.
@@ -56,11 +55,12 @@ class NTPSnippetsDatabase {
// Callbacks for ProtoDatabase operations.
void OnDatabaseInited(bool success);
- void OnDatabaseLoaded(bool success,
+ void OnDatabaseLoaded(const SnippetsLoadedCallback& callback,
+ bool success,
std::unique_ptr<std::vector<SnippetProto>> entries);
void OnDatabaseSaved(bool success);
- void LoadImpl();
+ void LoadImpl(const SnippetsLoadedCallback& callback);
void SaveImpl(std::unique_ptr<KeyEntryVector> entries_to_save);
@@ -69,7 +69,7 @@ class NTPSnippetsDatabase {
std::unique_ptr<leveldb_proto::ProtoDatabase<SnippetProto>> database_;
bool database_initialized_;
- SnippetsLoadedCallback callback_;
+ std::vector<SnippetsLoadedCallback> pending_load_callbacks_;
base::WeakPtrFactory<NTPSnippetsDatabase> weak_ptr_factory_;
« no previous file with comments | « no previous file | components/ntp_snippets/ntp_snippets_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698