Chromium Code Reviews| Index: blimp/common/blob_cache/in_memory_blob_cache.h |
| diff --git a/blimp/common/blob_cache/in_memory_blob_cache.h b/blimp/common/blob_cache/in_memory_blob_cache.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9e7107b6d61131093c6c8294e3aac6311540f23e |
| --- /dev/null |
| +++ b/blimp/common/blob_cache/in_memory_blob_cache.h |
| @@ -0,0 +1,40 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef BLIMP_COMMON_BLOB_CACHE_IN_MEMORY_BLOB_CACHE_H_ |
| +#define BLIMP_COMMON_BLOB_CACHE_IN_MEMORY_BLOB_CACHE_H_ |
| + |
| +#include <map> |
| +#include <string> |
| + |
| +#include "base/macros.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "blimp/common/blimp_common_export.h" |
| +#include "blimp/common/blob_cache/blob_cache.h" |
| + |
| +namespace blimp { |
| + |
| +// InMemoryBlobCache provides an in-memory implementation of BlobCache that |
| +// never evicts items. |
| +class BLIMP_COMMON_EXPORT InMemoryBlobCache : public BlobCache { |
| + public: |
| + InMemoryBlobCache(); |
| + ~InMemoryBlobCache() override; |
| + |
| + // BlobCache implementation. |
| + bool Contains(const std::string& id) const override; |
| + void Put(const std::string& id, |
| + scoped_refptr<RefCountedVector> data) override; |
| + scoped_refptr<RefCountedVector> Get(const std::string& id) const override; |
| + |
| + private: |
| + typedef std::map<std::string, scoped_refptr<RefCountedVector>> Cache; |
|
Kevin M
2016/04/15 17:28:51
The typedef is kind of unnecessary here, since you
nyquist
2016/04/16 00:25:29
Done.
|
| + Cache map_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(InMemoryBlobCache); |
| +}; |
| + |
| +} // namespace blimp |
| + |
| +#endif // BLIMP_COMMON_BLOB_CACHE_IN_MEMORY_BLOB_CACHE_H_ |