| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/cert_store.h" | 5 #include "chrome/browser/cert_store.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 | 9 |
| 10 #include "base/stl_util-inl.h" | 10 #include "base/stl_util-inl.h" |
| 11 #include "chrome/browser/renderer_host/render_process_host.h" | 11 #include "chrome/browser/renderer_host/render_process_host.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 return cert_id; | 81 return cert_id; |
| 82 } | 82 } |
| 83 | 83 |
| 84 bool CertStore::RetrieveCert(int cert_id, | 84 bool CertStore::RetrieveCert(int cert_id, |
| 85 scoped_refptr<net::X509Certificate>* cert) { | 85 scoped_refptr<net::X509Certificate>* cert) { |
| 86 AutoLock autoLock(cert_lock_); | 86 AutoLock autoLock(cert_lock_); |
| 87 | 87 |
| 88 CertMap::iterator iter = id_to_cert_.find(cert_id); | 88 CertMap::iterator iter = id_to_cert_.find(cert_id); |
| 89 if (iter == id_to_cert_.end()) | 89 if (iter == id_to_cert_.end()) |
| 90 return false; | 90 return false; |
| 91 *cert = iter->second; | 91 if (cert) |
| 92 *cert = iter->second; |
| 92 return true; | 93 return true; |
| 93 } | 94 } |
| 94 | 95 |
| 95 void CertStore::RemoveCertInternal(int cert_id) { | 96 void CertStore::RemoveCertInternal(int cert_id) { |
| 96 CertMap::iterator cert_iter = id_to_cert_.find(cert_id); | 97 CertMap::iterator cert_iter = id_to_cert_.find(cert_id); |
| 97 DCHECK(cert_iter != id_to_cert_.end()); | 98 DCHECK(cert_iter != id_to_cert_.end()); |
| 98 | 99 |
| 99 ReverseCertMap::iterator id_iter = cert_to_id_.find(cert_iter->second); | 100 ReverseCertMap::iterator id_iter = cert_to_id_.find(cert_iter->second); |
| 100 DCHECK(id_iter != cert_to_id_.end()); | 101 DCHECK(id_iter != cert_to_id_.end()); |
| 101 cert_to_id_.erase(id_iter); | 102 cert_to_id_.erase(id_iter); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 | 134 |
| 134 void CertStore::Observe(NotificationType type, | 135 void CertStore::Observe(NotificationType type, |
| 135 const NotificationSource& source, | 136 const NotificationSource& source, |
| 136 const NotificationDetails& details) { | 137 const NotificationDetails& details) { |
| 137 DCHECK(type == NotificationType::RENDERER_PROCESS_TERMINATED || | 138 DCHECK(type == NotificationType::RENDERER_PROCESS_TERMINATED || |
| 138 type == NotificationType::RENDERER_PROCESS_CLOSED); | 139 type == NotificationType::RENDERER_PROCESS_CLOSED); |
| 139 RenderProcessHost* rph = Source<RenderProcessHost>(source).ptr(); | 140 RenderProcessHost* rph = Source<RenderProcessHost>(source).ptr(); |
| 140 DCHECK(rph); | 141 DCHECK(rph); |
| 141 RemoveCertsForRenderProcesHost(rph->id()); | 142 RemoveCertsForRenderProcesHost(rph->id()); |
| 142 } | 143 } |
| OLD | NEW |