Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: net/http/transport_security_state.cc

Issue 2943703002: Use ContainsValue() instead of std::find() in net/ (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/http/http_security_headers_unittest.cc ('k') | net/log/net_log.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "net/http/transport_security_state.h" 5 #include "net/http/transport_security_state.h"
6 6
7 #include <algorithm>
8 #include <memory> 7 #include <memory>
9 #include <utility> 8 #include <utility>
10 #include <vector> 9 #include <vector>
11 10
12 #include "base/base64.h" 11 #include "base/base64.h"
13 #include "base/build_time.h" 12 #include "base/build_time.h"
14 #include "base/json/json_writer.h" 13 #include "base/json/json_writer.h"
15 #include "base/logging.h" 14 #include "base/logging.h"
16 #include "base/memory/ptr_util.h" 15 #include "base/memory/ptr_util.h"
17 #include "base/metrics/histogram_macros.h" 16 #include "base/metrics/histogram_macros.h"
18 #include "base/metrics/sparse_histogram.h" 17 #include "base/metrics/sparse_histogram.h"
19 #include "base/sha1.h" 18 #include "base/sha1.h"
19 #include "base/stl_util.h"
20 #include "base/strings/string_number_conversions.h" 20 #include "base/strings/string_number_conversions.h"
21 #include "base/strings/string_util.h" 21 #include "base/strings/string_util.h"
22 #include "base/strings/stringprintf.h" 22 #include "base/strings/stringprintf.h"
23 #include "base/strings/utf_string_conversions.h" 23 #include "base/strings/utf_string_conversions.h"
24 #include "base/values.h" 24 #include "base/values.h"
25 #include "build/build_config.h" 25 #include "build/build_config.h"
26 #include "crypto/sha2.h" 26 #include "crypto/sha2.h"
27 #include "net/base/host_port_pair.h" 27 #include "net/base/host_port_pair.h"
28 #include "net/cert/ct_policy_status.h" 28 #include "net/cert/ct_policy_status.h"
29 #include "net/cert/x509_cert_types.h" 29 #include "net/cert/x509_cert_types.h"
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 char hashed[crypto::kSHA256Length]; 217 char hashed[crypto::kSHA256Length];
218 crypto::SHA256HashString(canonicalized_host, hashed, sizeof(hashed)); 218 crypto::SHA256HashString(canonicalized_host, hashed, sizeof(hashed));
219 return std::string(hashed, sizeof(hashed)); 219 return std::string(hashed, sizeof(hashed));
220 } 220 }
221 221
222 // Returns true if the intersection of |a| and |b| is not empty. If either 222 // Returns true if the intersection of |a| and |b| is not empty. If either
223 // |a| or |b| is empty, returns false. 223 // |a| or |b| is empty, returns false.
224 bool HashesIntersect(const HashValueVector& a, 224 bool HashesIntersect(const HashValueVector& a,
225 const HashValueVector& b) { 225 const HashValueVector& b) {
226 for (const auto& hash : a) { 226 for (const auto& hash : a) {
227 auto p = std::find(b.begin(), b.end(), hash); 227 if (base::ContainsValue(b, hash))
228 if (p != b.end())
229 return true; 228 return true;
230 } 229 }
231 return false; 230 return false;
232 } 231 }
233 232
234 bool AddHash(const char* sha256_hash, HashValueVector* out) { 233 bool AddHash(const char* sha256_hash, HashValueVector* out) {
235 HashValue hash(HASH_VALUE_SHA256); 234 HashValue hash(HASH_VALUE_SHA256);
236 memcpy(hash.data(), sha256_hash, hash.size()); 235 memcpy(hash.data(), sha256_hash, hash.size());
237 out->push_back(hash); 236 out->push_back(hash);
238 return true; 237 return true;
(...skipping 1604 matching lines...) Expand 10 before | Expand all | Expand 10 after
1843 TransportSecurityState::PKPStateIterator::PKPStateIterator( 1842 TransportSecurityState::PKPStateIterator::PKPStateIterator(
1844 const TransportSecurityState& state) 1843 const TransportSecurityState& state)
1845 : iterator_(state.enabled_pkp_hosts_.begin()), 1844 : iterator_(state.enabled_pkp_hosts_.begin()),
1846 end_(state.enabled_pkp_hosts_.end()) { 1845 end_(state.enabled_pkp_hosts_.end()) {
1847 } 1846 }
1848 1847
1849 TransportSecurityState::PKPStateIterator::~PKPStateIterator() { 1848 TransportSecurityState::PKPStateIterator::~PKPStateIterator() {
1850 } 1849 }
1851 1850
1852 } // namespace net 1851 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_security_headers_unittest.cc ('k') | net/log/net_log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698