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_CERT_CACHE_DISK_BASED_CERT_CACHE_H | |
6 #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.
| |
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); | |
29 | |
30 // Stores |handle| in the cache. If |handle| is successfully stored, |cb| | |
wtc
2014/06/12 03:13:17
|handle| => |cert_handle|
| |
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. | |
wtc
2014/06/12 03:13:17
Add "TODO(brandonsalmon): " before this line.
| |
39 enum State { | |
40 START_WRITE, | |
41 CREATE_OR_OPEN, | |
42 FINISH_CREATE_OR_OPEN, | |
43 FINISH_WRITE, | |
44 START_READ, | |
45 FINISH_READ, | |
46 NONE | |
47 }; | |
48 | |
49 std::string Key(); | |
50 std::string Serialize(); | |
51 void OnIOComplete(int rv); | |
52 void DoLoop(int rv); | |
53 int DoStartWrite(int rv); | |
54 int DoCreateOrOpen(int rv); | |
55 int DoFinishCreateOrOpen(int rv); | |
56 int DoFinishWrite(int rv); | |
57 int DoStartRead(int rv); | |
58 int DoFinishRead(int rv); | |
59 | |
60 void ResetState(); | |
61 | |
62 // Most of these data members will have to be changed in the near future | |
63 // to accommodate for simultaneous operation. | |
64 disk_cache::Backend* backend_; | |
65 disk_cache::Entry* active_entry_; | |
66 CompletionCallback io_callback_; | |
67 State state_; | |
68 bool create_failed_; | |
69 int active_entry_size_; | |
70 | |
71 X509Certificate::OSCertHandle active_cert_handle_; | |
72 scoped_refptr<IOBuffer> buffer; | |
73 base::Callback<void(const std::string&)> user_write_callback_; | |
74 base::Callback<void(X509Certificate::OSCertHandle cert_handle)> | |
75 user_read_callback_; | |
76 | |
77 base::WeakPtrFactory<DiskBasedCertCache> weak_factory_; | |
78 }; | |
79 | |
80 } // namespace | |
wtc
2014/06/12 03:13:16
This comment needs to say "namespace net".
| |
81 | |
82 #endif // NET_CERT_CACHE_DISK_BASED_CERT_CACHE_H | |
OLD | NEW |