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

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 flow and added set overwrite functionality. 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..014ef48d21e0c7e82898841e0f32785112da3e1b
--- /dev/null
+++ b/net/http/disk_based_cert_cache.h
@@ -0,0 +1,82 @@
+// 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
wtc 2014/06/12 03:13:16 The include guard macro name needs to be updated.
+
+#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);
+
+ // Stores |handle| in the cache. If |handle| is successfully stored, |cb|
wtc 2014/06/12 03:13:17 |handle| => |cert_handle|
+ // 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.
wtc 2014/06/12 03:13:17 Add "TODO(brandonsalmon): " before this line.
+ enum State {
+ START_WRITE,
+ CREATE_OR_OPEN,
+ FINISH_CREATE_OR_OPEN,
+ FINISH_WRITE,
+ START_READ,
+ FINISH_READ,
+ NONE
+ };
+
+ std::string Key();
+ std::string Serialize();
+ void OnIOComplete(int rv);
+ void DoLoop(int rv);
+ int DoStartWrite(int rv);
+ int DoCreateOrOpen(int rv);
+ int DoFinishCreateOrOpen(int rv);
+ int DoFinishWrite(int rv);
+ int DoStartRead(int rv);
+ int DoFinishRead(int rv);
+
+ void ResetState();
+
+ // 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_;
+ CompletionCallback io_callback_;
+ State state_;
+ bool create_failed_;
+ int active_entry_size_;
+
+ X509Certificate::OSCertHandle active_cert_handle_;
+ scoped_refptr<IOBuffer> buffer;
+ base::Callback<void(const std::string&)> user_write_callback_;
+ base::Callback<void(X509Certificate::OSCertHandle cert_handle)>
+ user_read_callback_;
+
+ base::WeakPtrFactory<DiskBasedCertCache> weak_factory_;
+};
+
+} // namespace
wtc 2014/06/12 03:13:16 This comment needs to say "namespace net".
+
+#endif // NET_CERT_CACHE_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