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

Side by Side Diff: components/safe_browsing_db/safe_browsing_api_handler_util.cc

Issue 2539363004: Make base::Value::TYPE a scoped enum. (Closed)
Patch Set: Rebase Created 4 years 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 unified diff | Download patch
« no previous file with comments | « components/proximity_auth/wire_message.cc ('k') | components/safe_json/json_sanitizer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/safe_browsing_db/safe_browsing_api_handler_util.h" 5 #include "components/safe_browsing_db/safe_browsing_api_handler_util.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 ThreatMetadata* metadata) { 150 ThreatMetadata* metadata) {
151 *worst_threat = SB_THREAT_TYPE_SAFE; // Default to safe. 151 *worst_threat = SB_THREAT_TYPE_SAFE; // Default to safe.
152 *metadata = ThreatMetadata(); // Default values. 152 *metadata = ThreatMetadata(); // Default values.
153 153
154 if (metadata_str.empty()) 154 if (metadata_str.empty())
155 return UMA_STATUS_JSON_EMPTY; 155 return UMA_STATUS_JSON_EMPTY;
156 156
157 // Pick out the "matches" list. 157 // Pick out the "matches" list.
158 std::unique_ptr<base::Value> value = base::JSONReader::Read(metadata_str); 158 std::unique_ptr<base::Value> value = base::JSONReader::Read(metadata_str);
159 const base::ListValue* matches = nullptr; 159 const base::ListValue* matches = nullptr;
160 if (!value.get() || !value->IsType(base::Value::TYPE_DICTIONARY) || 160 if (!value.get() || !value->IsType(base::Value::Type::DICTIONARY) ||
161 !(static_cast<base::DictionaryValue*>(value.get())) 161 !(static_cast<base::DictionaryValue*>(value.get()))
162 ->GetList(kJsonKeyMatches, &matches) || 162 ->GetList(kJsonKeyMatches, &matches) ||
163 !matches) { 163 !matches) {
164 return UMA_STATUS_JSON_FAILED_TO_PARSE; 164 return UMA_STATUS_JSON_FAILED_TO_PARSE;
165 } 165 }
166 166
167 // Go through each matched threat type and pick the most severe. 167 // Go through each matched threat type and pick the most severe.
168 int worst_threat_num = -1; 168 int worst_threat_num = -1;
169 const base::DictionaryValue* worst_match = nullptr; 169 const base::DictionaryValue* worst_match = nullptr;
170 for (size_t i = 0; i < matches->GetSize(); i++) { 170 for (size_t i = 0; i < matches->GetSize(); i++) {
(...skipping 20 matching lines...) Expand all
191 191
192 // Fill in the metadata 192 // Fill in the metadata
193 metadata->threat_pattern_type = 193 metadata->threat_pattern_type =
194 ParseThreatSubType(worst_match, *worst_threat); 194 ParseThreatSubType(worst_match, *worst_threat);
195 metadata->population_id = ParseUserPopulation(worst_match); 195 metadata->population_id = ParseUserPopulation(worst_match);
196 196
197 return UMA_STATUS_UNSAFE; // success 197 return UMA_STATUS_UNSAFE; // success
198 } 198 }
199 199
200 } // namespace safe_browsing 200 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « components/proximity_auth/wire_message.cc ('k') | components/safe_json/json_sanitizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698