Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2439)

Unified Diff: blimp/common/blob_cache/blob_cache.h

Issue 1867653002: Initial version of Blimp BlobCache. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed to use BlobId and BlobData Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: blimp/common/blob_cache/blob_cache.h
diff --git a/blimp/common/blob_cache/blob_cache.h b/blimp/common/blob_cache/blob_cache.h
new file mode 100644
index 0000000000000000000000000000000000000000..033b8c045ff54c03f2e43fdfe7061fe03a18d165
--- /dev/null
+++ b/blimp/common/blob_cache/blob_cache.h
@@ -0,0 +1,38 @@
+// 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_BLOB_CACHE_H_
+#define BLIMP_COMMON_BLOB_CACHE_BLOB_CACHE_H_
+
+#include <string>
+#include <vector>
+
+#include "base/memory/ref_counted.h"
+#include "blimp/common/blimp_common_export.h"
+
+namespace blimp {
+
+using BlobId = const std::string;
+using BlobData = scoped_refptr<base::RefCountedData<const std::string>>;
+
+// An interface for a cache of blobs.
+class BLIMP_COMMON_EXPORT BlobCache {
+ public:
+ virtual ~BlobCache() {}
+
+ // Returns true if there is a cache item |id|.
+ virtual bool Contains(BlobId& id) const = 0;
nyquist 2016/04/16 00:25:30 This makes cpplint angry (here and in the sha1util
vmpstr 2016/04/16 00:52:47 I don't think linter is smart enough to do this. A
vmpstr 2016/04/16 00:55:08 Can you just make this a string in general and not
nyquist 2016/04/16 01:10:50 As a pure std::string I'm not sure either. Since w
+
+ // Stores |data| with the identifier |id| in the cache.
+ // Command is ignored if there is already a cache item stored under |id|.
+ virtual void Put(BlobId& id, BlobData data) = 0;
+
+ // Returns a pointer to the cache item |id|, or nullptr if no cache item
+ // exists under that identifier.
+ virtual BlobData Get(BlobId& id) const = 0;
+};
+
+} // namespace blimp
+
+#endif // BLIMP_COMMON_BLOB_CACHE_BLOB_CACHE_H_

Powered by Google App Engine
This is Rietveld 408576698