Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ios / web / public / cert_store.h
blobb6b085596d1b147b1adc3e2ec681f5ea56ae9266
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 IOS_WEB_PUBLIC_BROWSER_CERT_STORE_H_
6 #define IOS_WEB_PUBLIC_BROWSER_CERT_STORE_H_
8 #include "base/memory/ref_counted.h"
10 namespace net {
11 class X509Certificate;
14 namespace web {
16 // The purpose of the cert store is to provide an easy way to store/retrieve
17 // X509Certificate objects. When stored, an X509Certificate object is
18 // associated with a group, which can be cleared when it is no longer useful.
19 // It can be accessed from the UI and IO threads (it is thread-safe).
20 // Note that the cert ids will overflow if more than 2^32 - 1 certs are
21 // registered in one browsing session (which is highly unlikely to happen).
22 class CertStore {
23 public:
24 // Returns the singleton instance of the CertStore.
25 static CertStore* GetInstance();
27 // Stores the specified cert and returns the id associated with it. The cert
28 // is associated to the specified RequestTracker.
29 // When all the RequestTrackers associated with a cert have been closed, the
30 // cert is removed from the store.
31 // Note: ids starts at 1.
32 virtual int StoreCert(net::X509Certificate* cert, int group_id) = 0;
34 // Tries to retrieve the previously stored cert associated with the specified
35 // |cert_id|. Returns whether the cert could be found, and, if |cert| is
36 // non-nullptr, copies it in.
37 virtual bool RetrieveCert(int cert_id,
38 scoped_refptr<net::X509Certificate>* cert) = 0;
40 // Removes all the certs associated with the specified groups from the store.
41 virtual void RemoveCertsForGroup(int group_id) = 0;
43 protected:
44 virtual ~CertStore() {}
47 } // namespace web
49 #endif // IOS_WEB_PUBLIC_BROWSER_CERT_STORE_H_