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

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

Issue 9545011: Allow CertStore to be mocked by making its method virtual. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Revert none LGTMed changes Created 8 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
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_H_ 5 #ifndef CONTENT_BROWSER_CERT_STORE_H_
6 #define CONTENT_BROWSER_CERT_STORE_H_ 6 #define CONTENT_BROWSER_CERT_STORE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 10
(...skipping 17 matching lines...) Expand all
28 class CONTENT_EXPORT CertStore : public content::NotificationObserver { 28 class CONTENT_EXPORT CertStore : public content::NotificationObserver {
29 public: 29 public:
30 // Returns the singleton instance of the CertStore. 30 // Returns the singleton instance of the CertStore.
31 static CertStore* GetInstance(); 31 static CertStore* GetInstance();
32 32
33 // Stores the specified cert and returns the id associated with it. The cert 33 // Stores the specified cert and returns the id associated with it. The cert
34 // is associated to the specified RenderProcessHost. 34 // is associated to the specified RenderProcessHost.
35 // When all the RenderProcessHosts associated with a cert have exited, the 35 // When all the RenderProcessHosts associated with a cert have exited, the
36 // cert is removed from the store. 36 // cert is removed from the store.
37 // Note: ids starts at 1. 37 // Note: ids starts at 1.
38 int StoreCert(net::X509Certificate* cert, int render_process_host_id); 38 virtual int StoreCert(net::X509Certificate* cert, int render_process_host_id);
39 39
40 // Tries to retrieve the previously stored cert associated with the specified 40 // Tries to retrieve the previously stored cert associated with the specified
41 // |cert_id|. Returns whether the cert could be found, and, if |cert| is 41 // |cert_id|. Returns whether the cert could be found, and, if |cert| is
42 // non-NULL, copies it in. 42 // non-NULL, copies it in.
43 bool RetrieveCert(int cert_id, scoped_refptr<net::X509Certificate>* cert); 43 virtual bool RetrieveCert(int cert_id,
44 scoped_refptr<net::X509Certificate>* cert);
44 45
45 // content::NotificationObserver implementation. 46 // content::NotificationObserver implementation.
46 virtual void Observe(int type, 47 virtual void Observe(int type,
47 const content::NotificationSource& source, 48 const content::NotificationSource& source,
48 const content::NotificationDetails& details) OVERRIDE; 49 const content::NotificationDetails& details) OVERRIDE;
50 protected:
51 CertStore();
52 virtual ~CertStore();
49 53
50 private: 54 private:
51 friend struct DefaultSingletonTraits<CertStore>; 55 friend struct DefaultSingletonTraits<CertStore>;
52 56
53 CertStore();
54 virtual ~CertStore();
55
56 void RegisterForNotification(); 57 void RegisterForNotification();
57 58
58 // Remove the specified cert from id_to_cert_ and cert_to_id_. 59 // Remove the specified cert from id_to_cert_ and cert_to_id_.
59 // NOTE: the caller (RemoveCertsForRenderProcesHost) must hold cert_lock_. 60 // NOTE: the caller (RemoveCertsForRenderProcesHost) must hold cert_lock_.
60 void RemoveCertInternal(int cert_id); 61 void RemoveCertInternal(int cert_id);
61 62
62 // Removes all the certs associated with the specified process from the store. 63 // Removes all the certs associated with the specified process from the store.
63 void RemoveCertsForRenderProcesHost(int render_process_host_id); 64 void RemoveCertsForRenderProcesHost(int render_process_host_id);
64 65
65 typedef std::multimap<int, int> IDMap; 66 typedef std::multimap<int, int> IDMap;
(...skipping 13 matching lines...) Expand all
79 int next_cert_id_; 80 int next_cert_id_;
80 81
81 // This lock protects: process_to_ids_, id_to_processes_, id_to_cert_ and 82 // This lock protects: process_to_ids_, id_to_processes_, id_to_cert_ and
82 // cert_to_id_. 83 // cert_to_id_.
83 base::Lock cert_lock_; 84 base::Lock cert_lock_;
84 85
85 DISALLOW_COPY_AND_ASSIGN(CertStore); 86 DISALLOW_COPY_AND_ASSIGN(CertStore);
86 }; 87 };
87 88
88 #endif // CONTENT_BROWSER_CERT_STORE_H_ 89 #endif // CONTENT_BROWSER_CERT_STORE_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698