Chromium Code Reviews| OLD | NEW |
|---|---|
| (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/bind.h" | |
|
Ryan Sleevi
2014/06/18 22:16:04
You don't need Bind here; you can move it to the .
| |
| 11 #include "base/callback.h" | |
| 12 #include "base/containers/hash_tables.h" | |
| 13 #include "base/memory/weak_ptr.h" | |
| 14 #include "net/base/completion_callback.h" | |
|
Ryan Sleevi
2014/06/18 22:16:04
You don't use net::CompletionCallback in the .h. I
| |
| 15 #include "net/base/net_export.h" | |
| 16 #include "net/cert/x509_certificate.h" | |
| 17 | |
| 18 namespace disk_cache { | |
| 19 class Backend; | |
| 20 } // namespace disk_cache | |
| 21 | |
| 22 namespace net { | |
| 23 | |
| 24 class NET_EXPORT_PRIVATE DiskBasedCertCache { | |
| 25 public: | |
| 26 typedef base::Callback<void(const X509Certificate::OSCertHandle cert_handle)> | |
| 27 GetCallback; | |
| 28 typedef base::Callback<void(const std::string&)> SetCallback; | |
| 29 | |
| 30 // Constructor takes in a previously initialized backend, which is then | |
| 31 // used to store the certificates in the cache. | |
| 32 explicit DiskBasedCertCache(disk_cache::Backend* backend); | |
| 33 ~DiskBasedCertCache(); | |
| 34 | |
| 35 // Fetches the certificate associated with |key|. If the certificate is | |
| 36 // found within the cache, |cb| will be called with the certificate. | |
| 37 // Otherwise, |cb| will be called with NULL. Document ownership of | |
| 38 // |cert_handle| is not transferred. | |
|
Ryan Sleevi
2014/06/18 22:16:04
I suspect there may have been confusion about my r
| |
| 39 void Get(const std::string& key, const GetCallback& cb); | |
| 40 | |
| 41 // Stores |cert_handle| in the cache. If |cert_handle| is successfully stored, | |
| 42 // |cb| will be called with the key. If |cb| is called with an empty | |
| 43 // string, then |handle| was not stored. | |
| 44 void Set(const X509Certificate::OSCertHandle cert_handle, | |
| 45 const SetCallback& cb); | |
| 46 | |
| 47 private: | |
| 48 class ReadWorker; | |
| 49 class WriteWorker; | |
| 50 | |
| 51 typedef base::hash_map<std::string, ReadWorker*> ReadWorkerMap; | |
| 52 typedef base::hash_map<std::string, WriteWorker*> WriteWorkerMap; | |
| 53 | |
| 54 // FinishedReadOperation and FinishedWriteOperation are used by callbacks | |
| 55 // given to the workers to signal the DiskBasedCertCache they have completed | |
| 56 // their work. The workers are then deleted and removed from their respective | |
| 57 // hash maps. | |
| 58 void FinishedReadOperation(const std::string& key); | |
| 59 void FinishedWriteOperation(const std::string& key); | |
| 60 | |
| 61 ReadWorkerMap read_worker_map_; | |
| 62 WriteWorkerMap write_worker_map_; | |
| 63 | |
| 64 disk_cache::Backend* backend_; | |
| 65 base::WeakPtrFactory<DiskBasedCertCache> weak_factory_; | |
| 66 }; | |
|
Ryan Sleevi
2014/06/18 22:16:04
You will want to use DISALLOW_COPY_AND_ASSIGN(Disk
| |
| 67 | |
| 68 } // namespace net | |
| 69 | |
| 70 #endif // NET_HTTP_DISK_BASED_CERT_CACHE_H | |
| OLD | NEW |