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"
16 class NaClValidationCache
{
18 NaClValidationCache();
19 ~NaClValidationCache();
21 // Get the key used for HMACing validation signatures. This should be a
22 // string of cryptographically secure random bytes.
23 const std::string
& GetValidationCacheKey() const {
24 return validation_cache_key_
;
27 // Is the validation signature in the database?
28 bool QueryKnownToValidate(const std::string
& signature
, bool reorder
);
30 // Put the validation signature in the database.
31 void SetKnownToValidate(const std::string
& signature
);
34 void Serialize(Pickle
* pickle
) const;
35 bool Deserialize(const Pickle
* pickle
);
39 return validation_cache_
.size();
41 void SetValidationCacheKey(std::string
& key
) {
42 validation_cache_key_
= key
;
44 std::vector
<std::string
> GetContents() const {
45 std::vector
<std::string
> contents
;
46 ValidationCacheType::const_iterator iter
= validation_cache_
.begin();
47 for (iter
= validation_cache_
.begin();
48 iter
!= validation_cache_
.end();
50 contents
.push_back(iter
->first
);
56 bool DeserializeImpl(const Pickle
* pickle
);
58 typedef base::HashingMRUCache
<std::string
, bool> ValidationCacheType
;
59 ValidationCacheType validation_cache_
;
61 std::string validation_cache_key_
;
63 DISALLOW_COPY_AND_ASSIGN(NaClValidationCache
);
68 #endif // COMPONENTS_NACL_BROWSER_NACL_VALIDATION_CACHE_H_