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

Unified Diff: components/ntp_snippets/ntp_snippets_database.h

Issue 2083533002: [NTP Snippets] Shut down the service on database failure (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@image_db_tests
Patch Set: comments Created 4 years, 6 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 336dad02c3d4f8447200a18840d34481b2bcba47..983166235f0ca70265f66149e3ae6c9b6aa842d5 100644
--- a/components/ntp_snippets/ntp_snippets_database.h
+++ b/components/ntp_snippets/ntp_snippets_database.h
@@ -41,6 +41,13 @@ class NTPSnippetsDatabase {
// initialization finishes), but no updates are allowed.
bool IsInitialized() const;
+ // Returns whether the database is in an (unrecoverable) error state. If this
+ // is true, the database must not be used anymore
+ bool IsErrorState() const;
+
+ // Set a callback to be called when the database enters an error state.
+ void SetErrorCallback(const base::Closure& error_callback);
+
// Loads all snippets from storage and passes them to |callback|.
void LoadSnippets(const SnippetsCallback& callback);
@@ -88,6 +95,8 @@ class NTPSnippetsDatabase {
std::unique_ptr<SnippetImageProto> entry);
void OnImageDatabaseSaved(bool success);
+ void OnDatabaseError();
+
void ProcessPendingLoads();
void LoadSnippetsImpl(const SnippetsCallback& callback);
@@ -100,8 +109,6 @@ class NTPSnippetsDatabase {
void DeleteImagesImpl(
std::unique_ptr<std::vector<std::string>> keys_to_remove);
- void ResetDatabases();
-
std::unique_ptr<leveldb_proto::ProtoDatabase<SnippetProto>> database_;
bool database_initialized_;
std::vector<SnippetsCallback> pending_snippets_callbacks_;
@@ -112,6 +119,8 @@ class NTPSnippetsDatabase {
std::vector<std::pair<std::string, SnippetImageCallback>>
pending_image_callbacks_;
+ base::Closure error_callback_;
Bernhard Bauer 2016/06/20 17:37:46 At some point you could think about switching to a
Marc Treib 2016/06/21 08:27:48 Hm, true. I generally like explicit callbacks beca
+
base::WeakPtrFactory<NTPSnippetsDatabase> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(NTPSnippetsDatabase);
« 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