| Index: blimp/common/blob_cache/infinite_blob_cache.cc
|
| diff --git a/blimp/common/blob_cache/infinite_blob_cache.cc b/blimp/common/blob_cache/infinite_blob_cache.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..c52c4adda2cc44d646e780dfbb088acf829dfb93
|
| --- /dev/null
|
| +++ b/blimp/common/blob_cache/infinite_blob_cache.cc
|
| @@ -0,0 +1,40 @@
|
| +// 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.
|
| +
|
| +#include "blimp/common/blob_cache/infinite_blob_cache.h"
|
| +
|
| +#include "base/logging.h"
|
| +#include "base/sha1.h"
|
| +#include "base/strings/string_number_conversions.h"
|
| +#include "base/strings/string_util.h"
|
| +
|
| +namespace blimp {
|
| +
|
| +InfiniteBlobCache::InfiniteBlobCache() {}
|
| +
|
| +InfiniteBlobCache::~InfiniteBlobCache() {}
|
| +
|
| +void InfiniteBlobCache::Put(const std::string& id,
|
| + scoped_refptr<RefCountedVector> data) {
|
| + if (Contains(id)) {
|
| + DLOG(WARNING) << "Item with ID " << id << " already exists in cache.";
|
| + return;
|
| + }
|
| + map_.insert(std::make_pair(id, data));
|
| +}
|
| +
|
| +bool InfiniteBlobCache::Contains(const std::string& id) const {
|
| + return map_.find(id) != map_.end();
|
| +}
|
| +
|
| +scoped_refptr<RefCountedVector> InfiniteBlobCache::Get(
|
| + const std::string& id) const {
|
| + if (!Contains(id)) {
|
| + return nullptr;
|
| + }
|
| +
|
| + return map_.find(id)->second;
|
| +}
|
| +
|
| +} // namespace blimp
|
|
|