1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_CHROMEOS_CERTIFICATE_PROVIDER_THREAD_SAFE_CERTIFICATE_MAP_H_
6 #define CHROME_BROWSER_CHROMEOS_CERTIFICATE_PROVIDER_THREAD_SAFE_CERTIFICATE_MAP_H_
11 #include "base/macros.h"
12 #include "base/synchronization/lock.h"
13 #include "chrome/browser/chromeos/certificate_provider/certificate_info.h"
16 class SHA256HashValueLessThan
;
17 class X509Certificate
;
18 struct SHA256HashValue
;
22 namespace certificate_provider
{
24 class ThreadSafeCertificateMap
{
26 using FingerprintToCertMap
= std::map
<net::SHA256HashValue
,
28 net::SHA256HashValueLessThan
>;
29 using ExtensionToFingerprintsMap
=
30 std::map
<std::string
, FingerprintToCertMap
>;
32 ThreadSafeCertificateMap();
33 ~ThreadSafeCertificateMap();
35 // Replaces the stored certificates by the given certificates.
36 void Update(const std::map
<std::string
, CertificateInfoList
>&
37 extension_to_certificates
);
39 // Looks up the given certificate. If found, it returns true and sets
40 // |extension_id| to the extension id for which this certificate was
41 // registered and sets |info| to the stored info. Otherwise returns false and
42 // doesn't modify |info| and |extension_id|.
43 bool LookUpCertificate(const net::X509Certificate
& cert
,
44 CertificateInfo
* info
,
45 std::string
* extension_id
);
47 // Remove all certificates that are currently registered for the given
49 void RemoveExtension(const std::string
& extension_id
);
53 ExtensionToFingerprintsMap extension_to_certificates_
;
55 DISALLOW_COPY_AND_ASSIGN(ThreadSafeCertificateMap
);
58 } // namespace certificate_provider
59 } // namespace chromeos
61 #endif // CHROME_BROWSER_CHROMEOS_CERTIFICATE_PROVIDER_THREAD_SAFE_CERTIFICATE_MAP_H_