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/default_server_bound_cert_store.h" | 5 #include "net/ssl/default_server_bound_cert_store.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 | 10 |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 int DefaultServerBoundCertStore::GetCertCount() { | 308 int DefaultServerBoundCertStore::GetCertCount() { |
309 DCHECK(CalledOnValidThread()); | 309 DCHECK(CalledOnValidThread()); |
310 | 310 |
311 return server_bound_certs_.size(); | 311 return server_bound_certs_.size(); |
312 } | 312 } |
313 | 313 |
314 void DefaultServerBoundCertStore::SetForceKeepSessionState() { | 314 void DefaultServerBoundCertStore::SetForceKeepSessionState() { |
315 DCHECK(CalledOnValidThread()); | 315 DCHECK(CalledOnValidThread()); |
316 InitIfNecessary(); | 316 InitIfNecessary(); |
317 | 317 |
318 if (store_) | 318 if (store_.get()) |
319 store_->SetForceKeepSessionState(); | 319 store_->SetForceKeepSessionState(); |
320 } | 320 } |
321 | 321 |
322 DefaultServerBoundCertStore::~DefaultServerBoundCertStore() { | 322 DefaultServerBoundCertStore::~DefaultServerBoundCertStore() { |
323 DeleteAllInMemory(); | 323 DeleteAllInMemory(); |
324 } | 324 } |
325 | 325 |
326 void DefaultServerBoundCertStore::DeleteAllInMemory() { | 326 void DefaultServerBoundCertStore::DeleteAllInMemory() { |
327 DCHECK(CalledOnValidThread()); | 327 DCHECK(CalledOnValidThread()); |
328 | 328 |
329 for (ServerBoundCertMap::iterator it = server_bound_certs_.begin(); | 329 for (ServerBoundCertMap::iterator it = server_bound_certs_.begin(); |
330 it != server_bound_certs_.end(); ++it) { | 330 it != server_bound_certs_.end(); ++it) { |
331 delete it->second; | 331 delete it->second; |
332 } | 332 } |
333 server_bound_certs_.clear(); | 333 server_bound_certs_.clear(); |
334 } | 334 } |
335 | 335 |
336 void DefaultServerBoundCertStore::InitStore() { | 336 void DefaultServerBoundCertStore::InitStore() { |
337 DCHECK(CalledOnValidThread()); | 337 DCHECK(CalledOnValidThread()); |
338 DCHECK(store_) << "Store must exist to initialize"; | 338 DCHECK(store_.get()) << "Store must exist to initialize"; |
339 DCHECK(!loaded_); | 339 DCHECK(!loaded_); |
340 | 340 |
341 store_->Load(base::Bind(&DefaultServerBoundCertStore::OnLoaded, | 341 store_->Load(base::Bind(&DefaultServerBoundCertStore::OnLoaded, |
342 weak_ptr_factory_.GetWeakPtr())); | 342 weak_ptr_factory_.GetWeakPtr())); |
343 } | 343 } |
344 | 344 |
345 void DefaultServerBoundCertStore::OnLoaded( | 345 void DefaultServerBoundCertStore::OnLoaded( |
346 scoped_ptr<ScopedVector<ServerBoundCert> > certs) { | 346 scoped_ptr<ScopedVector<ServerBoundCert> > certs) { |
347 DCHECK(CalledOnValidThread()); | 347 DCHECK(CalledOnValidThread()); |
348 | 348 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 base::Time delete_end) { | 405 base::Time delete_end) { |
406 DCHECK(CalledOnValidThread()); | 406 DCHECK(CalledOnValidThread()); |
407 DCHECK(loaded_); | 407 DCHECK(loaded_); |
408 for (ServerBoundCertMap::iterator it = server_bound_certs_.begin(); | 408 for (ServerBoundCertMap::iterator it = server_bound_certs_.begin(); |
409 it != server_bound_certs_.end();) { | 409 it != server_bound_certs_.end();) { |
410 ServerBoundCertMap::iterator cur = it; | 410 ServerBoundCertMap::iterator cur = it; |
411 ++it; | 411 ++it; |
412 ServerBoundCert* cert = cur->second; | 412 ServerBoundCert* cert = cur->second; |
413 if ((delete_begin.is_null() || cert->creation_time() >= delete_begin) && | 413 if ((delete_begin.is_null() || cert->creation_time() >= delete_begin) && |
414 (delete_end.is_null() || cert->creation_time() < delete_end)) { | 414 (delete_end.is_null() || cert->creation_time() < delete_end)) { |
415 if (store_) | 415 if (store_.get()) |
416 store_->DeleteServerBoundCert(*cert); | 416 store_->DeleteServerBoundCert(*cert); |
417 delete cert; | 417 delete cert; |
418 server_bound_certs_.erase(cur); | 418 server_bound_certs_.erase(cur); |
419 } | 419 } |
420 } | 420 } |
421 } | 421 } |
422 | 422 |
423 void DefaultServerBoundCertStore::SyncGetAllServerBoundCerts( | 423 void DefaultServerBoundCertStore::SyncGetAllServerBoundCerts( |
424 ServerBoundCertList* cert_list) { | 424 ServerBoundCertList* cert_list) { |
425 DCHECK(CalledOnValidThread()); | 425 DCHECK(CalledOnValidThread()); |
(...skipping 26 matching lines...) Expand all Loading... |
452 void DefaultServerBoundCertStore::InternalDeleteServerBoundCert( | 452 void DefaultServerBoundCertStore::InternalDeleteServerBoundCert( |
453 const std::string& server_identifier) { | 453 const std::string& server_identifier) { |
454 DCHECK(CalledOnValidThread()); | 454 DCHECK(CalledOnValidThread()); |
455 DCHECK(loaded_); | 455 DCHECK(loaded_); |
456 | 456 |
457 ServerBoundCertMap::iterator it = server_bound_certs_.find(server_identifier); | 457 ServerBoundCertMap::iterator it = server_bound_certs_.find(server_identifier); |
458 if (it == server_bound_certs_.end()) | 458 if (it == server_bound_certs_.end()) |
459 return; // There is nothing to delete. | 459 return; // There is nothing to delete. |
460 | 460 |
461 ServerBoundCert* cert = it->second; | 461 ServerBoundCert* cert = it->second; |
462 if (store_) | 462 if (store_.get()) |
463 store_->DeleteServerBoundCert(*cert); | 463 store_->DeleteServerBoundCert(*cert); |
464 server_bound_certs_.erase(it); | 464 server_bound_certs_.erase(it); |
465 delete cert; | 465 delete cert; |
466 } | 466 } |
467 | 467 |
468 void DefaultServerBoundCertStore::InternalInsertServerBoundCert( | 468 void DefaultServerBoundCertStore::InternalInsertServerBoundCert( |
469 const std::string& server_identifier, | 469 const std::string& server_identifier, |
470 ServerBoundCert* cert) { | 470 ServerBoundCert* cert) { |
471 DCHECK(CalledOnValidThread()); | 471 DCHECK(CalledOnValidThread()); |
472 DCHECK(loaded_); | 472 DCHECK(loaded_); |
473 | 473 |
474 if (store_) | 474 if (store_.get()) |
475 store_->AddServerBoundCert(*cert); | 475 store_->AddServerBoundCert(*cert); |
476 server_bound_certs_[server_identifier] = cert; | 476 server_bound_certs_[server_identifier] = cert; |
477 } | 477 } |
478 | 478 |
479 DefaultServerBoundCertStore::PersistentStore::PersistentStore() {} | 479 DefaultServerBoundCertStore::PersistentStore::PersistentStore() {} |
480 | 480 |
481 DefaultServerBoundCertStore::PersistentStore::~PersistentStore() {} | 481 DefaultServerBoundCertStore::PersistentStore::~PersistentStore() {} |
482 | 482 |
483 } // namespace net | 483 } // namespace net |
OLD | NEW |