OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/browser/cert_store.h" | 5 #include "content/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" |
(...skipping 17 matching lines...) Expand all Loading... |
28 return Singleton<CertStore>::get(); | 28 return Singleton<CertStore>::get(); |
29 } | 29 } |
30 | 30 |
31 CertStore::CertStore() : next_cert_id_(1) { | 31 CertStore::CertStore() : next_cert_id_(1) { |
32 // We watch for RenderProcess termination, as this is how we clear | 32 // We watch for RenderProcess termination, as this is how we clear |
33 // certificates for now. | 33 // certificates for now. |
34 // TODO(jcampan): we should be listening to events such as resource cached/ | 34 // TODO(jcampan): we should be listening to events such as resource cached/ |
35 // removed from cache, and remove the cert when we know it | 35 // removed from cache, and remove the cert when we know it |
36 // is not used anymore. | 36 // is not used anymore. |
37 | 37 |
38 registrar_.Add(this, NotificationType::RENDERER_PROCESS_TERMINATED, | 38 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
39 NotificationService::AllSources()); | 39 NotificationService::AllSources()); |
40 registrar_.Add(this, NotificationType::RENDERER_PROCESS_CLOSED, | 40 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, |
41 NotificationService::AllSources()); | 41 NotificationService::AllSources()); |
42 } | 42 } |
43 | 43 |
44 CertStore::~CertStore() { | 44 CertStore::~CertStore() { |
45 } | 45 } |
46 | 46 |
47 int CertStore::StoreCert(net::X509Certificate* cert, int process_id) { | 47 int CertStore::StoreCert(net::X509Certificate* cert, int process_id) { |
48 DCHECK(cert); | 48 DCHECK(cert); |
49 base::AutoLock autoLock(cert_lock_); | 49 base::AutoLock autoLock(cert_lock_); |
50 | 50 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 // This cert is not referenced by any process, remove it from id_to_cert_ | 128 // This cert is not referenced by any process, remove it from id_to_cert_ |
129 // and cert_to_id_. | 129 // and cert_to_id_. |
130 RemoveCertInternal(cert_id); | 130 RemoveCertInternal(cert_id); |
131 } | 131 } |
132 | 132 |
133 // Erase the current item but keep the iterator valid. | 133 // Erase the current item but keep the iterator valid. |
134 process_id_to_cert_id_.erase(ids_iter++); | 134 process_id_to_cert_id_.erase(ids_iter++); |
135 } | 135 } |
136 } | 136 } |
137 | 137 |
138 void CertStore::Observe(NotificationType type, | 138 void CertStore::Observe(int type, |
139 const NotificationSource& source, | 139 const NotificationSource& source, |
140 const NotificationDetails& details) { | 140 const NotificationDetails& details) { |
141 DCHECK(type == NotificationType::RENDERER_PROCESS_TERMINATED || | 141 DCHECK(type == content::NOTIFICATION_RENDERER_PROCESS_TERMINATED || |
142 type == NotificationType::RENDERER_PROCESS_CLOSED); | 142 type == content::NOTIFICATION_RENDERER_PROCESS_CLOSED); |
143 RenderProcessHost* rph = Source<RenderProcessHost>(source).ptr(); | 143 RenderProcessHost* rph = Source<RenderProcessHost>(source).ptr(); |
144 DCHECK(rph); | 144 DCHECK(rph); |
145 RemoveCertsForRenderProcesHost(rph->id()); | 145 RemoveCertsForRenderProcesHost(rph->id()); |
146 } | 146 } |
OLD | NEW |