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

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

Issue 1867653002: Initial version of Blimp BlobCache. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed all comments. 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/infinite_blob_cache.h
diff --git a/blimp/common/blob_cache/infinite_blob_cache.h b/blimp/common/blob_cache/infinite_blob_cache.h
new file mode 100644
index 0000000000000000000000000000000000000000..2f17943146eda38285deb4429ddf815d96861382
--- /dev/null
+++ b/blimp/common/blob_cache/infinite_blob_cache.h
@@ -0,0 +1,41 @@
+// 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_INFINITE_BLOB_CACHE_H_
+#define BLIMP_COMMON_BLOB_CACHE_INFINITE_BLOB_CACHE_H_
+
+#include <map>
+#include <string>
+#include <vector>
Kevin M 2016/04/14 20:08:30 Necessary?
nyquist 2016/04/15 01:27:12 Done.
+
+#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 {
+
+// InfiniteBlobCache provides an in-memory implementation of BlobCache that
+// never evicts items.
+class BLIMP_COMMON_EXPORT InfiniteBlobCache : public BlobCache {
Kevin M 2016/04/14 20:08:30 InMemoryBlobCache (suggested by Wez because the na
nyquist 2016/04/15 01:27:12 Done.
+ public:
+ InfiniteBlobCache();
+ ~InfiniteBlobCache() 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;
+ Cache map_;
+
+ DISALLOW_COPY_AND_ASSIGN(InfiniteBlobCache);
+};
+
+} // namespace blimp
+
+#endif // BLIMP_COMMON_BLOB_CACHE_INFINITE_BLOB_CACHE_H_

Powered by Google App Engine
This is Rietveld 408576698