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 #ifndef CONTENT_BROWSER_CERT_STORE_H_ | 5 #ifndef CONTENT_BROWSER_CERT_STORE_H_ |
6 #define CONTENT_BROWSER_CERT_STORE_H_ | 6 #define CONTENT_BROWSER_CERT_STORE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 | 10 |
11 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
12 #include "base/synchronization/lock.h" | 12 #include "base/synchronization/lock.h" |
| 13 #include "content/common/content_export.h" |
13 #include "content/common/notification_observer.h" | 14 #include "content/common/notification_observer.h" |
14 #include "content/common/notification_registrar.h" | 15 #include "content/common/notification_registrar.h" |
15 #include "net/base/x509_certificate.h" | 16 #include "net/base/x509_certificate.h" |
16 | 17 |
17 // The purpose of the cert store is to provide an easy way to store/retrieve | 18 // The purpose of the cert store is to provide an easy way to store/retrieve |
18 // X509Certificate objects. When stored, an X509Certificate object is | 19 // X509Certificate objects. When stored, an X509Certificate object is |
19 // associated with a RenderProcessHost. If all the RenderProcessHosts | 20 // associated with a RenderProcessHost. If all the RenderProcessHosts |
20 // associated with the cert have exited, the cert is removed from the store. | 21 // associated with the cert have exited, the cert is removed from the store. |
21 // This class is used by the SSLManager to keep track of the certs associated | 22 // This class is used by the SSLManager to keep track of the certs associated |
22 // to loaded resources. | 23 // to loaded resources. |
23 // It can be accessed from the UI and IO threads (it is thread-safe). | 24 // It can be accessed from the UI and IO threads (it is thread-safe). |
24 // Note that the cert ids will overflow if we register more than 2^32 - 1 certs | 25 // Note that the cert ids will overflow if we register more than 2^32 - 1 certs |
25 // in 1 browsing session (which is highly unlikely to happen). | 26 // in 1 browsing session (which is highly unlikely to happen). |
26 | 27 |
27 class CertStore : public NotificationObserver { | 28 class CONTENT_EXPORT CertStore : public NotificationObserver { |
28 public: | 29 public: |
29 // Returns the singleton instance of the CertStore. | 30 // Returns the singleton instance of the CertStore. |
30 static CertStore* GetInstance(); | 31 static CertStore* GetInstance(); |
31 | 32 |
32 // Stores the specified cert and returns the id associated with it. The cert | 33 // Stores the specified cert and returns the id associated with it. The cert |
33 // is associated to the specified RenderProcessHost. | 34 // is associated to the specified RenderProcessHost. |
34 // When all the RenderProcessHosts associated with a cert have exited, the | 35 // When all the RenderProcessHosts associated with a cert have exited, the |
35 // cert is removed from the store. | 36 // cert is removed from the store. |
36 // Note: ids starts at 1. | 37 // Note: ids starts at 1. |
37 int StoreCert(net::X509Certificate* cert, int render_process_host_id); | 38 int StoreCert(net::X509Certificate* cert, int render_process_host_id); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 int next_cert_id_; | 76 int next_cert_id_; |
76 | 77 |
77 // This lock protects: process_to_ids_, id_to_processes_, id_to_cert_ and | 78 // This lock protects: process_to_ids_, id_to_processes_, id_to_cert_ and |
78 // cert_to_id_. | 79 // cert_to_id_. |
79 base::Lock cert_lock_; | 80 base::Lock cert_lock_; |
80 | 81 |
81 DISALLOW_COPY_AND_ASSIGN(CertStore); | 82 DISALLOW_COPY_AND_ASSIGN(CertStore); |
82 }; | 83 }; |
83 | 84 |
84 #endif // CONTENT_BROWSER_CERT_STORE_H_ | 85 #endif // CONTENT_BROWSER_CERT_STORE_H_ |
OLD | NEW |