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

Side by Side 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 unified diff | Download patch
OLDNEW
(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_CERT_CACHE_DISK_BASED_CERT_CACHE_H
6 #define NET_CERT_CACHE_DISK_BASED_CERT_CACHE_H
7
8 #include <string>
9
10 #include "base/bind.h"
11 #include "base/callback.h"
12 #include "net/base/completion_callback.h"
13 #include "net/base/net_export.h"
14 #include "net/cert/x509_certificate.h"
15 #include "net/disk_cache/disk_cache.h"
16
17 namespace net {
18
19 class NET_EXPORT_PRIVATE DiskBasedCertCache {
20 public:
21 explicit DiskBasedCertCache(disk_cache::Backend* backend);
22 ~DiskBasedCertCache();
23
24 // Fetches the certificate associated with |key|. If the certificate is
25 // found within the cache, |cb| will be called with the certificate.
26 // Otherwise, |cb| will be called with NULL.
27 void Get(std::string& key,
28 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
29
30 // Stores |handle| in the cache. If |handle| is successfully stored, |cb|
31 // will be called with the key. If |cb| is called with an empty std::string,
32 // then |handle| was not stored.
33 void Set(const X509Certificate::OSCertHandle cert_handle,
34 base::Callback<void(const std::string&)> cb);
35
36 private:
37 // State for the current operation, NONE indicates no pending operation.
38 // Will have to be updated to accomodate multiple simultaneous operations.
39 enum State { START_WRITE, FINISH_WRITE, START_READ, FINISH_READ, NONE };
40
41 std::string Key();
42 std::string Serialize();
43 void OnIOComplete(int rv);
44 void DoStartWrite();
45 void DoFinishWrite();
46 void DoStartRead();
47 void DoFinishRead();
48
49 void reset_state();
50
51 // Most of these data members will have to be changed in the near future
52 // to accommodate for simultaneous operation.
53 disk_cache::Backend* backend_;
54 disk_cache::Entry* active_entry_;
55 base::WeakPtrFactory<DiskBasedCertCache> weak_factory_;
Ryan Sleevi 2014/06/11 22:00:09 WeakPtrFactory should always be the last member of
56 CompletionCallback io_callback_;
57 State state_;
58
59 X509Certificate::OSCertHandle active_cert_handle_;
60 int active_entry_size_;
61 scoped_refptr<IOBuffer> buffer;
62 base::Callback<void(const std::string&)> user_write_callback_;
63 base::Callback<void(X509Certificate::OSCertHandle cert_handle)>
64 user_read_callback_;
65 };
66
67 } // namespace
68
69 #endif // NET_CERT_CACHE_DISK_BASED_CERT_CACHE_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698