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

Side by Side Diff: blimp/net/blob_channel/blob_channel_sender.cc

Issue 1985863002: Incorporate BlobChannel into Blimp image encode/decode pipeline. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blobchannel-helium
Patch Set: fix gn dependency warning & rebase Created 4 years, 6 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/net/blob_channel/blob_channel_sender.h"
6
7 #include "base/strings/string_number_conversions.h"
8 #include "blimp/common/blob_cache/blob_cache.h"
9 #include "blimp/common/blob_cache/id_util.h"
10
11 namespace blimp {
12
13 BlobChannelSender::BlobChannelSender(std::unique_ptr<BlobCache> cache,
14 std::unique_ptr<Delegate> delegate)
15 : cache_(std::move(cache)), delegate_(std::move(delegate)) {
16 DCHECK(cache_);
17 DCHECK(delegate_);
18 }
19
20 BlobChannelSender::~BlobChannelSender() {}
21
22 void BlobChannelSender::PutBlob(const BlobId& id, BlobDataPtr data) {
23 DCHECK(data);
24 DCHECK(!id.empty());
25
26 if (cache_->Contains(id)) {
27 return;
28 }
29
30 VLOG(2) << "Put blob: " << BlobIdToString(id);
31 cache_->Put(id, data);
32 }
33
34 void BlobChannelSender::DeliverBlob(const BlobId& id) {
35 if (!cache_->Contains(id)) {
36 DLOG(FATAL) << "Attempted to push unknown blob: " << BlobIdToString(id);
37 return;
38 }
39
40 if (receiver_cache_contents_.find(id) != receiver_cache_contents_.end()) {
41 DVLOG(3) << "Suppressed redundant push: " << BlobIdToString(id);
42 return;
43 }
44 receiver_cache_contents_.insert(id);
45
46 VLOG(2) << "Deliver blob: " << BlobIdToString(id);
47 delegate_->DeliverBlob(id, cache_->Get(id));
48 }
49
50 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/net/blob_channel/blob_channel_sender.h ('k') | blimp/net/blob_channel/blob_channel_sender_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698