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 "net/base/hash_value.h" | |
18 #include "net/base/net_errors.h" | 19 #include "net/base/net_errors.h" |
19 #include "net/base/net_log.h" | 20 #include "net/cert/cert_status_flags.h" |
20 #include "net/cert/cert_trust_anchor_provider.h" | 21 #include "net/cert/cert_trust_anchor_provider.h" |
21 #include "net/cert/cert_verify_proc.h" | 22 #include "net/cert/cert_verify_proc.h" |
22 #include "net/cert/crl_set.h" | 23 #include "net/cert/crl_set.h" |
23 #include "net/cert/x509_certificate.h" | 24 #include "net/cert/x509_certificate.h" |
24 #include "net/cert/x509_certificate_net_log_param.h" | 25 #include "net/cert/x509_certificate_net_log_param.h" |
25 | 26 |
26 #if defined(USE_NSS) || defined(OS_IOS) | 27 #if defined(USE_NSS) || defined(OS_IOS) |
27 #include <private/pprthred.h> // PR_DetachThread | 28 #include <private/pprthred.h> // PR_DetachThread |
28 #endif | 29 #endif |
29 | 30 |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
343 request->net_log().AddEvent( | 344 request->net_log().AddEvent( |
344 NetLog::TYPE_CERT_VERIFIER_REQUEST_BOUND_TO_JOB, | 345 NetLog::TYPE_CERT_VERIFIER_REQUEST_BOUND_TO_JOB, |
345 net_log_.source().ToEventParametersCallback()); | 346 net_log_.source().ToEventParametersCallback()); |
346 | 347 |
347 requests_.push_back(request); | 348 requests_.push_back(request); |
348 } | 349 } |
349 | 350 |
350 void HandleResult( | 351 void HandleResult( |
351 const MultiThreadedCertVerifier::CachedResult& verify_result, | 352 const MultiThreadedCertVerifier::CachedResult& verify_result, |
352 bool is_first_job) { | 353 bool is_first_job) { |
354 /* net_log_.AddEvent( | |
355 NetLog::TYPE_CERT_VERIFIER_JOB, | |
356 base::Bind(&CertVerifyResultCallback, verify_result.result));*/ | |
Ryan Sleevi
2014/05/31 00:53:02
Delete, not comment :)
mshelley
2014/05/31 01:50:39
Done. My mistake -- I meant to go back and delete
| |
353 worker_ = NULL; | 357 worker_ = NULL; |
354 net_log_.EndEvent(NetLog::TYPE_CERT_VERIFIER_JOB); | 358 net_log_.EndEvent( |
359 NetLog::TYPE_CERT_VERIFIER_JOB, | |
360 base::Bind(&CertVerifyResultCallback, verify_result.result)); | |
355 base::TimeDelta latency = base::TimeTicks::Now() - start_time_; | 361 base::TimeDelta latency = base::TimeTicks::Now() - start_time_; |
356 UMA_HISTOGRAM_CUSTOM_TIMES("Net.CertVerifier_Job_Latency", | 362 UMA_HISTOGRAM_CUSTOM_TIMES("Net.CertVerifier_Job_Latency", |
357 latency, | 363 latency, |
358 base::TimeDelta::FromMilliseconds(1), | 364 base::TimeDelta::FromMilliseconds(1), |
359 base::TimeDelta::FromMinutes(10), | 365 base::TimeDelta::FromMinutes(10), |
360 100); | 366 100); |
361 if (is_first_job) { | 367 if (is_first_job) { |
362 UMA_HISTOGRAM_CUSTOM_TIMES("Net.CertVerifier_First_Job_Latency", | 368 UMA_HISTOGRAM_CUSTOM_TIMES("Net.CertVerifier_First_Job_Latency", |
363 latency, | 369 latency, |
364 base::TimeDelta::FromMilliseconds(1), | 370 base::TimeDelta::FromMilliseconds(1), |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
576 } | 582 } |
577 | 583 |
578 void MultiThreadedCertVerifier::OnCACertChanged( | 584 void MultiThreadedCertVerifier::OnCACertChanged( |
579 const X509Certificate* cert) { | 585 const X509Certificate* cert) { |
580 DCHECK(CalledOnValidThread()); | 586 DCHECK(CalledOnValidThread()); |
581 | 587 |
582 ClearCache(); | 588 ClearCache(); |
583 } | 589 } |
584 | 590 |
585 } // namespace net | 591 } // namespace net |
592 | |
593 namespace { | |
594 | |
595 base::Value* CertVerifyResultCallback(net::CertVerifyResult verify_result, | |
596 net::NetLog::LogLevel log_level) { | |
597 base::DictionaryValue* results = new base::DictionaryValue(); | |
598 results->SetBoolean("has_md5", verify_result.has_md5); | |
599 results->SetBoolean("has_md2", verify_result.has_md2); | |
600 results->SetBoolean("has_md4", verify_result.has_md4); | |
601 results->SetBoolean("is_issued_by_known_root", | |
602 verify_result.is_issued_by_known_root); | |
603 results->SetBoolean("is_issued_by_additional_trust_anchor", | |
604 verify_result.is_issued_by_additional_trust_anchor); | |
605 results->SetBoolean("common_name_fallback_used", | |
606 verify_result.common_name_fallback_used); | |
607 results->SetInteger("cert_status", verify_result.cert_status); | |
608 results->Set("verified_cert", | |
609 net::NetLogX509CertificateCallback(verify_result.verified_cert, | |
610 net::NetLog::LOG_ALL)); | |
Ryan Sleevi
2014/05/31 00:53:02
Just pass your log level that you receive as the p
mshelley
2014/05/31 01:50:39
Done.
| |
611 base::ListValue* hashes = new base::ListValue(); | |
612 for (std::vector<net::HashValue>::const_iterator it = | |
613 verify_result.public_key_hashes.begin(); | |
614 it != verify_result.public_key_hashes.end(); | |
615 it++) { | |
616 hashes->AppendString(it->ToString()); | |
617 } | |
618 | |
619 results->Set("public_key_hashes", hashes); | |
620 | |
621 return results; | |
622 } | |
623 } | |
OLD | NEW |