Chromium Code Reviews| 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 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
| 15 #include "base/synchronization/lock.h" | 15 #include "base/synchronization/lock.h" |
| 16 #include "base/threading/worker_pool.h" | 16 #include "base/threading/worker_pool.h" |
| 17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 18 #include "base/values.h" | |
| 19 #include "net/base/hash_value.h" | |
| 18 #include "net/base/net_errors.h" | 20 #include "net/base/net_errors.h" |
| 19 #include "net/base/net_log.h" | 21 #include "net/base/net_log.h" |
| 22 #include "net/cert/cert_status_flags.h" | |
|
Ryan Sleevi
2014/05/31 02:41:11
I don't believe you need this header anymore? We'r
mshelley
2014/06/02 20:40:06
Done.
| |
| 20 #include "net/cert/cert_trust_anchor_provider.h" | 23 #include "net/cert/cert_trust_anchor_provider.h" |
| 21 #include "net/cert/cert_verify_proc.h" | 24 #include "net/cert/cert_verify_proc.h" |
| 22 #include "net/cert/crl_set.h" | 25 #include "net/cert/crl_set.h" |
| 23 #include "net/cert/x509_certificate.h" | 26 #include "net/cert/x509_certificate.h" |
| 24 #include "net/cert/x509_certificate_net_log_param.h" | 27 #include "net/cert/x509_certificate_net_log_param.h" |
| 25 | 28 |
| 26 #if defined(USE_NSS) || defined(OS_IOS) | 29 #if defined(USE_NSS) || defined(OS_IOS) |
| 27 #include <private/pprthred.h> // PR_DetachThread | 30 #include <private/pprthred.h> // PR_DetachThread |
| 28 #endif | 31 #endif |
| 29 | 32 |
| 33 namespace { | |
|
wtc
2014/05/31 02:48:03
I suggest that you nest this unnamed namespace ins
mshelley
2014/06/02 20:40:06
Done.
| |
| 34 | |
| 35 base::Value* CertVerifyResultCallback(net::CertVerifyResult verify_result, | |
|
Ryan Sleevi
2014/05/31 02:41:11
STYLE: So, in the previous comment, I mentioned yo
wtc
2014/05/31 02:48:03
Since CertVerifyResult is a struct with several me
mshelley
2014/06/02 20:40:06
Done.
mshelley
2014/06/02 20:40:06
Done.
mshelley
2014/06/02 20:40:06
Done.
mshelley
2014/06/02 20:40:06
Done.
mshelley
2014/06/02 20:40:06
Done.
mshelley
2014/06/02 20:40:06
Done.
mshelley
2014/06/02 20:40:06
Done.
mshelley
2014/06/02 20:40:06
Done.
| |
| 36 net::NetLog::LogLevel log_level) { | |
| 37 base::DictionaryValue* results = new base::DictionaryValue(); | |
| 38 results->SetBoolean("has_md5", verify_result.has_md5); | |
| 39 results->SetBoolean("has_md2", verify_result.has_md2); | |
| 40 results->SetBoolean("has_md4", verify_result.has_md4); | |
| 41 results->SetBoolean("is_issued_by_known_root", | |
| 42 verify_result.is_issued_by_known_root); | |
| 43 results->SetBoolean("is_issued_by_additional_trust_anchor", | |
| 44 verify_result.is_issued_by_additional_trust_anchor); | |
| 45 results->SetBoolean("common_name_fallback_used", | |
| 46 verify_result.common_name_fallback_used); | |
| 47 results->SetInteger("cert_status", verify_result.cert_status); | |
| 48 results->Set("verified_cert", | |
| 49 net::NetLogX509CertificateCallback(verify_result.verified_cert, | |
| 50 log_level)); | |
| 51 base::ListValue* hashes = new base::ListValue(); | |
| 52 for (std::vector<net::HashValue>::const_iterator it = | |
| 53 verify_result.public_key_hashes.begin(); | |
| 54 it != verify_result.public_key_hashes.end(); | |
| 55 it++) { | |
|
wtc
2014/05/31 02:48:03
Use pre-increment to increment an iterator. See th
mshelley
2014/06/02 20:40:06
Done.
| |
| 56 hashes->AppendString(it->ToString()); | |
| 57 } | |
| 58 | |
| 59 results->Set("public_key_hashes", hashes); | |
| 60 | |
| 61 return results; | |
| 62 } | |
| 63 } | |
|
wtc
2014/05/31 02:48:03
1. Add a blank line before this line.
2. This lin
mshelley
2014/06/02 20:40:06
Done.
| |
| 64 | |
| 30 namespace net { | 65 namespace net { |
| 31 | 66 |
| 32 //////////////////////////////////////////////////////////////////////////// | 67 //////////////////////////////////////////////////////////////////////////// |
| 33 | 68 |
| 34 // Life of a request: | 69 // Life of a request: |
| 35 // | 70 // |
| 36 // MultiThreadedCertVerifier CertVerifierJob CertVerifierWorker Request | 71 // MultiThreadedCertVerifier CertVerifierJob CertVerifierWorker Request |
| 37 // | (origin loop) (worker loop) | 72 // | (origin loop) (worker loop) |
| 38 // | | 73 // | |
| 39 // Verify() | 74 // Verify() |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 344 NetLog::TYPE_CERT_VERIFIER_REQUEST_BOUND_TO_JOB, | 379 NetLog::TYPE_CERT_VERIFIER_REQUEST_BOUND_TO_JOB, |
| 345 net_log_.source().ToEventParametersCallback()); | 380 net_log_.source().ToEventParametersCallback()); |
| 346 | 381 |
| 347 requests_.push_back(request); | 382 requests_.push_back(request); |
| 348 } | 383 } |
| 349 | 384 |
| 350 void HandleResult( | 385 void HandleResult( |
| 351 const MultiThreadedCertVerifier::CachedResult& verify_result, | 386 const MultiThreadedCertVerifier::CachedResult& verify_result, |
| 352 bool is_first_job) { | 387 bool is_first_job) { |
| 353 worker_ = NULL; | 388 worker_ = NULL; |
| 354 net_log_.EndEvent(NetLog::TYPE_CERT_VERIFIER_JOB); | 389 net_log_.EndEvent( |
| 390 NetLog::TYPE_CERT_VERIFIER_JOB, | |
| 391 base::Bind(&CertVerifyResultCallback, verify_result.result)); | |
| 355 base::TimeDelta latency = base::TimeTicks::Now() - start_time_; | 392 base::TimeDelta latency = base::TimeTicks::Now() - start_time_; |
| 356 UMA_HISTOGRAM_CUSTOM_TIMES("Net.CertVerifier_Job_Latency", | 393 UMA_HISTOGRAM_CUSTOM_TIMES("Net.CertVerifier_Job_Latency", |
| 357 latency, | 394 latency, |
| 358 base::TimeDelta::FromMilliseconds(1), | 395 base::TimeDelta::FromMilliseconds(1), |
| 359 base::TimeDelta::FromMinutes(10), | 396 base::TimeDelta::FromMinutes(10), |
| 360 100); | 397 100); |
| 361 if (is_first_job) { | 398 if (is_first_job) { |
| 362 UMA_HISTOGRAM_CUSTOM_TIMES("Net.CertVerifier_First_Job_Latency", | 399 UMA_HISTOGRAM_CUSTOM_TIMES("Net.CertVerifier_First_Job_Latency", |
| 363 latency, | 400 latency, |
| 364 base::TimeDelta::FromMilliseconds(1), | 401 base::TimeDelta::FromMilliseconds(1), |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 576 } | 613 } |
| 577 | 614 |
| 578 void MultiThreadedCertVerifier::OnCACertChanged( | 615 void MultiThreadedCertVerifier::OnCACertChanged( |
| 579 const X509Certificate* cert) { | 616 const X509Certificate* cert) { |
| 580 DCHECK(CalledOnValidThread()); | 617 DCHECK(CalledOnValidThread()); |
| 581 | 618 |
| 582 ClearCache(); | 619 ClearCache(); |
| 583 } | 620 } |
| 584 | 621 |
| 585 } // namespace net | 622 } // namespace net |
| 623 | |
| OLD | NEW |