OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "core/fetch/IntegrityMetadata.h" | 5 #include "platform/loader/fetch/IntegrityMetadata.h" |
6 | 6 |
7 namespace blink { | 7 namespace blink { |
8 | 8 |
9 IntegrityMetadata::IntegrityMetadata(WTF::String digest, | 9 IntegrityMetadata::IntegrityMetadata(WTF::String digest, |
10 HashAlgorithm algorithm) | 10 HashAlgorithm algorithm) |
11 : m_digest(digest), m_algorithm(algorithm) {} | 11 : m_digest(digest), m_algorithm(algorithm) {} |
12 | 12 |
13 IntegrityMetadata::IntegrityMetadata(std::pair<WTF::String, HashAlgorithm> pair) | 13 IntegrityMetadata::IntegrityMetadata(std::pair<WTF::String, HashAlgorithm> pair) |
14 : m_digest(pair.first), m_algorithm(pair.second) {} | 14 : m_digest(pair.first), m_algorithm(pair.second) {} |
15 | 15 |
16 std::pair<WTF::String, HashAlgorithm> IntegrityMetadata::toPair() const { | 16 std::pair<WTF::String, HashAlgorithm> IntegrityMetadata::toPair() const { |
17 return std::pair<WTF::String, HashAlgorithm>(m_digest, m_algorithm); | 17 return std::pair<WTF::String, HashAlgorithm>(m_digest, m_algorithm); |
18 } | 18 } |
19 | 19 |
20 bool IntegrityMetadata::setsEqual(const IntegrityMetadataSet& set1, | 20 bool IntegrityMetadata::setsEqual(const IntegrityMetadataSet& set1, |
21 const IntegrityMetadataSet& set2) { | 21 const IntegrityMetadataSet& set2) { |
22 if (set1.size() != set2.size()) | 22 if (set1.size() != set2.size()) |
23 return false; | 23 return false; |
24 | 24 |
25 for (const IntegrityMetadataPair& metadata : set1) { | 25 for (const IntegrityMetadataPair& metadata : set1) { |
26 if (!set2.contains(metadata)) | 26 if (!set2.contains(metadata)) |
27 return false; | 27 return false; |
28 } | 28 } |
29 | 29 |
30 return true; | 30 return true; |
31 } | 31 } |
32 | 32 |
33 } // namespace blink | 33 } // namespace blink |
OLD | NEW |