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