Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1880)

Unified Diff: chrome/browser/chromeos/certificate_provider/thread_safe_certificate_map.h

Issue 1330003002: CertificateProviderService: Expose certificate lookup. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scoped_ptr_map
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/certificate_provider/thread_safe_certificate_map.h
diff --git a/chrome/browser/chromeos/certificate_provider/thread_safe_certificate_map.h b/chrome/browser/chromeos/certificate_provider/thread_safe_certificate_map.h
index 15f04429a34f8ed6064fc043580e9bc99deec5c9..e9d5a99dec257af6182fecb4caa58d4b776dc5d0 100644
--- a/chrome/browser/chromeos/certificate_provider/thread_safe_certificate_map.h
+++ b/chrome/browser/chromeos/certificate_provider/thread_safe_certificate_map.h
@@ -8,6 +8,7 @@
#include <map>
#include <string>
+#include "base/containers/scoped_ptr_map.h"
#include "base/macros.h"
#include "base/synchronization/lock.h"
#include "chrome/browser/chromeos/certificate_provider/certificate_info.h"
@@ -23,34 +24,46 @@ namespace certificate_provider {
class ThreadSafeCertificateMap {
public:
- using FingerprintToCertMap = std::map<net::SHA256HashValue,
- CertificateInfo,
- net::SHA256HashValueLessThan>;
- using ExtensionToFingerprintsMap =
- std::map<std::string, FingerprintToCertMap>;
+ struct MapValue {
+ MapValue(const CertificateInfo& cert_info, const std::string& extension_id);
+ ~MapValue();
+
+ CertificateInfo cert_info;
+ std::string extension_id;
+ };
+ using FingerprintToCertAndExtensionMap =
+ base::ScopedPtrMap<net::SHA256HashValue,
+ scoped_ptr<MapValue>,
+ net::SHA256HashValueLessThan>;
ThreadSafeCertificateMap();
~ThreadSafeCertificateMap();
- // Replaces the stored certificates by the given certificates.
+ // Updates the stored certificates with the given mapping from extension ids
+ // to certificates.
void Update(const std::map<std::string, CertificateInfoList>&
extension_to_certificates);
- // Looks up the given certificate. If found, it returns true and sets
- // |extension_id| to the extension id for which this certificate was
- // registered and sets |info| to the stored info. Otherwise returns false and
- // doesn't modify |info| and |extension_id|.
+ // Looks up the given certificate. If the certificate was added by any
+ // previous Update() call, returns true.
+ // If this certificate was provided in the most recent Update() call,
+ // |is_currently_provided| will be set to true, |extension_id| be set to that
+ // extension's id and |info| will be set to the stored info. Otherwise, if
+ // this certificate was not provided in the the most recent Update() call,
+ // sets |is_currently_provided| to false and doesn't modify |info| and
+ // |extension_id|.
bool LookUpCertificate(const net::X509Certificate& cert,
+ bool* is_currently_provided,
CertificateInfo* info,
std::string* extension_id);
- // Remove all certificates that are currently registered for the given
- // extension.
+ // Remove every association of stored certificates to the given extension.
+ // The certificates themselves will be remembered.
void RemoveExtension(const std::string& extension_id);
private:
base::Lock lock_;
- ExtensionToFingerprintsMap extension_to_certificates_;
+ FingerprintToCertAndExtensionMap fingerprint_to_cert_and_extension_;
DISALLOW_COPY_AND_ASSIGN(ThreadSafeCertificateMap);
};

Powered by Google App Engine
This is Rietveld 408576698