Chromium Code Reviews| 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); |