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

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

Issue 2626423004: Remove all //blimp code. (Closed)
Patch Set: One last(?) `git merge` for good measure. Created 3 years, 11 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 <utility>
8
9 #include "base/logging.h"
10
11 namespace blimp {
12
13 InMemoryBlobCache::InMemoryBlobCache() {}
14
15 InMemoryBlobCache::~InMemoryBlobCache() {}
16
17 std::vector<BlobId> InMemoryBlobCache::GetCachedBlobIds() const {
18 std::vector<BlobId> cached_ids;
19 for (const auto& blob_id_and_data_pair : cache_) {
20 cached_ids.push_back(blob_id_and_data_pair.first);
21 }
22 return cached_ids;
23 }
24
25 void InMemoryBlobCache::Put(const BlobId& id, BlobDataPtr data) {
26 if (Contains(id)) {
27 // In cases where the engine has miscalculated what is already available
28 // on the client, Put() might be called unnecessarily, which should be
29 // ignored.
30 VLOG(2) << "Item with ID " << id << " already exists in cache.";
31 return;
32 }
33 cache_.insert(std::make_pair(id, std::move(data)));
34 }
35
36 bool InMemoryBlobCache::Contains(const BlobId& id) const {
37 return cache_.find(id) != cache_.end();
38 }
39
40 BlobDataPtr InMemoryBlobCache::Get(const BlobId& id) const {
41 if (!Contains(id)) {
42 return nullptr;
43 }
44
45 return cache_.find(id)->second;
46 }
47
48 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/common/blob_cache/in_memory_blob_cache.h ('k') | blimp/common/blob_cache/in_memory_blob_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698