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

Unified Diff: components/ntp_snippets/remote/remote_suggestions_database.cc

Issue 2520853002: [NTP] Cleanup: add brackets in components/ntp_snippets. [2/2] (Closed)
Patch Set: "else if". Created 4 years, 1 month 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
Index: components/ntp_snippets/remote/remote_suggestions_database.cc
diff --git a/components/ntp_snippets/remote/remote_suggestions_database.cc b/components/ntp_snippets/remote/remote_suggestions_database.cc
index 572d649081b9b16034809ff9425fee14c236e71e..8001a6bd927f67f9c0cf67068d78cd28841a3d96 100644
--- a/components/ntp_snippets/remote/remote_suggestions_database.cc
+++ b/components/ntp_snippets/remote/remote_suggestions_database.cc
@@ -64,10 +64,11 @@ void RemoteSuggestionsDatabase::SetErrorCallback(
}
void RemoteSuggestionsDatabase::LoadSnippets(const SnippetsCallback& callback) {
- if (IsInitialized())
+ if (IsInitialized()) {
LoadSnippetsImpl(callback);
- else
+ } else {
pending_snippets_callbacks_.emplace_back(callback);
+ }
}
void RemoteSuggestionsDatabase::SaveSnippet(const NTPSnippet& snippet) {
@@ -109,10 +110,11 @@ void RemoteSuggestionsDatabase::DeleteSnippets(
void RemoteSuggestionsDatabase::LoadImage(
const std::string& snippet_id,
const SnippetImageCallback& callback) {
- if (IsInitialized())
+ if (IsInitialized()) {
LoadImageImpl(snippet_id, callback);
- else
+ } else {
pending_image_callbacks_.emplace_back(snippet_id, callback);
+ }
}
void RemoteSuggestionsDatabase::SaveImage(const std::string& snippet_id,
@@ -162,8 +164,9 @@ void RemoteSuggestionsDatabase::OnDatabaseInited(bool success) {
return;
}
database_initialized_ = true;
- if (IsInitialized())
+ if (IsInitialized()) {
ProcessPendingLoads();
+ }
}
void RemoteSuggestionsDatabase::OnDatabaseLoaded(
@@ -199,8 +202,9 @@ void RemoteSuggestionsDatabase::OnDatabaseLoaded(
// If any of the snippet protos couldn't be converted to actual snippets,
// clean them up now.
- if (!keys_to_remove->empty())
+ if (!keys_to_remove->empty()) {
DeleteSnippets(std::move(keys_to_remove));
+ }
}
void RemoteSuggestionsDatabase::OnDatabaseSaved(bool success) {
@@ -218,8 +222,9 @@ void RemoteSuggestionsDatabase::OnImageDatabaseInited(bool success) {
return;
}
image_database_initialized_ = true;
- if (IsInitialized())
+ if (IsInitialized()) {
ProcessPendingLoads();
+ }
}
void RemoteSuggestionsDatabase::OnImageDatabaseLoaded(
@@ -251,19 +256,22 @@ void RemoteSuggestionsDatabase::OnImageDatabaseSaved(bool success) {
void RemoteSuggestionsDatabase::OnDatabaseError() {
database_.reset();
image_database_.reset();
- if (!error_callback_.is_null())
+ if (!error_callback_.is_null()) {
error_callback_.Run();
+ }
}
void RemoteSuggestionsDatabase::ProcessPendingLoads() {
DCHECK(IsInitialized());
- for (const auto& callback : pending_snippets_callbacks_)
+ for (const auto& callback : pending_snippets_callbacks_) {
LoadSnippetsImpl(callback);
+ }
pending_snippets_callbacks_.clear();
- for (const auto& id_callback : pending_image_callbacks_)
+ for (const auto& id_callback : pending_image_callbacks_) {
LoadImageImpl(id_callback.first, id_callback.second);
+ }
pending_image_callbacks_.clear();
}

Powered by Google App Engine
This is Rietveld 408576698