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

Unified Diff: net/cert_cache/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 and fixed first test. 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
Index: net/cert_cache/disk_based_cert_cache.h
diff --git a/net/cert_cache/disk_based_cert_cache.h b/net/cert_cache/disk_based_cert_cache.h
new file mode 100644
index 0000000000000000000000000000000000000000..a46b90e6d3b288481f9d4cc2ad9cd94dd8915172
--- /dev/null
+++ b/net/cert_cache/disk_based_cert_cache.h
@@ -0,0 +1,69 @@
+// 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_CERT_CACHE_DISK_BASED_CERT_CACHE_H
+#define NET_CERT_CACHE_DISK_BASED_CERT_CACHE_H
+
+#include <string>
+
+#include "base/bind.h"
+#include "base/callback.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"
+
+namespace net {
+
+class NET_EXPORT_PRIVATE DiskBasedCertCache {
+ public:
+ 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.
+ void Get(std::string& key,
+ base::Callback<void(X509Certificate::OSCertHandle cert_handle)> cb);
Ryan Sleevi 2014/06/11 22:00:09 Crap, I just realized a problem with this Callback
+
+ // Stores |handle| in the cache. If |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.
+ void Set(const X509Certificate::OSCertHandle cert_handle,
+ base::Callback<void(const std::string&)> cb);
+
+ private:
+ // State for the current operation, NONE indicates no pending operation.
+ // Will have to be updated to accomodate multiple simultaneous operations.
+ enum State { START_WRITE, FINISH_WRITE, START_READ, FINISH_READ, NONE };
+
+ std::string Key();
+ std::string Serialize();
+ void OnIOComplete(int rv);
+ void DoStartWrite();
+ void DoFinishWrite();
+ void DoStartRead();
+ void DoFinishRead();
+
+ void reset_state();
+
+ // Most of these data members will have to be changed in the near future
+ // to accommodate for simultaneous operation.
+ disk_cache::Backend* backend_;
+ disk_cache::Entry* active_entry_;
+ base::WeakPtrFactory<DiskBasedCertCache> weak_factory_;
Ryan Sleevi 2014/06/11 22:00:09 WeakPtrFactory should always be the last member of
+ CompletionCallback io_callback_;
+ State state_;
+
+ X509Certificate::OSCertHandle active_cert_handle_;
+ int active_entry_size_;
+ scoped_refptr<IOBuffer> buffer;
+ base::Callback<void(const std::string&)> user_write_callback_;
+ base::Callback<void(X509Certificate::OSCertHandle cert_handle)>
+ user_read_callback_;
+};
+
+} // namespace
+
+#endif // NET_CERT_CACHE_DISK_BASED_CERT_CACHE_H

Powered by Google App Engine
This is Rietveld 408576698