OLD | NEW |
| (Empty) |
1 // Copyright 2016 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 BLIMP_COMMON_BLOB_CACHE_BLOB_CACHE_H_ | |
6 #define BLIMP_COMMON_BLOB_CACHE_BLOB_CACHE_H_ | |
7 | |
8 #include <string> | |
9 #include <vector> | |
10 | |
11 #include "base/memory/ref_counted.h" | |
12 #include "blimp/common/blimp_common_export.h" | |
13 | |
14 namespace blimp { | |
15 | |
16 using BlobId = std::string; | |
17 using BlobData = base::RefCountedData<std::string>; | |
18 | |
19 // Immutable, ref-counted representation of blob payloads, suitable for sharing | |
20 // across threads. | |
21 using BlobDataPtr = scoped_refptr<const BlobData>; | |
22 | |
23 // An interface for a cache of blobs. | |
24 class BLIMP_COMMON_EXPORT BlobCache { | |
25 public: | |
26 virtual ~BlobCache() {} | |
27 | |
28 // Gets the keys of items stored by the cache. | |
29 virtual std::vector<BlobId> GetCachedBlobIds() const = 0; | |
30 | |
31 // Returns true if there is a cache item |id|. | |
32 virtual bool Contains(const BlobId& id) const = 0; | |
33 | |
34 // Stores |data| with the identifier |id| in the cache. | |
35 // Command is ignored if there is already a cache item stored under |id|. | |
36 virtual void Put(const BlobId& id, BlobDataPtr data) = 0; | |
37 | |
38 // Returns a pointer to the cache item |id|, or nullptr if no cache item | |
39 // exists under that identifier. | |
40 virtual BlobDataPtr Get(const BlobId& id) const = 0; | |
41 }; | |
42 | |
43 } // namespace blimp | |
44 | |
45 #endif // BLIMP_COMMON_BLOB_CACHE_BLOB_CACHE_H_ | |
OLD | NEW |