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

Unified 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: Improved unittests, error checking, and improved functionality in workers (although this isn't prop… 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 side-by-side diff with in-line comments
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')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/disk_based_cert_cache.h
diff --git a/net/http/disk_based_cert_cache.h b/net/http/disk_based_cert_cache.h
new file mode 100644
index 0000000000000000000000000000000000000000..38380e81a5c119c6f0978df38e43838abb06e558
--- /dev/null
+++ b/net/http/disk_based_cert_cache.h
@@ -0,0 +1,71 @@
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NET_HTTP_DISK_BASED_CERT_CACHE_H
+#define NET_HTTP_DISK_BASED_CERT_CACHE_H
+
+#include <string>
+
+#include "base/bind.h"
+#include "base/callback.h"
+#include "base/memory/weak_ptr.h"
+#include "net/base/completion_callback.h"
+#include "net/base/net_export.h"
+#include "net/cert/x509_certificate.h"
+#include "net/disk_cache/disk_cache.h"
Ryan Sleevi 2014/06/17 00:00:21 As per http://www.chromium.org/developers/coding-s
+
+namespace net {
+
+class NET_EXPORT_PRIVATE DiskBasedCertCache {
+ public:
+ typedef base::Callback<void(const std::string&)> SetCallback;
+ 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
+ GetCallback;
+
+ // Constructor takes in a previously initialized backend, which is then
+ // used to store the certificates in the cache.
+ explicit DiskBasedCertCache(disk_cache::Backend* backend);
+ ~DiskBasedCertCache();
+
+ // Fetches the certificate associated with |key|. If the certificate is
+ // found within the cache, |cb| will be called with the certificate.
+ // Otherwise, |cb| will be called with NULL.
Ryan Sleevi 2014/06/17 00:00:21 Will |cb| ever be called synchronously? Good to do
+ void Get(std::string& key, GetCallback cb);
Ryan Sleevi 2014/06/17 00:00:21 STYLE: Reference arguments should always be passed
+
+ // Stores |cert_handle| in the cache. If |cert_handle| is successfully stored,
+ // |cb| will be called with the key. If |cb| is called with an empty
+ // std::string, then |handle| was not stored.
Ryan Sleevi 2014/06/17 00:00:21 empty std::string -> empty string
+ 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
+
+ base::WeakPtr<DiskBasedCertCache> GetWeakPtr() {
Ryan Sleevi 2014/06/17 00:00:21 DESIGN: Exposing a public member to allow access t
+ return weak_factory_.GetWeakPtr();
+ }
+
+ private:
+ // Types --------------------------------------------------------------------
Ryan Sleevi 2014/06/17 00:00:21 STYLE: Don't include these block-style comments (
+ class WriteWorker;
+ class ReadWorker;
+
+ typedef base::hash_map<std::string, WriteWorker*> WriteWorkerMap;
+ 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
+
+ // Methods ------------------------------------------------------------------
+ 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
+ void FinishedWriteOperation(const std::string& key);
+ void FinishedReadOperation(const std::string& key);
Ryan Sleevi 2014/06/17 00:00:21 Document (Briefly) what these methods do.
+
+ // Variables ----------------------------------------------------------------
+ WriteWorkerMap write_worker_map_;
+ ReadWorkerMap read_worker_map_;
+
+ disk_cache::Backend* backend_;
+ base::WeakPtrFactory<DiskBasedCertCache> weak_factory_;
+
+ base::Callback<void(const std::string&)> write_io_callback_;
+ base::Callback<void(const std::string&)> read_io_callback_;
+};
+
+} // namespace net
+
+#endif // NET_HTTP_DISK_BASED_CERT_CACHE_H
« 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