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

Side by Side Diff: content/browser/cert_store_impl.h

Issue 71153005: Pull implementation of CertStore out to be reused. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update gypi too Created 7 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/cert_store_impl.cc » ('j') | content/browser/cert_store_impl.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_CERT_STORE_IMPL_H_ 5 #ifndef CONTENT_BROWSER_CERT_STORE_IMPL_H_
6 #define CONTENT_BROWSER_CERT_STORE_IMPL_H_ 6 #define CONTENT_BROWSER_CERT_STORE_IMPL_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/memory/singleton.h" 10 #include "base/memory/singleton.h"
11 #include "base/synchronization/lock.h" 11 #include "base/synchronization/lock.h"
12 #include "content/browser/renderer_data_memoizing_store.h"
12 #include "content/public/browser/cert_store.h" 13 #include "content/public/browser/cert_store.h"
13 #include "content/public/browser/notification_observer.h" 14 #include "content/public/browser/notification_observer.h"
14 #include "content/public/browser/notification_registrar.h" 15 #include "content/public/browser/notification_registrar.h"
15 #include "net/cert/x509_certificate.h" 16 #include "net/cert/x509_certificate.h"
wtc 2013/11/14 22:04:58 Please trim the header list. For example, the noti
alcutter 2013/11/15 13:33:07 Done.
16 17
17 namespace content { 18 namespace content {
18 19
19 class CertStoreImpl : public CertStore, 20 class CertStoreImpl : public CertStore {
20 public NotificationObserver {
21 public: 21 public:
22 // Returns the singleton instance of the CertStore. 22 // Returns the singleton instance of the CertStore.
23 static CertStoreImpl* GetInstance(); 23 static CertStoreImpl* GetInstance();
24 24
25 // CertStore implementation: 25 // CertStore implementation:
26 virtual int StoreCert(net::X509Certificate* cert, 26 virtual int StoreCert(net::X509Certificate* cert,
27 int render_process_host_id) OVERRIDE; 27 int render_process_host_id) OVERRIDE;
28 virtual bool RetrieveCert(int cert_id, 28 virtual bool RetrieveCert(int cert_id,
29 scoped_refptr<net::X509Certificate>* cert) OVERRIDE; 29 scoped_refptr<net::X509Certificate>* cert) OVERRIDE;
30 30
31 // NotificationObserver implementation.
32 virtual void Observe(int type,
33 const NotificationSource& source,
34 const NotificationDetails& details) OVERRIDE;
35 protected: 31 protected:
36 CertStoreImpl(); 32 CertStoreImpl();
37 virtual ~CertStoreImpl(); 33 virtual ~CertStoreImpl();
38 34
39 private: 35 private:
36 RendererDataMemoizingStore<net::X509Certificate> store_;
wtc 2013/11/14 22:04:58 This should be reordered to following the Style Gu
alcutter 2013/11/15 13:33:07 Done.
40 friend struct DefaultSingletonTraits<CertStoreImpl>; 37 friend struct DefaultSingletonTraits<CertStoreImpl>;
41
42 void RegisterForNotification();
43
44 // Remove the specified cert from id_to_cert_ and cert_to_id_.
45 // NOTE: the caller (RemoveCertsForRenderProcesHost) must hold cert_lock_.
46 void RemoveCertInternal(int cert_id);
47
48 // Removes all the certs associated with the specified process from the store.
49 void RemoveCertsForRenderProcesHost(int render_process_host_id);
50
51 typedef std::multimap<int, int> IDMap;
52 typedef std::map<int, scoped_refptr<net::X509Certificate> > CertMap;
53 typedef std::map<net::X509Certificate*, int, net::X509Certificate::LessThan>
54 ReverseCertMap;
55
56 // Is only used on the UI Thread.
57 NotificationRegistrar registrar_;
58
59 IDMap process_id_to_cert_id_;
60 IDMap cert_id_to_process_id_;
61
62 CertMap id_to_cert_;
63 ReverseCertMap cert_to_id_;
64
65 int next_cert_id_;
66
67 // This lock protects: process_to_ids_, id_to_processes_, id_to_cert_ and
68 // cert_to_id_.
69 base::Lock cert_lock_;
70
71 DISALLOW_COPY_AND_ASSIGN(CertStoreImpl); 38 DISALLOW_COPY_AND_ASSIGN(CertStoreImpl);
72 }; 39 };
73 40
74 } // namespace content 41 } // namespace content
75 42
76 #endif // CONTENT_BROWSER_CERT_STORE_IMPL_H_ 43 #endif // CONTENT_BROWSER_CERT_STORE_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/cert_store_impl.cc » ('j') | content/browser/cert_store_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698