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 "net/cert/multi_threaded_cert_verifier.h" | 5 #include "net/cert/multi_threaded_cert_verifier.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> |
8 | 9 |
9 #include "base/bind.h" | 10 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
11 #include "base/callback_helpers.h" | 12 #include "base/callback_helpers.h" |
12 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
13 #include "base/containers/linked_list.h" | 14 #include "base/containers/linked_list.h" |
14 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
15 #include "base/metrics/histogram_macros.h" | 16 #include "base/metrics/histogram_macros.h" |
16 #include "base/profiler/scoped_tracker.h" | 17 #include "base/profiler/scoped_tracker.h" |
17 #include "base/sha1.h" | 18 #include "base/sha1.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 NetLogX509CertificateCallback(verify_result.verified_cert.get(), | 100 NetLogX509CertificateCallback(verify_result.verified_cert.get(), |
100 capture_mode)); | 101 capture_mode)); |
101 | 102 |
102 scoped_ptr<base::ListValue> hashes(new base::ListValue()); | 103 scoped_ptr<base::ListValue> hashes(new base::ListValue()); |
103 for (std::vector<HashValue>::const_iterator it = | 104 for (std::vector<HashValue>::const_iterator it = |
104 verify_result.public_key_hashes.begin(); | 105 verify_result.public_key_hashes.begin(); |
105 it != verify_result.public_key_hashes.end(); | 106 it != verify_result.public_key_hashes.end(); |
106 ++it) { | 107 ++it) { |
107 hashes->AppendString(it->ToString()); | 108 hashes->AppendString(it->ToString()); |
108 } | 109 } |
109 results->Set("public_key_hashes", hashes.Pass()); | 110 results->Set("public_key_hashes", std::move(hashes)); |
110 | 111 |
111 return results.Pass(); | 112 return std::move(results); |
112 } | 113 } |
113 | 114 |
114 } // namespace | 115 } // namespace |
115 | 116 |
116 MultiThreadedCertVerifier::CachedResult::CachedResult() : error(ERR_FAILED) {} | 117 MultiThreadedCertVerifier::CachedResult::CachedResult() : error(ERR_FAILED) {} |
117 | 118 |
118 MultiThreadedCertVerifier::CachedResult::~CachedResult() {} | 119 MultiThreadedCertVerifier::CachedResult::~CachedResult() {} |
119 | 120 |
120 MultiThreadedCertVerifier::CacheValidityPeriod::CacheValidityPeriod( | 121 MultiThreadedCertVerifier::CacheValidityPeriod::CacheValidityPeriod( |
121 const base::Time& now) | 122 const base::Time& now) |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 CertVerifyResult* verify_result, | 323 CertVerifyResult* verify_result, |
323 const BoundNetLog& net_log) { | 324 const BoundNetLog& net_log) { |
324 scoped_ptr<CertVerifierRequest> request( | 325 scoped_ptr<CertVerifierRequest> request( |
325 new CertVerifierRequest(this, callback, verify_result, net_log)); | 326 new CertVerifierRequest(this, callback, verify_result, net_log)); |
326 | 327 |
327 request->net_log().AddEvent( | 328 request->net_log().AddEvent( |
328 NetLog::TYPE_CERT_VERIFIER_REQUEST_BOUND_TO_JOB, | 329 NetLog::TYPE_CERT_VERIFIER_REQUEST_BOUND_TO_JOB, |
329 net_log_.source().ToEventParametersCallback()); | 330 net_log_.source().ToEventParametersCallback()); |
330 | 331 |
331 requests_.Append(request.get()); | 332 requests_.Append(request.get()); |
332 return request.Pass(); | 333 return request; |
333 } | 334 } |
334 | 335 |
335 private: | 336 private: |
336 using RequestList = base::LinkedList<CertVerifierRequest>; | 337 using RequestList = base::LinkedList<CertVerifierRequest>; |
337 | 338 |
338 // Called on completion of the Job to log UMA metrics and NetLog events. | 339 // Called on completion of the Job to log UMA metrics and NetLog events. |
339 void LogMetrics( | 340 void LogMetrics( |
340 const MultiThreadedCertVerifier::CachedResult& verify_result) { | 341 const MultiThreadedCertVerifier::CachedResult& verify_result) { |
341 net_log_.EndEvent( | 342 net_log_.EndEvent( |
342 NetLog::TYPE_CERT_VERIFIER_JOB, | 343 NetLog::TYPE_CERT_VERIFIER_JOB, |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 | 462 |
462 job = new_job.release(); | 463 job = new_job.release(); |
463 inflight_.insert(job); | 464 inflight_.insert(job); |
464 | 465 |
465 if (requests_ == 1) | 466 if (requests_ == 1) |
466 job->set_is_first_job(true); | 467 job->set_is_first_job(true); |
467 } | 468 } |
468 | 469 |
469 scoped_ptr<CertVerifierRequest> request = | 470 scoped_ptr<CertVerifierRequest> request = |
470 job->CreateRequest(callback, verify_result, net_log); | 471 job->CreateRequest(callback, verify_result, net_log); |
471 *out_req = request.Pass(); | 472 *out_req = std::move(request); |
472 return ERR_IO_PENDING; | 473 return ERR_IO_PENDING; |
473 } | 474 } |
474 | 475 |
475 bool MultiThreadedCertVerifier::SupportsOCSPStapling() { | 476 bool MultiThreadedCertVerifier::SupportsOCSPStapling() { |
476 return verify_proc_->SupportsOCSPStapling(); | 477 return verify_proc_->SupportsOCSPStapling(); |
477 } | 478 } |
478 | 479 |
479 MultiThreadedCertVerifier::RequestParams::RequestParams( | 480 MultiThreadedCertVerifier::RequestParams::RequestParams( |
480 const SHA1HashValue& cert_fingerprint_arg, | 481 const SHA1HashValue& cert_fingerprint_arg, |
481 const SHA1HashValue& ca_fingerprint_arg, | 482 const SHA1HashValue& ca_fingerprint_arg, |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 // search. | 582 // search. |
582 auto it = std::lower_bound(inflight_.begin(), inflight_.end(), key, | 583 auto it = std::lower_bound(inflight_.begin(), inflight_.end(), key, |
583 JobToRequestParamsComparator()); | 584 JobToRequestParamsComparator()); |
584 if (it != inflight_.end() && !(key < (*it)->key())) | 585 if (it != inflight_.end() && !(key < (*it)->key())) |
585 return *it; | 586 return *it; |
586 return nullptr; | 587 return nullptr; |
587 } | 588 } |
588 | 589 |
589 } // namespace net | 590 } // namespace net |
590 | 591 |
OLD | NEW |