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

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

Issue 1420053005: Move code in components/safe_browsing_db and chrome/browser/s_b/ under the safe_browsing namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@02_components_move
Patch Set: Other minor fixes incl. using "using safe_browsing::ClassName" instead of safe_browsing::ClassName everywhere. Created 5 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 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 <stdlib.h> 9 #include <stdlib.h>
10 10
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 return true; 124 return true;
125 } 125 }
126 126
127 private: 127 private:
128 const char* data_; 128 const char* data_;
129 size_t length_; 129 size_t length_;
130 130
131 DISALLOW_COPY_AND_ASSIGN(BufferReader); 131 DISALLOW_COPY_AND_ASSIGN(BufferReader);
132 }; 132 };
133 133
134 bool ParseGetHashMetadata(size_t hash_count, 134 bool ParseGetHashMetadata(
135 BufferReader* reader, 135 size_t hash_count,
136 std::vector<SBFullHashResult>* full_hashes) { 136 BufferReader* reader,
137 std::vector<safe_browsing::SBFullHashResult>* full_hashes) {
137 for (size_t i = 0; i < hash_count; ++i) { 138 for (size_t i = 0; i < hash_count; ++i) {
138 base::StringPiece line; 139 base::StringPiece line;
139 if (!reader->GetLine(&line)) 140 if (!reader->GetLine(&line))
140 return false; 141 return false;
141 142
142 size_t meta_data_len; 143 size_t meta_data_len;
143 if (!base::StringToSizeT(line, &meta_data_len)) 144 if (!base::StringToSizeT(line, &meta_data_len))
144 return false; 145 return false;
145 146
146 const void* meta_data; 147 const void* meta_data;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 193
193 *cache_lifetime = base::TimeDelta::FromSeconds(cache_lifetime_seconds); 194 *cache_lifetime = base::TimeDelta::FromSeconds(cache_lifetime_seconds);
194 } 195 }
195 196
196 while (!reader.empty()) { 197 while (!reader.empty()) {
197 std::vector<base::StringPiece> cmd_parts; 198 std::vector<base::StringPiece> cmd_parts;
198 if (!reader.GetPieces(3, &cmd_parts)) 199 if (!reader.GetPieces(3, &cmd_parts))
199 return false; 200 return false;
200 201
201 SBFullHashResult full_hash; 202 SBFullHashResult full_hash;
202 full_hash.list_id = safe_browsing::GetListId(cmd_parts[0]); 203 full_hash.list_id = GetListId(cmd_parts[0]);
203 204
204 size_t hash_len; 205 size_t hash_len;
205 if (!base::StringToSizeT(cmd_parts[1], &hash_len)) 206 if (!base::StringToSizeT(cmd_parts[1], &hash_len))
206 return false; 207 return false;
207 208
208 // TODO(shess): Is this possible? If not, why the length present? 209 // TODO(shess): Is this possible? If not, why the length present?
209 if (hash_len != sizeof(SBFullHash)) 210 if (hash_len != sizeof(SBFullHash))
210 return false; 211 return false;
211 212
212 // Metadata is indicated by an optional ":m" at the end of the line. 213 // Metadata is indicated by an optional ":m" at the end of the line.
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 if (!list.adds.empty() && !list.subs.empty()) 388 if (!list.adds.empty() && !list.subs.empty())
388 formatted_results.append(":"); 389 formatted_results.append(":");
389 if (!list.subs.empty()) 390 if (!list.subs.empty())
390 formatted_results.append("s:").append(list.subs); 391 formatted_results.append("s:").append(list.subs);
391 formatted_results.append("\n"); 392 formatted_results.append("\n");
392 393
393 return formatted_results; 394 return formatted_results;
394 } 395 }
395 396
396 } // namespace safe_browsing 397 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698