| Index: components/ntp_snippets/ntp_snippets_service.cc
|
| diff --git a/components/ntp_snippets/ntp_snippets_service.cc b/components/ntp_snippets/ntp_snippets_service.cc
|
| index bf55467f307a661ea0b5c57667e600a0080cc465..48b3f0b11128729b6bde2273f06ad6b2b9e3d658 100644
|
| --- a/components/ntp_snippets/ntp_snippets_service.cc
|
| +++ b/components/ntp_snippets/ntp_snippets_service.cc
|
| @@ -203,7 +203,7 @@ NTPSnippetsService::NTPSnippetsService(
|
| image_decoder_(std::move(image_decoder)),
|
| database_(std::move(database)),
|
| fetch_after_load_(false) {
|
| - // TODO(dgn) should be removed after branch point (https:://crbug.com/617585).
|
| + // TODO(dgn) should be removed after branch point (https://crbug.com/617585).
|
| ClearDeprecatedPrefs();
|
|
|
| if (explicitly_disabled_) {
|
| @@ -211,6 +211,14 @@ NTPSnippetsService::NTPSnippetsService(
|
| return;
|
| }
|
|
|
| + if (database_->IsErrorState()) {
|
| + EnterState(State::SHUT_DOWN);
|
| + return;
|
| + }
|
| +
|
| + database_->SetErrorCallback(base::Bind(&NTPSnippetsService::OnDatabaseError,
|
| + base::Unretained(this)));
|
| +
|
| // We transition to other states while finalizing the initialization, when the
|
| // database is done loading.
|
| database_->LoadSnippets(base::Bind(&NTPSnippetsService::OnDatabaseLoaded,
|
| @@ -325,6 +333,9 @@ void NTPSnippetsService::ClearDiscardedSnippets() {
|
| if (!initialized())
|
| return;
|
|
|
| + if (discarded_snippets_.empty())
|
| + return;
|
| +
|
| database_->DeleteSnippets(discarded_snippets_);
|
| discarded_snippets_.clear();
|
| }
|
| @@ -422,6 +433,10 @@ void NTPSnippetsService::OnDatabaseLoaded(NTPSnippet::PtrVector snippets) {
|
| FinishInitialization();
|
| }
|
|
|
| +void NTPSnippetsService::OnDatabaseError() {
|
| + EnterState(State::SHUT_DOWN);
|
| +}
|
| +
|
| void NTPSnippetsService::OnSuggestionsChanged(
|
| const SuggestionsProfile& suggestions) {
|
| DCHECK(initialized());
|
|
|