OLD | NEW |
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 #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" |
11 #include "base/stringprintf.h" | |
12 #include "base/strings/string_split.h" | 11 #include "base/strings/string_split.h" |
| 12 #include "base/strings/stringprintf.h" |
13 #include "base/sys_byteorder.h" | 13 #include "base/sys_byteorder.h" |
14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
15 #include "chrome/browser/safe_browsing/protocol_parser.h" | 15 #include "chrome/browser/safe_browsing/protocol_parser.h" |
16 #include "chrome/browser/safe_browsing/safe_browsing_util.h" | 16 #include "chrome/browser/safe_browsing/safe_browsing_util.h" |
17 | 17 |
18 namespace { | 18 namespace { |
19 // Helper function for quick scans of a line oriented protocol. Note that we use | 19 // Helper function for quick scans of a line oriented protocol. Note that we use |
20 // std::string::assign(const charT* s, size_type n) | 20 // std::string::assign(const charT* s, size_type n) |
21 // to copy data into 'line'. This form of 'assign' does not call strlen on | 21 // to copy data into 'line'. This form of 'assign' does not call strlen on |
22 // 'input', which is binary data and is not NULL terminated. 'input' may also | 22 // 'input', which is binary data and is not NULL terminated. 'input' may also |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 memcpy(&hash, *data, sizeof(hash)); | 411 memcpy(&hash, *data, sizeof(hash)); |
412 entry->SetFullHashAt(i, hash); | 412 entry->SetFullHashAt(i, hash); |
413 } | 413 } |
414 *data += hash_len; | 414 *data += hash_len; |
415 *remaining -= hash_len; | 415 *remaining -= hash_len; |
416 DCHECK_GE(*remaining, 0); | 416 DCHECK_GE(*remaining, 0); |
417 } | 417 } |
418 | 418 |
419 return true; | 419 return true; |
420 } | 420 } |
OLD | NEW |