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

Side by Side Diff: net/quic/crypto/proof_verifier_chromium.cc

Issue 2126023002: use std::unique_ptr for the callback argument of QUIC's ProofVerifier::Verify proof to make ownersh… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@126327823
Patch Set: Created 4 years, 5 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "net/quic/crypto/proof_verifier_chromium.h" 5 #include "net/quic/crypto/proof_verifier_chromium.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 const std::string& hostname, 69 const std::string& hostname,
70 const uint16_t port, 70 const uint16_t port,
71 const std::string& server_config, 71 const std::string& server_config,
72 QuicVersion quic_version, 72 QuicVersion quic_version,
73 base::StringPiece chlo_hash, 73 base::StringPiece chlo_hash,
74 const std::vector<std::string>& certs, 74 const std::vector<std::string>& certs,
75 const std::string& cert_sct, 75 const std::string& cert_sct,
76 const std::string& signature, 76 const std::string& signature,
77 std::string* error_details, 77 std::string* error_details,
78 std::unique_ptr<ProofVerifyDetails>* verify_details, 78 std::unique_ptr<ProofVerifyDetails>* verify_details,
79 ProofVerifierCallback* callback); 79 std::unique_ptr<ProofVerifierCallback> callback);
80 80
81 private: 81 private:
82 enum State { 82 enum State {
83 STATE_NONE, 83 STATE_NONE,
84 STATE_VERIFY_CERT, 84 STATE_VERIFY_CERT,
85 STATE_VERIFY_CERT_COMPLETE, 85 STATE_VERIFY_CERT_COMPLETE,
86 }; 86 };
87 87
88 int DoLoop(int last_io_result); 88 int DoLoop(int last_io_result);
89 void OnIOComplete(int result); 89 void OnIOComplete(int result);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 const string& hostname, 173 const string& hostname,
174 const uint16_t port, 174 const uint16_t port,
175 const string& server_config, 175 const string& server_config,
176 QuicVersion quic_version, 176 QuicVersion quic_version,
177 StringPiece chlo_hash, 177 StringPiece chlo_hash,
178 const vector<string>& certs, 178 const vector<string>& certs,
179 const std::string& cert_sct, 179 const std::string& cert_sct,
180 const string& signature, 180 const string& signature,
181 std::string* error_details, 181 std::string* error_details,
182 std::unique_ptr<ProofVerifyDetails>* verify_details, 182 std::unique_ptr<ProofVerifyDetails>* verify_details,
183 ProofVerifierCallback* callback) { 183 std::unique_ptr<ProofVerifierCallback> callback) {
184 DCHECK(error_details); 184 DCHECK(error_details);
185 DCHECK(verify_details); 185 DCHECK(verify_details);
186 DCHECK(callback);
rjshade 2016/07/06 20:09:34 Not sure about this removal, but the following tes
Ryan Hamilton 2016/07/07 00:10:35 Hm. That sounds dodgy. DO you have a failure log?
187 186
188 error_details->clear(); 187 error_details->clear();
189 188
190 if (STATE_NONE != next_state_) { 189 if (STATE_NONE != next_state_) {
191 *error_details = "Certificate is already set and VerifyProof has begun"; 190 *error_details = "Certificate is already set and VerifyProof has begun";
192 DLOG(DFATAL) << *error_details; 191 DLOG(DFATAL) << *error_details;
193 return QUIC_FAILURE; 192 return QUIC_FAILURE;
194 } 193 }
195 194
196 verify_details_.reset(new ProofVerifyDetailsChromium); 195 verify_details_.reset(new ProofVerifyDetailsChromium);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 238
240 hostname_ = hostname; 239 hostname_ = hostname;
241 port_ = port; 240 port_ = port;
242 241
243 next_state_ = STATE_VERIFY_CERT; 242 next_state_ = STATE_VERIFY_CERT;
244 switch (DoLoop(OK)) { 243 switch (DoLoop(OK)) {
245 case OK: 244 case OK:
246 *verify_details = std::move(verify_details_); 245 *verify_details = std::move(verify_details_);
247 return QUIC_SUCCESS; 246 return QUIC_SUCCESS;
248 case ERR_IO_PENDING: 247 case ERR_IO_PENDING:
249 callback_.reset(callback); 248 callback_ = std::move(callback);
250 return QUIC_PENDING; 249 return QUIC_PENDING;
251 default: 250 default:
252 *error_details = error_details_; 251 *error_details = error_details_;
253 *verify_details = std::move(verify_details_); 252 *verify_details = std::move(verify_details_);
254 return QUIC_FAILURE; 253 return QUIC_FAILURE;
255 } 254 }
256 } 255 }
257 256
258 int ProofVerifierChromium::Job::DoLoop(int last_result) { 257 int ProofVerifierChromium::Job::DoLoop(int last_result) {
259 int rv = last_result; 258 int rv = last_result;
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 const uint16_t port, 483 const uint16_t port,
485 const std::string& server_config, 484 const std::string& server_config,
486 QuicVersion quic_version, 485 QuicVersion quic_version,
487 base::StringPiece chlo_hash, 486 base::StringPiece chlo_hash,
488 const std::vector<std::string>& certs, 487 const std::vector<std::string>& certs,
489 const std::string& cert_sct, 488 const std::string& cert_sct,
490 const std::string& signature, 489 const std::string& signature,
491 const ProofVerifyContext* verify_context, 490 const ProofVerifyContext* verify_context,
492 std::string* error_details, 491 std::string* error_details,
493 std::unique_ptr<ProofVerifyDetails>* verify_details, 492 std::unique_ptr<ProofVerifyDetails>* verify_details,
494 ProofVerifierCallback* callback) { 493 std::unique_ptr<ProofVerifierCallback> callback) {
495 if (!verify_context) { 494 if (!verify_context) {
496 *error_details = "Missing context"; 495 *error_details = "Missing context";
497 return QUIC_FAILURE; 496 return QUIC_FAILURE;
498 } 497 }
499 const ProofVerifyContextChromium* chromium_context = 498 const ProofVerifyContextChromium* chromium_context =
500 reinterpret_cast<const ProofVerifyContextChromium*>(verify_context); 499 reinterpret_cast<const ProofVerifyContextChromium*>(verify_context);
501 std::unique_ptr<Job> job( 500 std::unique_ptr<Job> job(
502 new Job(this, cert_verifier_, ct_policy_enforcer_, 501 new Job(this, cert_verifier_, ct_policy_enforcer_,
503 transport_security_state_, cert_transparency_verifier_, 502 transport_security_state_, cert_transparency_verifier_,
504 chromium_context->cert_verify_flags, chromium_context->net_log)); 503 chromium_context->cert_verify_flags, chromium_context->net_log));
505 QuicAsyncStatus status = job->VerifyProof( 504 QuicAsyncStatus status = job->VerifyProof(
506 hostname, port, server_config, quic_version, chlo_hash, certs, cert_sct, 505 hostname, port, server_config, quic_version, chlo_hash, certs, cert_sct,
507 signature, error_details, verify_details, callback); 506 signature, error_details, verify_details, std::move(callback));
508 if (status == QUIC_PENDING) { 507 if (status == QUIC_PENDING) {
509 active_jobs_.insert(job.release()); 508 active_jobs_.insert(job.release());
510 } 509 }
511 return status; 510 return status;
512 } 511 }
513 512
514 void ProofVerifierChromium::OnJobComplete(Job* job) { 513 void ProofVerifierChromium::OnJobComplete(Job* job) {
515 active_jobs_.erase(job); 514 active_jobs_.erase(job);
516 delete job; 515 delete job;
517 } 516 }
518 517
519 } // namespace net 518 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/proof_verifier_chromium.h ('k') | net/quic/crypto/proof_verifier_chromium_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698