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

Side by Side Diff: blimp/common/blob_cache/in_memory_blob_cache.cc

Issue 1867653002: Initial version of Blimp BlobCache. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments from kmarshall, except swap 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "blimp/common/blob_cache/in_memory_blob_cache.h"
6
7 #include "base/logging.h"
8 #include "base/sha1.h"
9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_util.h"
11
12 namespace blimp {
13
14 InMemoryBlobCache::InMemoryBlobCache() {}
15
16 InMemoryBlobCache::~InMemoryBlobCache() {}
17
18 void InMemoryBlobCache::Put(const std::string& id,
19 scoped_refptr<RefCountedVector> data) {
20 if (Contains(id)) {
21 DLOG(WARNING) << "Item with ID " << id << " already exists in cache.";
vmpstr 2016/04/15 18:18:54 If this is not an expected scenario, then it shoul
nyquist 2016/04/16 00:25:29 Done.
22 return;
23 }
24 map_.insert(std::make_pair(id, data));
vmpstr 2016/04/15 18:18:54 you can std::move(data) here to avoid ref/unref if
nyquist 2016/04/16 00:25:29 Done.
25 }
26
27 bool InMemoryBlobCache::Contains(const std::string& id) const {
28 return map_.find(id) != map_.end();
29 }
30
31 scoped_refptr<RefCountedVector> InMemoryBlobCache::Get(
32 const std::string& id) const {
33 if (!Contains(id)) {
34 return nullptr;
35 }
36
37 return map_.find(id)->second;
38 }
39
40 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698