Support Promise<T> syntax in the IDL parser.
[chromium-blink-merge.git] / components / nacl / browser / nacl_validation_cache.h
blobf9961fdee9268ca9b37ff0663d2f8586dc3cbe77
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_
8 #include <vector>
10 #include "base/containers/mru_cache.h"
12 class Pickle;
14 namespace nacl {
16 class NaClValidationCache {
17 public:
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);
33 void Reset();
34 void Serialize(Pickle* pickle) const;
35 bool Deserialize(const Pickle* pickle);
37 // Testing functions
38 size_t size() const {
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();
49 iter++) {
50 contents.push_back(iter->first);
52 return contents;
55 private:
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);
66 } // namespace nacl
68 #endif // COMPONENTS_NACL_BROWSER_NACL_VALIDATION_CACHE_H_