OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef BLIMP_COMMON_BLOB_CACHE_BLOB_CACHE_H_ | 5 #ifndef BLIMP_COMMON_BLOB_CACHE_BLOB_CACHE_H_ |
6 #define BLIMP_COMMON_BLOB_CACHE_BLOB_CACHE_H_ | 6 #define BLIMP_COMMON_BLOB_CACHE_BLOB_CACHE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "blimp/common/blimp_common_export.h" | 12 #include "blimp/common/blimp_common_export.h" |
13 | 13 |
14 namespace blimp { | 14 namespace blimp { |
15 | 15 |
16 using BlobId = std::string; | 16 using BlobId = std::string; |
17 using BlobData = base::RefCountedData<std::string>; | 17 using BlobData = base::RefCountedData<std::string>; |
18 | 18 |
19 // Immutable, ref-counted representation of blob payloads, suitable for sharing | 19 // Immutable, ref-counted representation of blob payloads, suitable for sharing |
20 // across threads. | 20 // across threads. |
21 using BlobDataPtr = scoped_refptr<const BlobData>; | 21 using BlobDataPtr = scoped_refptr<const BlobData>; |
22 | 22 |
23 // An interface for a cache of blobs. | 23 // An interface for a cache of blobs. |
24 class BLIMP_COMMON_EXPORT BlobCache { | 24 class BLIMP_COMMON_EXPORT BlobCache { |
25 public: | 25 public: |
26 virtual ~BlobCache() {} | 26 virtual ~BlobCache() {} |
27 | 27 |
28 // Gets the keys of items stored by the cache. | |
29 virtual std::vector<BlobId> GetCacheState() const = 0; | |
Wez
2016/06/21 00:33:33
nit: GetCachedBlobIds()?
Wez
2016/06/21 00:33:33
In general this seems like a potentially large str
Kevin M
2016/06/21 21:23:51
Done.
Kevin M
2016/06/21 21:23:51
Agreed, but in general I think if this saves us ev
Wez
2016/06/22 19:54:23
Acknowledged.
| |
30 | |
28 // Returns true if there is a cache item |id|. | 31 // Returns true if there is a cache item |id|. |
29 virtual bool Contains(const BlobId& id) const = 0; | 32 virtual bool Contains(const BlobId& id) const = 0; |
30 | 33 |
31 // Stores |data| with the identifier |id| in the cache. | 34 // Stores |data| with the identifier |id| in the cache. |
32 // Command is ignored if there is already a cache item stored under |id|. | 35 // Command is ignored if there is already a cache item stored under |id|. |
33 virtual void Put(const BlobId& id, BlobDataPtr data) = 0; | 36 virtual void Put(const BlobId& id, BlobDataPtr data) = 0; |
34 | 37 |
35 // Returns a pointer to the cache item |id|, or nullptr if no cache item | 38 // Returns a pointer to the cache item |id|, or nullptr if no cache item |
36 // exists under that identifier. | 39 // exists under that identifier. |
37 virtual BlobDataPtr Get(const BlobId& id) const = 0; | 40 virtual BlobDataPtr Get(const BlobId& id) const = 0; |
38 }; | 41 }; |
39 | 42 |
40 } // namespace blimp | 43 } // namespace blimp |
41 | 44 |
42 #endif // BLIMP_COMMON_BLOB_CACHE_BLOB_CACHE_H_ | 45 #endif // BLIMP_COMMON_BLOB_CACHE_BLOB_CACHE_H_ |
OLD | NEW |