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

Side by Side Diff: net/cert/single_request_cert_verifier.cc

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
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/cert/single_request_cert_verifier.h" 5 #include "net/cert/single_request_cert_verifier.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
10 #include "net/cert/x509_certificate.h" 10 #include "net/cert/x509_certificate.h"
11 11
12 namespace net { 12 namespace net {
13 13
14 SingleRequestCertVerifier::SingleRequestCertVerifier( 14 SingleRequestCertVerifier::SingleRequestCertVerifier(
15 CertVerifier* cert_verifier) 15 CertVerifier* cert_verifier)
16 : cert_verifier_(cert_verifier), 16 : cert_verifier_(cert_verifier), cur_request_(NULL) {
17 cur_request_(NULL) {
18 DCHECK(cert_verifier_ != NULL); 17 DCHECK(cert_verifier_ != NULL);
19 } 18 }
20 19
21 SingleRequestCertVerifier::~SingleRequestCertVerifier() { 20 SingleRequestCertVerifier::~SingleRequestCertVerifier() {
22 if (cur_request_) { 21 if (cur_request_) {
23 cert_verifier_->CancelRequest(cur_request_); 22 cert_verifier_->CancelRequest(cur_request_);
24 cur_request_ = NULL; 23 cur_request_ = NULL;
25 } 24 }
26 } 25 }
27 26
28 int SingleRequestCertVerifier::Verify(X509Certificate* cert, 27 int SingleRequestCertVerifier::Verify(X509Certificate* cert,
29 const std::string& hostname, 28 const std::string& hostname,
30 int flags, 29 int flags,
31 CRLSet* crl_set, 30 CRLSet* crl_set,
32 CertVerifyResult* verify_result, 31 CertVerifyResult* verify_result,
33 const CompletionCallback& callback, 32 const CompletionCallback& callback,
34 const BoundNetLog& net_log) { 33 const BoundNetLog& net_log) {
35 // Should not be already in use. 34 // Should not be already in use.
36 DCHECK(!cur_request_ && cur_request_callback_.is_null()); 35 DCHECK(!cur_request_ && cur_request_callback_.is_null());
37 36
38 CertVerifier::RequestHandle request = NULL; 37 CertVerifier::RequestHandle request = NULL;
39 38
40 // We need to be notified of completion before |callback| is called, so that 39 // We need to be notified of completion before |callback| is called, so that
41 // we can clear out |cur_request_*|. 40 // we can clear out |cur_request_*|.
42 int rv = cert_verifier_->Verify( 41 int rv = cert_verifier_->Verify(
43 cert, hostname, flags, crl_set, verify_result, 42 cert,
43 hostname,
44 flags,
45 crl_set,
46 verify_result,
44 base::Bind(&SingleRequestCertVerifier::OnVerifyCompletion, 47 base::Bind(&SingleRequestCertVerifier::OnVerifyCompletion,
45 base::Unretained(this)), 48 base::Unretained(this)),
46 &request, net_log); 49 &request,
50 net_log);
47 51
48 if (rv == ERR_IO_PENDING) { 52 if (rv == ERR_IO_PENDING) {
49 // Cleared in OnVerifyCompletion(). 53 // Cleared in OnVerifyCompletion().
50 cur_request_ = request; 54 cur_request_ = request;
51 cur_request_callback_ = callback; 55 cur_request_callback_ = callback;
52 } 56 }
53 57
54 return rv; 58 return rv;
55 } 59 }
56 60
57 void SingleRequestCertVerifier::OnVerifyCompletion(int result) { 61 void SingleRequestCertVerifier::OnVerifyCompletion(int result) {
58 DCHECK(cur_request_ && !cur_request_callback_.is_null()); 62 DCHECK(cur_request_ && !cur_request_callback_.is_null());
59 63
60 CompletionCallback callback = cur_request_callback_; 64 CompletionCallback callback = cur_request_callback_;
61 65
62 // Clear the outstanding request information. 66 // Clear the outstanding request information.
63 cur_request_ = NULL; 67 cur_request_ = NULL;
64 cur_request_callback_.Reset(); 68 cur_request_callback_.Reset();
65 69
66 // Call the user's original callback. 70 // Call the user's original callback.
67 callback.Run(result); 71 callback.Run(result);
68 } 72 }
69 73
70 } // namespace net 74 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698