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

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: Changed BlobId from 'const std::string' to 'std::string' 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 BlobId& id, BlobData data) {
19 if (Contains(id)) {
20 // In cases where the engine has miscalculated what is already available
vmpstr 2016/04/18 19:38:11 I'm ok with leaving this as is, but this would see
nyquist 2016/04/18 20:12:02 When we deploy this for realz, there idea is to us
21 // on the client, Put() might be called unnecessarily, which should be
22 // ignored.
23 VLOG(2) << "Item with ID " << id << " already exists in cache.";
24 return;
25 }
26 cache_.insert(std::make_pair(id, std::move(data)));
27 }
28
29 bool InMemoryBlobCache::Contains(const BlobId& id) const {
30 return cache_.find(id) != cache_.end();
31 }
32
33 BlobData InMemoryBlobCache::Get(const BlobId& id) const {
34 if (!Contains(id)) {
vmpstr 2016/04/18 19:38:11 nit: braces optional
nyquist 2016/04/18 20:12:02 The other reviewer pointed out to me that in //bli
35 return nullptr;
36 }
37
38 return cache_.find(id)->second;
39 }
40
41 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698