| 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 #include "chrome/browser/safe_browsing/safe_browsing_util.h" | 5 #include "chrome/browser/safe_browsing/safe_browsing_util.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| 11 #include "chrome/browser/safe_browsing/chunk.pb.h" | 11 #include "chrome/browser/safe_browsing/chunk.pb.h" |
| 12 #include "components/google/core/browser/google_util.h" | 12 #include "components/google/core/browser/google_util.h" |
| 13 | 13 |
| 14 namespace safe_browsing { | 14 namespace safe_browsing { |
| 15 | 15 |
| 16 // SBChunkData ----------------------------------------------------------------- | 16 // SBChunkData ----------------------------------------------------------------- |
| 17 | 17 |
| 18 // TODO(shess): Right now this contains a scoped_ptr<ChunkData> so that the | 18 // TODO(shess): Right now this contains a std::unique_ptr<ChunkData> so that the |
| 19 // proto buffer isn't copied all over the place, then these are contained in a | 19 // proto buffer isn't copied all over the place, then these are contained in a |
| 20 // ScopedVector for purposes of passing things around between tasks. This seems | 20 // ScopedVector for purposes of passing things around between tasks. This seems |
| 21 // convoluted. Maybe it would make sense to have an overall container class | 21 // convoluted. Maybe it would make sense to have an overall container class |
| 22 // returning references to a nested per-chunk class? | 22 // returning references to a nested per-chunk class? |
| 23 | 23 |
| 24 SBChunkData::SBChunkData() { | 24 SBChunkData::SBChunkData() { |
| 25 } | 25 } |
| 26 | 26 |
| 27 SBChunkData::SBChunkData(scoped_ptr<ChunkData> data) | 27 SBChunkData::SBChunkData(std::unique_ptr<ChunkData> data) |
| 28 : chunk_data_(std::move(data)) { | 28 : chunk_data_(std::move(data)) { |
| 29 DCHECK(chunk_data_.get()); | 29 DCHECK(chunk_data_.get()); |
| 30 } | 30 } |
| 31 | 31 |
| 32 SBChunkData::~SBChunkData() { | 32 SBChunkData::~SBChunkData() { |
| 33 } | 33 } |
| 34 | 34 |
| 35 bool SBChunkData::ParseFrom(const unsigned char* data, size_t length) { | 35 bool SBChunkData::ParseFrom(const unsigned char* data, size_t length) { |
| 36 scoped_ptr<ChunkData> chunk(new ChunkData()); | 36 std::unique_ptr<ChunkData> chunk(new ChunkData()); |
| 37 if (!chunk->ParseFromArray(data, length)) | 37 if (!chunk->ParseFromArray(data, length)) |
| 38 return false; | 38 return false; |
| 39 | 39 |
| 40 if (chunk->chunk_type() != ChunkData::ADD && | 40 if (chunk->chunk_type() != ChunkData::ADD && |
| 41 chunk->chunk_type() != ChunkData::SUB) { | 41 chunk->chunk_type() != ChunkData::SUB) { |
| 42 return false; | 42 return false; |
| 43 } | 43 } |
| 44 | 44 |
| 45 size_t hash_size = 0; | 45 size_t hash_size = 0; |
| 46 if (chunk->prefix_type() == ChunkData::PREFIX_4B) { | 46 if (chunk->prefix_type() == ChunkData::PREFIX_4B) { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 | 129 |
| 130 // SBChunkDelete --------------------------------------------------------------- | 130 // SBChunkDelete --------------------------------------------------------------- |
| 131 | 131 |
| 132 SBChunkDelete::SBChunkDelete() : is_sub_del(false) {} | 132 SBChunkDelete::SBChunkDelete() : is_sub_del(false) {} |
| 133 | 133 |
| 134 SBChunkDelete::SBChunkDelete(const SBChunkDelete& other) = default; | 134 SBChunkDelete::SBChunkDelete(const SBChunkDelete& other) = default; |
| 135 | 135 |
| 136 SBChunkDelete::~SBChunkDelete() {} | 136 SBChunkDelete::~SBChunkDelete() {} |
| 137 | 137 |
| 138 } // namespace safe_browsing | 138 } // namespace safe_browsing |
| OLD | NEW |