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/common/safe_browsing/zip_analyzer.h" | 5 #include "chrome/common/safe_browsing/zip_analyzer.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
| 10 #include <memory> |
10 #include <set> | 11 #include <set> |
11 | 12 |
12 #include "base/i18n/streaming_utf8_validator.h" | 13 #include "base/i18n/streaming_utf8_validator.h" |
13 #include "base/logging.h" | 14 #include "base/logging.h" |
14 #include "base/macros.h" | 15 #include "base/macros.h" |
15 #include "chrome/common/safe_browsing/binary_feature_extractor.h" | 16 #include "chrome/common/safe_browsing/binary_feature_extractor.h" |
16 #include "chrome/common/safe_browsing/csd.pb.h" | 17 #include "chrome/common/safe_browsing/csd.pb.h" |
17 #include "chrome/common/safe_browsing/download_protection_util.h" | 18 #include "chrome/common/safe_browsing/download_protection_util.h" |
18 #include "chrome/common/safe_browsing/zip_analyzer_results.h" | 19 #include "chrome/common/safe_browsing/zip_analyzer_results.h" |
19 #include "crypto/secure_hash.h" | 20 #include "crypto/secure_hash.h" |
(...skipping 10 matching lines...) Expand all Loading... |
30 class HashingFileWriter : public zip::FileWriterDelegate { | 31 class HashingFileWriter : public zip::FileWriterDelegate { |
31 public: | 32 public: |
32 explicit HashingFileWriter(base::File* file); | 33 explicit HashingFileWriter(base::File* file); |
33 | 34 |
34 // zip::FileWriterDelegate methods: | 35 // zip::FileWriterDelegate methods: |
35 bool WriteBytes(const char* data, int num_bytes) override; | 36 bool WriteBytes(const char* data, int num_bytes) override; |
36 | 37 |
37 void ComputeDigest(uint8_t* digest, size_t digest_length); | 38 void ComputeDigest(uint8_t* digest, size_t digest_length); |
38 | 39 |
39 private: | 40 private: |
40 scoped_ptr<crypto::SecureHash> sha256_; | 41 std::unique_ptr<crypto::SecureHash> sha256_; |
41 | 42 |
42 DISALLOW_COPY_AND_ASSIGN(HashingFileWriter); | 43 DISALLOW_COPY_AND_ASSIGN(HashingFileWriter); |
43 }; | 44 }; |
44 | 45 |
45 HashingFileWriter::HashingFileWriter(base::File* file) | 46 HashingFileWriter::HashingFileWriter(base::File* file) |
46 : zip::FileWriterDelegate(file), | 47 : zip::FileWriterDelegate(file), |
47 sha256_(crypto::SecureHash::Create(crypto::SecureHash::SHA256)) { | 48 sha256_(crypto::SecureHash::Create(crypto::SecureHash::SHA256)) { |
48 } | 49 } |
49 | 50 |
50 bool HashingFileWriter::WriteBytes(const char* data, int num_bytes) { | 51 bool HashingFileWriter::WriteBytes(const char* data, int num_bytes) { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 DVLOG(3) << "Ignoring non-binary file: " << file.value(); | 129 DVLOG(3) << "Ignoring non-binary file: " << file.value(); |
129 } | 130 } |
130 } | 131 } |
131 results->archived_archive_filenames.assign(archived_archive_filenames.begin(), | 132 results->archived_archive_filenames.assign(archived_archive_filenames.begin(), |
132 archived_archive_filenames.end()); | 133 archived_archive_filenames.end()); |
133 results->success = true; | 134 results->success = true; |
134 } | 135 } |
135 | 136 |
136 } // namespace zip_analyzer | 137 } // namespace zip_analyzer |
137 } // namespace safe_browsing | 138 } // namespace safe_browsing |
OLD | NEW |