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

Side by Side Diff: chrome/browser/safe_browsing/protocol_parser.cc

Issue 1726403006: Switch Safe Browsing's metadata from string to struct. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix ParseJson in test Created 4 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // Parse the data returned from the SafeBrowsing v2.1 protocol response. 5 // Parse the data returned from the SafeBrowsing v2.1 protocol response.
6 6
7 // TODOv3(shess): Review these changes carefully. 7 // TODOv3(shess): Review these changes carefully.
8 8
9 #include "chrome/browser/safe_browsing/protocol_parser.h" 9 #include "chrome/browser/safe_browsing/protocol_parser.h"
10 10
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 148
149 size_t meta_data_len; 149 size_t meta_data_len;
150 if (!base::StringToSizeT(line, &meta_data_len)) 150 if (!base::StringToSizeT(line, &meta_data_len))
151 return false; 151 return false;
152 152
153 const void* meta_data; 153 const void* meta_data;
154 if (!reader->RefData(&meta_data, meta_data_len)) 154 if (!reader->RefData(&meta_data, meta_data_len))
155 return false; 155 return false;
156 156
157 if (full_hashes) { 157 if (full_hashes) {
158 (*full_hashes)[full_hashes->size() - hash_count + i].metadata.assign( 158 (*full_hashes)[full_hashes->size() - hash_count + i]
159 reinterpret_cast<const char*>(meta_data), meta_data_len); 159 .metadata.raw_metadata.assign(
160 reinterpret_cast<const char*>(meta_data), meta_data_len);
160 } 161 }
161 } 162 }
162 return true; 163 return true;
163 } 164 }
164 165
165 } // namespace 166 } // namespace
166 167
167 // BODY = CACHELIFETIME LF HASHENTRY* EOF 168 // BODY = CACHELIFETIME LF HASHENTRY* EOF
168 // CACHELIFETIME = DIGIT+ 169 // CACHELIFETIME = DIGIT+
169 // HASHENTRY = LISTNAME ":" HASHSIZE ":" NUMRESPONSES [":m"] LF 170 // HASHENTRY = LISTNAME ":" HASHSIZE ":" NUMRESPONSES [":m"] LF
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 if (!list.adds.empty() && !list.subs.empty()) 393 if (!list.adds.empty() && !list.subs.empty())
393 formatted_results.append(":"); 394 formatted_results.append(":");
394 if (!list.subs.empty()) 395 if (!list.subs.empty())
395 formatted_results.append("s:").append(list.subs); 396 formatted_results.append("s:").append(list.subs);
396 formatted_results.append("\n"); 397 formatted_results.append("\n");
397 398
398 return formatted_results; 399 return formatted_results;
399 } 400 }
400 401
401 } // namespace safe_browsing 402 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/local_database_manager.h ('k') | chrome/browser/safe_browsing/protocol_parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698