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

Side by Side Diff: net/base/multi_threaded_cert_verifier.cc

Issue 10539094: NetLogEventParameter to Callback refactoring 1, (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fix headers Created 8 years, 6 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/base/multi_threaded_cert_verifier.h" 5 #include "net/base/multi_threaded_cert_verifier.h"
6 6
7 #include <vector> 7 #include <vector>
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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 flags_(flags), 145 flags_(flags),
146 crl_set_(crl_set), 146 crl_set_(crl_set),
147 origin_loop_(MessageLoop::current()), 147 origin_loop_(MessageLoop::current()),
148 cert_verifier_(cert_verifier), 148 cert_verifier_(cert_verifier),
149 canceled_(false), 149 canceled_(false),
150 error_(ERR_FAILED) { 150 error_(ERR_FAILED) {
151 } 151 }
152 152
153 // Returns the certificate being verified. May only be called /before/ 153 // Returns the certificate being verified. May only be called /before/
154 // Start() is called. 154 // Start() is called.
155 X509Certificate* certificate() const { return cert_; } 155 scoped_refptr<X509Certificate> certificate() const { return cert_; }
eroman 2012/06/11 23:42:25 Is this change necessary? Seems fine and I'm not s
mmenke 2012/06/12 00:42:19 It's not...But if it someone was being bad and kee
156 156
157 bool Start() { 157 bool Start() {
158 DCHECK_EQ(MessageLoop::current(), origin_loop_); 158 DCHECK_EQ(MessageLoop::current(), origin_loop_);
159 159
160 return base::WorkerPool::PostTask( 160 return base::WorkerPool::PostTask(
161 FROM_HERE, base::Bind(&CertVerifierWorker::Run, base::Unretained(this)), 161 FROM_HERE, base::Bind(&CertVerifierWorker::Run, base::Unretained(this)),
162 true /* task is slow */); 162 true /* task is slow */);
163 } 163 }
164 164
165 // Cancel is called from the origin loop when the MultiThreadedCertVerifier is 165 // Cancel is called from the origin loop when the MultiThreadedCertVerifier is
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 256
257 // A CertVerifierJob is a one-to-one counterpart of a CertVerifierWorker. It 257 // A CertVerifierJob is a one-to-one counterpart of a CertVerifierWorker. It
258 // lives only on the CertVerifier's origin message loop. 258 // lives only on the CertVerifier's origin message loop.
259 class CertVerifierJob { 259 class CertVerifierJob {
260 public: 260 public:
261 CertVerifierJob(CertVerifierWorker* worker, 261 CertVerifierJob(CertVerifierWorker* worker,
262 const BoundNetLog& net_log) 262 const BoundNetLog& net_log)
263 : start_time_(base::TimeTicks::Now()), 263 : start_time_(base::TimeTicks::Now()),
264 worker_(worker), 264 worker_(worker),
265 net_log_(net_log) { 265 net_log_(net_log) {
266 scoped_refptr<NetLog::EventParameters> params( 266 net_log_.BeginEvent(NetLog::TYPE_CERT_VERIFIER_JOB,
267 new X509CertificateNetLogParam(worker_->certificate())); 267 base::Bind(&NetLogX509CertificateNetLogCallback,
268 net_log_.BeginEvent(NetLog::TYPE_CERT_VERIFIER_JOB, params); 268 worker_->certificate()));
269 } 269 }
270 270
271 ~CertVerifierJob() { 271 ~CertVerifierJob() {
272 if (worker_) { 272 if (worker_) {
273 net_log_.AddEvent(NetLog::TYPE_CANCELLED, NULL); 273 net_log_.AddEvent(NetLog::TYPE_CANCELLED, NULL);
274 net_log_.EndEvent(NetLog::TYPE_CERT_VERIFIER_JOB, NULL); 274 net_log_.EndEvent(NetLog::TYPE_CERT_VERIFIER_JOB, NULL);
275 worker_->Cancel(); 275 worker_->Cancel();
276 DeleteAllCanceled(); 276 DeleteAllCanceled();
277 } 277 }
278 } 278 }
279 279
280 void AddRequest(CertVerifierRequest* request) { 280 void AddRequest(CertVerifierRequest* request) {
281 request->net_log().AddEvent( 281 request->net_log().AddEvent(
282 NetLog::TYPE_CERT_VERIFIER_REQUEST_BOUND_TO_JOB, 282 NetLog::TYPE_CERT_VERIFIER_REQUEST_BOUND_TO_JOB,
283 make_scoped_refptr(new NetLogSourceParameter( 283 net_log_.source().ToEventParametersCallback());
284 "source_dependency", net_log_.source())));
285 284
286 requests_.push_back(request); 285 requests_.push_back(request);
287 } 286 }
288 287
289 void HandleResult( 288 void HandleResult(
290 const MultiThreadedCertVerifier::CachedResult& verify_result) { 289 const MultiThreadedCertVerifier::CachedResult& verify_result) {
291 worker_ = NULL; 290 worker_ = NULL;
292 net_log_.EndEvent(NetLog::TYPE_CERT_VERIFIER_JOB, NULL); 291 net_log_.EndEvent(NetLog::TYPE_CERT_VERIFIER_JOB, NULL);
293 UMA_HISTOGRAM_CUSTOM_TIMES("Net.CertVerifier_Job_Latency", 292 UMA_HISTOGRAM_CUSTOM_TIMES("Net.CertVerifier_Job_Latency",
294 base::TimeTicks::Now() - start_time_, 293 base::TimeTicks::Now() - start_time_,
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 DCHECK(CalledOnValidThread()); 447 DCHECK(CalledOnValidThread());
449 448
450 ClearCache(); 449 ClearCache();
451 } 450 }
452 451
453 void MultiThreadedCertVerifier::SetCertVerifyProc(CertVerifyProc* verify_proc) { 452 void MultiThreadedCertVerifier::SetCertVerifyProc(CertVerifyProc* verify_proc) {
454 verify_proc_ = verify_proc; 453 verify_proc_ = verify_proc;
455 } 454 }
456 455
457 } // namespace net 456 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698