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<const std::string>; | 17 using BlobData = base::RefCountedData<std::string>; |
18 using BlobDataPtr = scoped_refptr<BlobData>; | 18 using BlobDataPtr = scoped_refptr<const BlobData>; |
Wez
2016/05/20 21:46:17
This seems peculiar - I think it's worth an explan
Kevin M
2016/05/23 20:48:07
Done.
| |
19 | 19 |
20 // An interface for a cache of blobs. | 20 // An interface for a cache of blobs. |
21 class BLIMP_COMMON_EXPORT BlobCache { | 21 class BLIMP_COMMON_EXPORT BlobCache { |
22 public: | 22 public: |
23 virtual ~BlobCache() {} | 23 virtual ~BlobCache() {} |
24 | 24 |
25 // Returns true if there is a cache item |id|. | 25 // Returns true if there is a cache item |id|. |
26 virtual bool Contains(const BlobId& id) const = 0; | 26 virtual bool Contains(const BlobId& id) const = 0; |
27 | 27 |
28 // Stores |data| with the identifier |id| in the cache. | 28 // Stores |data| with the identifier |id| in the cache. |
29 // Command is ignored if there is already a cache item stored under |id|. | 29 // Command is ignored if there is already a cache item stored under |id|. |
30 virtual void Put(const BlobId& id, BlobDataPtr data) = 0; | 30 virtual void Put(const BlobId& id, BlobDataPtr data) = 0; |
31 | 31 |
32 // Returns a pointer to the cache item |id|, or nullptr if no cache item | 32 // Returns a pointer to the cache item |id|, or nullptr if no cache item |
33 // exists under that identifier. | 33 // exists under that identifier. |
34 virtual BlobDataPtr Get(const BlobId& id) const = 0; | 34 virtual BlobDataPtr Get(const BlobId& id) const = 0; |
35 }; | 35 }; |
36 | 36 |
37 } // namespace blimp | 37 } // namespace blimp |
38 | 38 |
39 #endif // BLIMP_COMMON_BLOB_CACHE_BLOB_CACHE_H_ | 39 #endif // BLIMP_COMMON_BLOB_CACHE_BLOB_CACHE_H_ |
OLD | NEW |