| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/browser/chromeos/policy/policy_cert_verifier.h" | 5 #include "chrome/browser/chromeos/policy/policy_cert_verifier.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
| 10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| 11 #include "net/cert/cert_verify_proc.h" | 11 #include "net/cert/cert_verify_proc.h" |
| 12 #include "net/cert/multi_threaded_cert_verifier.h" | 12 #include "net/cert/multi_threaded_cert_verifier.h" |
| 13 | 13 |
| 14 namespace policy { | 14 namespace policy { |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 void MaybeSignalAnchorUse(int error, | 18 void MaybeSignalAnchorUse(int error, |
| 19 const base::Closure& anchor_used_callback, | 19 const base::Closure& anchor_used_callback, |
| 20 const net::CertVerifyResult& verify_result) { | 20 const net::CertVerifyResult& verify_result) { |
| 21 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 21 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 22 if (error != net::OK || !verify_result.is_issued_by_additional_trust_anchor || | 22 if (error != net::OK || !verify_result.is_issued_by_additional_trust_anchor || |
| 23 anchor_used_callback.is_null()) { | 23 anchor_used_callback.is_null()) { |
| 24 return; | 24 return; |
| 25 } | 25 } |
| 26 anchor_used_callback.Run(); | 26 anchor_used_callback.Run(); |
| 27 } | 27 } |
| 28 | 28 |
| 29 void CompleteAndSignalAnchorUse( | 29 void CompleteAndSignalAnchorUse( |
| 30 const base::Closure& anchor_used_callback, | 30 const base::Closure& anchor_used_callback, |
| 31 const net::CompletionCallback& completion_callback, | 31 const net::CompletionCallback& completion_callback, |
| 32 const net::CertVerifyResult* verify_result, | 32 const net::CertVerifyResult* verify_result, |
| 33 int error) { | 33 int error) { |
| 34 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 34 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 35 MaybeSignalAnchorUse(error, anchor_used_callback, *verify_result); | 35 MaybeSignalAnchorUse(error, anchor_used_callback, *verify_result); |
| 36 if (!completion_callback.is_null()) | 36 if (!completion_callback.is_null()) |
| 37 completion_callback.Run(error); | 37 completion_callback.Run(error); |
| 38 } | 38 } |
| 39 | 39 |
| 40 } // namespace | 40 } // namespace |
| 41 | 41 |
| 42 PolicyCertVerifier::PolicyCertVerifier( | 42 PolicyCertVerifier::PolicyCertVerifier( |
| 43 const base::Closure& anchor_used_callback) | 43 const base::Closure& anchor_used_callback) |
| 44 : anchor_used_callback_(anchor_used_callback) { | 44 : anchor_used_callback_(anchor_used_callback) { |
| 45 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 45 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 46 } | 46 } |
| 47 | 47 |
| 48 PolicyCertVerifier::~PolicyCertVerifier() { | 48 PolicyCertVerifier::~PolicyCertVerifier() { |
| 49 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 49 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
| 50 } | 50 } |
| 51 | 51 |
| 52 void PolicyCertVerifier::InitializeOnIOThread( | 52 void PolicyCertVerifier::InitializeOnIOThread( |
| 53 const scoped_refptr<net::CertVerifyProc>& verify_proc) { | 53 const scoped_refptr<net::CertVerifyProc>& verify_proc) { |
| 54 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 54 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
| 55 if (!verify_proc->SupportsAdditionalTrustAnchors()) { | 55 if (!verify_proc->SupportsAdditionalTrustAnchors()) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 94 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
| 95 delegate_->CancelRequest(req); | 95 delegate_->CancelRequest(req); |
| 96 } | 96 } |
| 97 | 97 |
| 98 const net::CertificateList& PolicyCertVerifier::GetAdditionalTrustAnchors() { | 98 const net::CertificateList& PolicyCertVerifier::GetAdditionalTrustAnchors() { |
| 99 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 99 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
| 100 return trust_anchors_; | 100 return trust_anchors_; |
| 101 } | 101 } |
| 102 | 102 |
| 103 } // namespace policy | 103 } // namespace policy |
| OLD | NEW |