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

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

Issue 8417040: Measure how often downloaded executables match the download whitelist. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Address Brian's comment. Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 const char* data, 328 const char* data,
329 int data_len, 329 int data_len,
330 int hash_len, 330 int hash_len,
331 std::deque<SBChunkHost>* hosts) { 331 std::deque<SBChunkHost>* hosts) {
332 const char* chunk_data = data; 332 const char* chunk_data = data;
333 int remaining = data_len; 333 int remaining = data_len;
334 int prefix_count; 334 int prefix_count;
335 SBEntry::Type type = hash_len == sizeof(SBPrefix) ? 335 SBEntry::Type type = hash_len == sizeof(SBPrefix) ?
336 SBEntry::ADD_PREFIX : SBEntry::ADD_FULL_HASH; 336 SBEntry::ADD_PREFIX : SBEntry::ADD_FULL_HASH;
337 337
338 if (list_name == safe_browsing_util::kBinHashList) { 338 if (list_name == safe_browsing_util::kBinHashList ||
339 // kBinHashList only contains prefixes, no HOSTKEY and COUNT. 339 list_name == safe_browsing_util::kDownloadWhiteList) {
340 // These lists only contain prefixes, no HOSTKEY and COUNT.
340 DCHECK_EQ(0, remaining % hash_len); 341 DCHECK_EQ(0, remaining % hash_len);
341 prefix_count = remaining / hash_len; 342 prefix_count = remaining / hash_len;
342 SBChunkHost chunk_host; 343 SBChunkHost chunk_host;
343 chunk_host.host = 0; 344 chunk_host.host = 0;
344 chunk_host.entry = SBEntry::Create(type, prefix_count); 345 chunk_host.entry = SBEntry::Create(type, prefix_count);
345 hosts->push_back(chunk_host); 346 hosts->push_back(chunk_host);
346 if (!ReadPrefixes(&chunk_data, &remaining, chunk_host.entry, prefix_count)) 347 if (!ReadPrefixes(&chunk_data, &remaining, chunk_host.entry, prefix_count))
347 return false; 348 return false;
348 } else { 349 } else {
349 SBPrefix host; 350 SBPrefix host;
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 487
487 data += line.size() + 1; 488 data += line.size() + 1;
488 remaining -= static_cast<int>(line.size()) + 1; 489 remaining -= static_cast<int>(line.size()) + 1;
489 } 490 }
490 491
491 if (client_key->empty() || wrapped_key->empty()) 492 if (client_key->empty() || wrapped_key->empty())
492 return false; 493 return false;
493 494
494 return true; 495 return true;
495 } 496 }
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/protocol_manager.cc ('k') | chrome/browser/safe_browsing/protocol_parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698