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

Unified Diff: net/cert/nss_cert_database.h

Issue 214863002: Extension API enterprise.platformKeys. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated histograms.xml. Created 6 years, 7 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
« no previous file with comments | « extensions/common/permissions/api_permission.h ('k') | net/cert/nss_cert_database.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cert/nss_cert_database.h
diff --git a/net/cert/nss_cert_database.h b/net/cert/nss_cert_database.h
index df52e589f3f70d1cd1e2a747286e240ff2ca0add..1c4daf817937c83d328441d491b196be8858af86 100644
--- a/net/cert/nss_cert_database.h
+++ b/net/cert/nss_cert_database.h
@@ -11,8 +11,10 @@
#include "base/basictypes.h"
#include "base/callback_forward.h"
#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
#include "base/strings/string16.h"
#include "crypto/scoped_nss_types.h"
+#include "net/base/net_errors.h"
#include "net/base/net_export.h"
#include "net/cert/cert_type.h"
#include "net/cert/x509_certificate.h"
@@ -96,6 +98,8 @@ class NET_EXPORT NSSCertDatabase {
typedef base::Callback<void(scoped_ptr<CertificateList> certs)>
ListCertsCallback;
+ typedef base::Callback<void(bool)> DeleteCertCallback;
+
// DEPRECATED: See http://crbug.com/329735.
static NSSCertDatabase* GetInstance();
@@ -109,6 +113,14 @@ class NET_EXPORT NSSCertDatabase {
// run even after the database is deleted.
virtual void ListCerts(const ListCertsCallback& callback);
+ // Get a list of certificates in the certificate database of the given slot.
+ // Note that the callback may be run even after the database is deleted.
+ // Must be called on the IO thread and it calls |callback| on the IO thread.
+ // This does not block by retrieving the certs asynchronously on a worker
+ // thread. Never calls |callback| synchronously.
+ virtual void ListCertsInSlot(const ListCertsCallback& callback,
+ PK11SlotInfo* slot);
+
// Get the default slot for public key data.
virtual crypto::ScopedPK11Slot GetPublicSlot() const;
@@ -199,7 +211,13 @@ class NET_EXPORT NSSCertDatabase {
// Delete certificate and associated private key (if one exists).
// |cert| is still valid when this function returns. Returns true on
// success.
- bool DeleteCertAndKey(const X509Certificate* cert);
+ bool DeleteCertAndKey(X509Certificate* cert);
+
+ // Like DeleteCertAndKey but does not block by running the removal on a worker
+ // thread. This must be called on IO thread and it will run |callback| on IO
+ // thread. Never calls |callback| synchronously.
+ void DeleteCertAndKeyAsync(const scoped_refptr<X509Certificate>& cert,
+ const DeleteCertCallback& callback);
// Check whether cert is stored in a readonly slot.
bool IsReadOnly(const X509Certificate* cert) const;
@@ -228,9 +246,12 @@ class NET_EXPORT NSSCertDatabase {
NSSCertDatabase();
virtual ~NSSCertDatabase();
- // Certificate listing implementation used by |ListCerts| and |ListCertsSync|.
- // Static so it may safely be used on the worker thread.
- static void ListCertsImpl(CertificateList* certs);
+ // Certificate listing implementation used by |ListCerts*| and
+ // |ListCertsSync|. Static so it may safely be used on the worker thread.
+ // If |slot| is NULL, obtains the certs of all slots, otherwise only of
+ // |slot|.
+ static void ListCertsImpl(crypto::ScopedPK11Slot slot,
+ CertificateList* certs);
// Gets task runner that should be used for slow tasks like certificate
// listing. Defaults to a base::WorkerPool runner, but may be overriden
@@ -240,16 +261,28 @@ class NET_EXPORT NSSCertDatabase {
private:
friend struct base::DefaultLazyInstanceTraits<NSSCertDatabase>;
+ // Notifies observers of the removal of |cert| and calls |callback| with
+ // |success| as argument.
+ void NotifyCertRemovalAndCallBack(scoped_refptr<X509Certificate> cert,
+ const DeleteCertCallback& callback,
+ bool success);
+
// Broadcasts notifications to all registered observers.
void NotifyObserversOfCertAdded(const X509Certificate* cert);
void NotifyObserversOfCertRemoved(const X509Certificate* cert);
void NotifyObserversOfCACertChanged(const X509Certificate* cert);
+ // Certificate removal implementation used by |DeleteCertAndKey*|. Static so
+ // it may safely be used on the worker thread.
+ static bool DeleteCertAndKeyImpl(scoped_refptr<X509Certificate> cert);
+
// Task runner that should be used in tests if set.
scoped_refptr<base::TaskRunner> slow_task_runner_for_test_;
const scoped_refptr<ObserverListThreadSafe<Observer> > observer_list_;
+ base::WeakPtrFactory<NSSCertDatabase> weak_factory_;
+
DISALLOW_COPY_AND_ASSIGN(NSSCertDatabase);
};
« no previous file with comments | « extensions/common/permissions/api_permission.h ('k') | net/cert/nss_cert_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698