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

Side by Side Diff: net/http/disk_based_cert_cache.h

Issue 329733002: Disk Based Certificate Cache Implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated unittests with respect to the review of patch 9. Created 6 years, 6 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
« no previous file with comments | « no previous file | net/http/disk_based_cert_cache.cc » ('j') | net/http/disk_based_cert_cache.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2014 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.
4
5 #ifndef NET_HTTP_DISK_BASED_CERT_CACHE_H
6 #define NET_HTTP_DISK_BASED_CERT_CACHE_H
7
8 #include <string>
9
10 #include "base/callback.h"
11 #include "base/containers/hash_tables.h"
12 #include "base/memory/weak_ptr.h"
13 #include "net/base/net_export.h"
14 #include "net/cert/x509_certificate.h"
15
16 namespace disk_cache {
17 class Backend;
18 } // namespace disk_cache
19
20 namespace net {
wtc 2014/06/24 00:21:04 Nit: add a blank line after this line.
21 // DiskBasedCertCache is used to store and retrieve X509Certificates from the
Ryan Sleevi 2014/06/23 22:43:58 comment nit: You don't actually take X509Certifica
Ryan Sleevi 2014/06/23 22:43:58 style: newline between 20 & 21
22 // cache. Each individual certificate is stored separately from its Certificate
Ryan Sleevi 2014/06/23 22:43:58 s/Certificate/certificate
23 // chain. Each certificate is associated with a unique cache key that is
24 // created with a SHA1 hash.
Ryan Sleevi 2014/06/23 22:43:58 comment nit: this last comment feels like it's exp
25 class NET_EXPORT_PRIVATE DiskBasedCertCache {
26 public:
27 typedef base::Callback<void(const X509Certificate::OSCertHandle cert_handle)>
28 GetCallback;
29 typedef base::Callback<void(const std::string&)> SetCallback;
30
31 // Constructor takes in a previously initialized backend, which is then
32 // used to store the certificates in the cache.
Ryan Sleevi 2014/06/23 22:43:58 Usual comment style is to avoid using the word "co
33 explicit DiskBasedCertCache(disk_cache::Backend* backend);
34 ~DiskBasedCertCache();
35
36 // Fetches the certificate associated with |key|. If the certificate is
37 // found within the cache, |cb| will be called with the certificate.
38 // Otherwise, |cb| will be called with NULL. Callers that wish to store
39 // a reference to the certificate need to use X509Certificate::DupOSCertHandle
40 // inside |cb|.
41 void Get(const std::string& key, const GetCallback& cb);
42
43 // Stores |cert_handle| in the cache. If |cert_handle| is successfully stored,
44 // |cb| will be called with the key. If |cb| is called with an empty
45 // string, then |cert_handle| was not stored.
46 void Set(const X509Certificate::OSCertHandle cert_handle,
47 const SetCallback& cb);
48
49 private:
50 class ReadWorker;
51 class WriteWorker;
52
53 // ReadWorkerMap and WriteWorkerMap map cache keys to their
54 // corresponding Workers.
55 typedef base::hash_map<std::string, ReadWorker*> ReadWorkerMap;
56 typedef base::hash_map<std::string, WriteWorker*> WriteWorkerMap;
57
58 // FinishedReadOperation and FinishedWriteOperation are used by callbacks
59 // given to the workers to signal the DiskBasedCertCache they have completed
60 // their work. The workers are then deleted and removed from their respective
61 // hash maps.
Ryan Sleevi 2014/06/23 22:43:58 This last sentence is an implementation detail; we
62 void FinishedReadOperation(const std::string& key);
63 void FinishedWriteOperation(const std::string& key);
64
65 ReadWorkerMap read_worker_map_;
66 WriteWorkerMap write_worker_map_;
67
68 disk_cache::Backend* backend_;
69 base::WeakPtrFactory<DiskBasedCertCache> weak_factory_;
70 DISALLOW_COPY_AND_ASSIGN(DiskBasedCertCache);
71 };
72
73 } // namespace net
74
75 #endif // NET_HTTP_DISK_BASED_CERT_CACHE_H
OLDNEW
« no previous file with comments | « no previous file | net/http/disk_based_cert_cache.cc » ('j') | net/http/disk_based_cert_cache.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698