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

Unified Diff: components/search_provider_logos/google_logo_api.cc

Issue 1618043002: Correctly record "No logo today" instead of "Parsing error" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/search_provider_logos/google_logo_api.cc
diff --git a/components/search_provider_logos/google_logo_api.cc b/components/search_provider_logos/google_logo_api.cc
index d3bbe3332f845afdb258681593f2b6a2b10e6ffb..42e046d32015fa8a8ceb0d013b1e7a70e1078545 100644
--- a/components/search_provider_logos/google_logo_api.cc
+++ b/components/search_provider_logos/google_logo_api.cc
@@ -71,16 +71,11 @@ scoped_ptr<EncodedLogo> GoogleParseLogoResponse(
if (response_sp.starts_with(kResponsePreamble))
response_sp.remove_prefix(strlen(kResponsePreamble));
- scoped_ptr<base::Value> value = base::JSONReader::Read(response_sp);
-
- // Check if no logo today.
- if (!value.get()) {
- *parsing_failed = false;
- return scoped_ptr<EncodedLogo>();
- }
-
// Default parsing failure to be true.
*parsing_failed = true;
newt (away) 2016/01/22 03:11:20 I'd move this line to very beginning of the functi
+ scoped_ptr<base::Value> value = base::JSONReader::Read(response_sp);
+ if (!value.get())
+ return scoped_ptr<EncodedLogo>();
// The important data lives inside several nested dictionaries:
// {"update": {"logo": { "mime_type": ..., etc } } }
const base::DictionaryValue* outer_dict;
@@ -89,6 +84,13 @@ scoped_ptr<EncodedLogo> GoogleParseLogoResponse(
const base::DictionaryValue* update_dict;
if (!outer_dict->GetDictionary("update", &update_dict))
return scoped_ptr<EncodedLogo>();
+
+ // If there is no logo today, the server sends out an empty update.
newt (away) 2016/01/22 03:11:20 Slightly less ambiguous, I think: "If there is no
+ if (update_dict->empty()) {
+ *parsing_failed = false;
+ return scoped_ptr<EncodedLogo>();
+ }
+
const base::DictionaryValue* logo_dict;
if (!update_dict->GetDictionary("logo", &logo_dict))
return scoped_ptr<EncodedLogo>();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698