1 // Copyright 2013 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.
5 #ifndef COMPONENTS_NACL_BROWSER_NACL_VALIDATION_CACHE_H_
6 #define COMPONENTS_NACL_BROWSER_NACL_VALIDATION_CACHE_H_
10 #include "base/containers/mru_cache.h"
18 class NaClValidationCache
{
20 NaClValidationCache();
21 ~NaClValidationCache();
23 // Get the key used for HMACing validation signatures. This should be a
24 // string of cryptographically secure random bytes.
25 const std::string
& GetValidationCacheKey() const {
26 return validation_cache_key_
;
29 // Is the validation signature in the database?
30 bool QueryKnownToValidate(const std::string
& signature
, bool reorder
);
32 // Put the validation signature in the database.
33 void SetKnownToValidate(const std::string
& signature
);
36 void Serialize(base::Pickle
* pickle
) const;
37 bool Deserialize(const base::Pickle
* pickle
);
41 return validation_cache_
.size();
43 void SetValidationCacheKey(std::string
& key
) {
44 validation_cache_key_
= key
;
46 std::vector
<std::string
> GetContents() const {
47 std::vector
<std::string
> contents
;
48 ValidationCacheType::const_iterator iter
= validation_cache_
.begin();
49 for (iter
= validation_cache_
.begin();
50 iter
!= validation_cache_
.end();
52 contents
.push_back(iter
->first
);
58 bool DeserializeImpl(const base::Pickle
* pickle
);
60 typedef base::HashingMRUCache
<std::string
, bool> ValidationCacheType
;
61 ValidationCacheType validation_cache_
;
63 std::string validation_cache_key_
;
65 DISALLOW_COPY_AND_ASSIGN(NaClValidationCache
);
70 #endif // COMPONENTS_NACL_BROWSER_NACL_VALIDATION_CACHE_H_