OLD | NEW |
---|---|
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/ssl/server_bound_cert_service.h" | 5 #include "net/ssl/server_bound_cert_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
419 | 419 |
420 // See if a request for the same domain is currently in flight. | 420 // See if a request for the same domain is currently in flight. |
421 bool create_if_missing = true; | 421 bool create_if_missing = true; |
422 if (JoinToInFlightRequest(request_start, domain, private_key, cert, | 422 if (JoinToInFlightRequest(request_start, domain, private_key, cert, |
423 create_if_missing, callback, out_req)) { | 423 create_if_missing, callback, out_req)) { |
424 return ERR_IO_PENDING; | 424 return ERR_IO_PENDING; |
425 } | 425 } |
426 | 426 |
427 int err = LookupDomainBoundCert(request_start, domain, private_key, cert, | 427 int err = LookupDomainBoundCert(request_start, domain, private_key, cert, |
428 create_if_missing, callback, out_req); | 428 create_if_missing, callback, out_req); |
429 if (err == ERR_FILE_NOT_FOUND) { | 429 if (err == ERR_FILE_NOT_FOUND) { |
wtc
2014/06/20 00:21:54
We set create_if_missing to true on line 421 and p
davidben
2014/06/20 20:05:57
Yeah, GetOrCreateDomainBoundCert does a create_if_
| |
430 // Sync lookup did not find a valid cert. Start generating a new one. | 430 // Sync lookup did not find a valid cert. Start generating a new one. |
431 workers_created_++; | 431 workers_created_++; |
432 ServerBoundCertServiceWorker* worker = new ServerBoundCertServiceWorker( | 432 ServerBoundCertServiceWorker* worker = new ServerBoundCertServiceWorker( |
433 domain, | 433 domain, |
434 base::Bind(&ServerBoundCertService::GeneratedServerBoundCert, | 434 base::Bind(&ServerBoundCertService::GeneratedServerBoundCert, |
435 weak_ptr_factory_.GetWeakPtr())); | 435 weak_ptr_factory_.GetWeakPtr())); |
436 if (!worker->Start(task_runner_)) { | 436 if (!worker->Start(task_runner_)) { |
437 // TODO(rkn): Log to the NetLog. | 437 // TODO(rkn): Log to the NetLog. |
438 LOG(ERROR) << "ServerBoundCertServiceWorker couldn't be started."; | 438 LOG(ERROR) << "ServerBoundCertServiceWorker couldn't be started."; |
439 RecordGetDomainBoundCertResult(WORKER_FAILURE); | 439 RecordGetDomainBoundCertResult(WORKER_FAILURE); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
509 } | 509 } |
510 | 510 |
511 if (err == OK) { | 511 if (err == OK) { |
512 // Async DB lookup found a valid cert. | 512 // Async DB lookup found a valid cert. |
513 DVLOG(1) << "Cert store had valid cert for " << server_identifier; | 513 DVLOG(1) << "Cert store had valid cert for " << server_identifier; |
514 cert_store_hits_++; | 514 cert_store_hits_++; |
515 // ServerBoundCertServiceRequest::Post will do the histograms and stuff. | 515 // ServerBoundCertServiceRequest::Post will do the histograms and stuff. |
516 HandleResult(OK, server_identifier, key, cert); | 516 HandleResult(OK, server_identifier, key, cert); |
517 return; | 517 return; |
518 } | 518 } |
519 // Async lookup did not find a valid cert. If no request asked to create one, | 519 // Async lookup failed or was missing. Return the error directly, unless the |
wtc
2014/06/20 00:21:54
Nit: add "the certificate" after "or".
davidben
2014/06/20 20:05:57
Done.
| |
520 // return the error directly. | 520 // certificate was missing and a request asked to create one. |
521 if (!j->second->CreateIfMissing()) { | 521 if (err != ERR_FILE_NOT_FOUND || !j->second->CreateIfMissing()) { |
522 HandleResult(err, server_identifier, key, cert); | 522 HandleResult(err, server_identifier, key, cert); |
523 return; | 523 return; |
524 } | 524 } |
525 // At least one request asked to create a cert => start generating a new one. | 525 // At least one request asked to create a cert => start generating a new one. |
526 workers_created_++; | 526 workers_created_++; |
527 ServerBoundCertServiceWorker* worker = new ServerBoundCertServiceWorker( | 527 ServerBoundCertServiceWorker* worker = new ServerBoundCertServiceWorker( |
528 server_identifier, | 528 server_identifier, |
529 base::Bind(&ServerBoundCertService::GeneratedServerBoundCert, | 529 base::Bind(&ServerBoundCertService::GeneratedServerBoundCert, |
530 weak_ptr_factory_.GetWeakPtr())); | 530 weak_ptr_factory_.GetWeakPtr())); |
531 if (!worker->Start(task_runner_)) { | 531 if (!worker->Start(task_runner_)) { |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
667 } | 667 } |
668 | 668 |
669 return err; | 669 return err; |
670 } | 670 } |
671 | 671 |
672 int ServerBoundCertService::cert_count() { | 672 int ServerBoundCertService::cert_count() { |
673 return server_bound_cert_store_->GetCertCount(); | 673 return server_bound_cert_store_->GetCertCount(); |
674 } | 674 } |
675 | 675 |
676 } // namespace net | 676 } // namespace net |
OLD | NEW |