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 // 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 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 } | 385 } |
386 | 386 |
387 return true; | 387 return true; |
388 } | 388 } |
389 | 389 |
390 // BODY = (UINT32 CHUNKDATA)+ | 390 // BODY = (UINT32 CHUNKDATA)+ |
391 // UINT32 = Unsigned 32-bit integer in network byte order | 391 // UINT32 = Unsigned 32-bit integer in network byte order |
392 // CHUNKDATA = Encoded ChunkData protocol message | 392 // CHUNKDATA = Encoded ChunkData protocol message |
393 bool ParseChunk(const char* data, | 393 bool ParseChunk(const char* data, |
394 size_t length, | 394 size_t length, |
395 std::vector<scoped_ptr<SBChunkData>>* chunks) { | 395 std::vector<std::unique_ptr<SBChunkData>>* chunks) { |
396 BufferReader reader(data, length); | 396 BufferReader reader(data, length); |
397 | 397 |
398 while (!reader.empty()) { | 398 while (!reader.empty()) { |
399 uint32_t l = 0; | 399 uint32_t l = 0; |
400 if (!reader.GetNet32(&l) || l == 0 || l > reader.length()) | 400 if (!reader.GetNet32(&l) || l == 0 || l > reader.length()) |
401 return false; | 401 return false; |
402 | 402 |
403 const void* p = NULL; | 403 const void* p = NULL; |
404 if (!reader.RefData(&p, l)) | 404 if (!reader.RefData(&p, l)) |
405 return false; | 405 return false; |
406 | 406 |
407 scoped_ptr<SBChunkData> chunk(new SBChunkData()); | 407 std::unique_ptr<SBChunkData> chunk(new SBChunkData()); |
408 if (!chunk->ParseFrom(reinterpret_cast<const unsigned char*>(p), l)) | 408 if (!chunk->ParseFrom(reinterpret_cast<const unsigned char*>(p), l)) |
409 return false; | 409 return false; |
410 | 410 |
411 chunks->push_back(std::move(chunk)); | 411 chunks->push_back(std::move(chunk)); |
412 } | 412 } |
413 | 413 |
414 DCHECK(reader.empty()); | 414 DCHECK(reader.empty()); |
415 return true; | 415 return true; |
416 } | 416 } |
417 | 417 |
(...skipping 12 matching lines...) Expand all Loading... |
430 if (!list.adds.empty() && !list.subs.empty()) | 430 if (!list.adds.empty() && !list.subs.empty()) |
431 formatted_results.append(":"); | 431 formatted_results.append(":"); |
432 if (!list.subs.empty()) | 432 if (!list.subs.empty()) |
433 formatted_results.append("s:").append(list.subs); | 433 formatted_results.append("s:").append(list.subs); |
434 formatted_results.append("\n"); | 434 formatted_results.append("\n"); |
435 | 435 |
436 return formatted_results; | 436 return formatted_results; |
437 } | 437 } |
438 | 438 |
439 } // namespace safe_browsing | 439 } // namespace safe_browsing |
OLD | NEW |