#ifndef NET_CERT_INTERNAL_TRUST_STORE_ANDROID_H_
#define NET_CERT_INTERNAL_TRUST_STORE_ANDROID_H_
#include <atomic>
#include "base/memory/ptr_util.h"
#include "base/memory/scoped_refptr.h"
#include "base/sequence_checker.h"
#include "base/synchronization/lock.h"
#include "net/base/net_export.h"
#include "net/cert/cert_database.h"
#include "net/cert/internal/platform_trust_store.h"
#include "third_party/boringssl/src/pki/trust_store.h"
#include "third_party/boringssl/src/pki/trust_store_in_memory.h"
namespace net {
class NET_EXPORT TrustStoreAndroid : public PlatformTrustStore,
public CertDatabase::Observer {
public:
TrustStoreAndroid();
~TrustStoreAndroid() override;
TrustStoreAndroid(const TrustStoreAndroid& other) = delete;
TrustStoreAndroid& operator=(const TrustStoreAndroid& other) = delete;
void Initialize();
void SyncGetIssuersOf(const bssl::ParsedCertificate* cert,
bssl::ParsedCertificateList* issuers) override;
bssl::CertificateTrust GetTrust(const bssl::ParsedCertificate* cert) override;
std::vector<net::PlatformTrustStore::CertWithTrust> GetAllUserAddedCerts()
override;
void OnTrustStoreChanged() override;
void ObserveCertDBChanges();
private:
class Impl;
scoped_refptr<Impl> MaybeInitializeAndGetImpl();
bool is_observing_certdb_changes_
GUARDED_BY_CONTEXT(certdb_observer_sequence_checker_) = false;
SEQUENCE_CHECKER(certdb_observer_sequence_checker_);
base::Lock init_lock_;
scoped_refptr<Impl> impl_ GUARDED_BY(init_lock_);
std::atomic_int generation_ = 0;
};
}
#endif