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

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

Issue 10548028: NetLogEventParameter to Callback refactoring 8. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fix bad paste 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
« no previous file with comments | « net/base/host_resolver_impl.cc ('k') | net/socket_stream/socket_stream.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 85
86 // Represents the output and result callback of a request. 86 // Represents the output and result callback of a request.
87 class CertVerifierRequest { 87 class CertVerifierRequest {
88 public: 88 public:
89 CertVerifierRequest(const CompletionCallback& callback, 89 CertVerifierRequest(const CompletionCallback& callback,
90 CertVerifyResult* verify_result, 90 CertVerifyResult* verify_result,
91 const BoundNetLog& net_log) 91 const BoundNetLog& net_log)
92 : callback_(callback), 92 : callback_(callback),
93 verify_result_(verify_result), 93 verify_result_(verify_result),
94 net_log_(net_log) { 94 net_log_(net_log) {
95 net_log_.BeginEvent(NetLog::TYPE_CERT_VERIFIER_REQUEST, NULL); 95 net_log_.BeginEvent(NetLog::TYPE_CERT_VERIFIER_REQUEST);
96 } 96 }
97 97
98 ~CertVerifierRequest() { 98 ~CertVerifierRequest() {
99 } 99 }
100 100
101 // Ensures that the result callback will never be made. 101 // Ensures that the result callback will never be made.
102 void Cancel() { 102 void Cancel() {
103 callback_.Reset(); 103 callback_.Reset();
104 verify_result_ = NULL; 104 verify_result_ = NULL;
105 net_log_.AddEvent(NetLog::TYPE_CANCELLED, NULL); 105 net_log_.AddEvent(NetLog::TYPE_CANCELLED);
106 net_log_.EndEvent(NetLog::TYPE_CERT_VERIFIER_REQUEST, NULL); 106 net_log_.EndEvent(NetLog::TYPE_CERT_VERIFIER_REQUEST);
107 } 107 }
108 108
109 // Copies the contents of |verify_result| to the caller's 109 // Copies the contents of |verify_result| to the caller's
110 // CertVerifyResult and calls the callback. 110 // CertVerifyResult and calls the callback.
111 void Post(const MultiThreadedCertVerifier::CachedResult& verify_result) { 111 void Post(const MultiThreadedCertVerifier::CachedResult& verify_result) {
112 if (!callback_.is_null()) { 112 if (!callback_.is_null()) {
113 net_log_.EndEvent(NetLog::TYPE_CERT_VERIFIER_REQUEST, NULL); 113 net_log_.EndEvent(NetLog::TYPE_CERT_VERIFIER_REQUEST);
114 *verify_result_ = verify_result.result; 114 *verify_result_ = verify_result.result;
115 callback_.Run(verify_result.error); 115 callback_.Run(verify_result.error);
116 } 116 }
117 delete this; 117 delete this;
118 } 118 }
119 119
120 bool canceled() const { return callback_.is_null(); } 120 bool canceled() const { return callback_.is_null(); }
121 121
122 const BoundNetLog& net_log() const { return net_log_; } 122 const BoundNetLog& net_log() const { return net_log_; }
123 123
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 worker_(worker), 264 worker_(worker),
265 net_log_(net_log) { 265 net_log_(net_log) {
266 net_log_.BeginEvent( 266 net_log_.BeginEvent(
267 NetLog::TYPE_CERT_VERIFIER_JOB, 267 NetLog::TYPE_CERT_VERIFIER_JOB,
268 base::Bind(&NetLogX509CertificateCallback, 268 base::Bind(&NetLogX509CertificateCallback,
269 base::Unretained(worker_->certificate()))); 269 base::Unretained(worker_->certificate())));
270 } 270 }
271 271
272 ~CertVerifierJob() { 272 ~CertVerifierJob() {
273 if (worker_) { 273 if (worker_) {
274 net_log_.AddEvent(NetLog::TYPE_CANCELLED, NULL); 274 net_log_.AddEvent(NetLog::TYPE_CANCELLED);
275 net_log_.EndEvent(NetLog::TYPE_CERT_VERIFIER_JOB, NULL); 275 net_log_.EndEvent(NetLog::TYPE_CERT_VERIFIER_JOB);
276 worker_->Cancel(); 276 worker_->Cancel();
277 DeleteAllCanceled(); 277 DeleteAllCanceled();
278 } 278 }
279 } 279 }
280 280
281 void AddRequest(CertVerifierRequest* request) { 281 void AddRequest(CertVerifierRequest* request) {
282 request->net_log().AddEvent( 282 request->net_log().AddEvent(
283 NetLog::TYPE_CERT_VERIFIER_REQUEST_BOUND_TO_JOB, 283 NetLog::TYPE_CERT_VERIFIER_REQUEST_BOUND_TO_JOB,
284 net_log_.source().ToEventParametersCallback()); 284 net_log_.source().ToEventParametersCallback());
285 285
286 requests_.push_back(request); 286 requests_.push_back(request);
287 } 287 }
288 288
289 void HandleResult( 289 void HandleResult(
290 const MultiThreadedCertVerifier::CachedResult& verify_result) { 290 const MultiThreadedCertVerifier::CachedResult& verify_result) {
291 worker_ = NULL; 291 worker_ = NULL;
292 net_log_.EndEvent(NetLog::TYPE_CERT_VERIFIER_JOB, NULL); 292 net_log_.EndEvent(NetLog::TYPE_CERT_VERIFIER_JOB);
293 UMA_HISTOGRAM_CUSTOM_TIMES("Net.CertVerifier_Job_Latency", 293 UMA_HISTOGRAM_CUSTOM_TIMES("Net.CertVerifier_Job_Latency",
294 base::TimeTicks::Now() - start_time_, 294 base::TimeTicks::Now() - start_time_,
295 base::TimeDelta::FromMilliseconds(1), 295 base::TimeDelta::FromMilliseconds(1),
296 base::TimeDelta::FromMinutes(10), 296 base::TimeDelta::FromMinutes(10),
297 100); 297 100);
298 PostAll(verify_result); 298 PostAll(verify_result);
299 } 299 }
300 300
301 private: 301 private:
302 void PostAll(const MultiThreadedCertVerifier::CachedResult& verify_result) { 302 void PostAll(const MultiThreadedCertVerifier::CachedResult& verify_result) {
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 DCHECK(CalledOnValidThread()); 448 DCHECK(CalledOnValidThread());
449 449
450 ClearCache(); 450 ClearCache();
451 } 451 }
452 452
453 void MultiThreadedCertVerifier::SetCertVerifyProc(CertVerifyProc* verify_proc) { 453 void MultiThreadedCertVerifier::SetCertVerifyProc(CertVerifyProc* verify_proc) {
454 verify_proc_ = verify_proc; 454 verify_proc_ = verify_proc;
455 } 455 }
456 456
457 } // namespace net 457 } // namespace net
OLDNEW
« no previous file with comments | « net/base/host_resolver_impl.cc ('k') | net/socket_stream/socket_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698