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" | |
| 11 #include "base/callback.h" | |
| 12 #include "base/memory/weak_ptr.h" | |
| 13 #include "net/base/completion_callback.h" | |
| 14 #include "net/base/net_export.h" | |
| 15 #include "net/cert/x509_certificate.h" | |
| 16 #include "net/disk_cache/disk_cache.h" | |
|
Ryan Sleevi
2014/06/17 00:00:21
As per http://www.chromium.org/developers/coding-s
| |
| 17 | |
| 18 namespace net { | |
| 19 | |
| 20 class NET_EXPORT_PRIVATE DiskBasedCertCache { | |
| 21 public: | |
| 22 typedef base::Callback<void(const std::string&)> SetCallback; | |
| 23 typedef base::Callback<void(X509Certificate::OSCertHandle cert_handle)> | |
|
Ryan Sleevi
2014/06/17 00:00:21
STYLE: In this case, you likely want to ensure you
| |
| 24 GetCallback; | |
| 25 | |
| 26 // Constructor takes in a previously initialized backend, which is then | |
| 27 // used to store the certificates in the cache. | |
| 28 explicit DiskBasedCertCache(disk_cache::Backend* backend); | |
| 29 ~DiskBasedCertCache(); | |
| 30 | |
| 31 // Fetches the certificate associated with |key|. If the certificate is | |
| 32 // found within the cache, |cb| will be called with the certificate. | |
| 33 // Otherwise, |cb| will be called with NULL. | |
|
Ryan Sleevi
2014/06/17 00:00:21
Will |cb| ever be called synchronously? Good to do
| |
| 34 void Get(std::string& key, GetCallback cb); | |
|
Ryan Sleevi
2014/06/17 00:00:21
STYLE: Reference arguments should always be passed
| |
| 35 | |
| 36 // Stores |cert_handle| in the cache. If |cert_handle| is successfully stored, | |
| 37 // |cb| will be called with the key. If |cb| is called with an empty | |
| 38 // std::string, then |handle| was not stored. | |
|
Ryan Sleevi
2014/06/17 00:00:21
empty std::string -> empty string
| |
| 39 void Set(const X509Certificate::OSCertHandle cert_handle, SetCallback cb); | |
|
Ryan Sleevi
2014/06/17 00:00:21
And with the exception of above, you need to pass
| |
| 40 | |
| 41 base::WeakPtr<DiskBasedCertCache> GetWeakPtr() { | |
|
Ryan Sleevi
2014/06/17 00:00:21
DESIGN: Exposing a public member to allow access t
| |
| 42 return weak_factory_.GetWeakPtr(); | |
| 43 } | |
| 44 | |
| 45 private: | |
| 46 // Types -------------------------------------------------------------------- | |
|
Ryan Sleevi
2014/06/17 00:00:21
STYLE: Don't include these block-style comments (
| |
| 47 class WriteWorker; | |
| 48 class ReadWorker; | |
| 49 | |
| 50 typedef base::hash_map<std::string, WriteWorker*> WriteWorkerMap; | |
| 51 typedef base::hash_map<std::string, ReadWorker*> ReadWorkerMap; | |
|
Ryan Sleevi
2014/06/17 00:00:21
You use base::hash_map, but you never include the
| |
| 52 | |
| 53 // Methods ------------------------------------------------------------------ | |
| 54 std::string Key(const X509Certificate::OSCertHandle cert_handle) const; | |
|
Ryan Sleevi
2014/06/17 00:00:21
STYLE: Function names are generally of the form of
| |
| 55 void FinishedWriteOperation(const std::string& key); | |
| 56 void FinishedReadOperation(const std::string& key); | |
|
Ryan Sleevi
2014/06/17 00:00:21
Document (Briefly) what these methods do.
| |
| 57 | |
| 58 // Variables ---------------------------------------------------------------- | |
| 59 WriteWorkerMap write_worker_map_; | |
| 60 ReadWorkerMap read_worker_map_; | |
| 61 | |
| 62 disk_cache::Backend* backend_; | |
| 63 base::WeakPtrFactory<DiskBasedCertCache> weak_factory_; | |
| 64 | |
| 65 base::Callback<void(const std::string&)> write_io_callback_; | |
| 66 base::Callback<void(const std::string&)> read_io_callback_; | |
| 67 }; | |
| 68 | |
| 69 } // namespace net | |
| 70 | |
| 71 #endif // NET_HTTP_DISK_BASED_CERT_CACHE_H | |
| OLD | NEW |