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

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

Issue 2056993003: Add Mojo IPC for seeding new Renderer with Browser's cached blob state. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blobchannel-master
Patch Set: Mojo mapz Created 4 years, 5 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "blimp/common/blob_cache/in_memory_blob_cache.h" 5 #include "blimp/common/blob_cache/in_memory_blob_cache.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 namespace blimp { 9 namespace blimp {
10 10
11 InMemoryBlobCache::InMemoryBlobCache() {} 11 InMemoryBlobCache::InMemoryBlobCache() {}
12 12
13 InMemoryBlobCache::~InMemoryBlobCache() {} 13 InMemoryBlobCache::~InMemoryBlobCache() {}
14 14
15 std::vector<BlobId> InMemoryBlobCache::GetCachedBlobIds() const {
16 std::vector<BlobId> output;
Wez 2016/07/01 00:30:20 nit: Suggest cached_ids.
Kevin M 2016/07/18 16:58:16 Done.
17 for (const auto& pair : cache_) {
Wez 2016/07/01 00:30:20 nit: Suggest blob_id_and_data_pair for clarity (si
Kevin M 2016/07/18 16:58:16 Done.
18 output.push_back(pair.first);
19 }
20 return output;
21 }
22
15 void InMemoryBlobCache::Put(const BlobId& id, BlobDataPtr data) { 23 void InMemoryBlobCache::Put(const BlobId& id, BlobDataPtr data) {
16 if (Contains(id)) { 24 if (Contains(id)) {
17 // In cases where the engine has miscalculated what is already available 25 // In cases where the engine has miscalculated what is already available
18 // on the client, Put() might be called unnecessarily, which should be 26 // on the client, Put() might be called unnecessarily, which should be
19 // ignored. 27 // ignored.
20 VLOG(2) << "Item with ID " << id << " already exists in cache."; 28 VLOG(2) << "Item with ID " << id << " already exists in cache.";
21 return; 29 return;
22 } 30 }
23 cache_.insert(std::make_pair(id, std::move(data))); 31 cache_.insert(std::make_pair(id, std::move(data)));
24 } 32 }
25 33
26 bool InMemoryBlobCache::Contains(const BlobId& id) const { 34 bool InMemoryBlobCache::Contains(const BlobId& id) const {
27 return cache_.find(id) != cache_.end(); 35 return cache_.find(id) != cache_.end();
28 } 36 }
29 37
30 BlobDataPtr InMemoryBlobCache::Get(const BlobId& id) const { 38 BlobDataPtr InMemoryBlobCache::Get(const BlobId& id) const {
31 if (!Contains(id)) { 39 if (!Contains(id)) {
32 return nullptr; 40 return nullptr;
33 } 41 }
34 42
35 return cache_.find(id)->second; 43 return cache_.find(id)->second;
36 } 44 }
37 45
38 } // namespace blimp 46 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698