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

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

Issue 1887013003: Blimp: Add BlobChannelSender implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blobchannel-blobcache
Patch Set: Wez feedback. 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/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
10 namespace blimp {
11
12 BlobChannelSender::BlobChannelSender(BlobCache* cache,
13 Delegate* delegate)
14 : cache_(cache), delegate_(delegate) {
15 DCHECK(cache_);
16 DCHECK(delegate_);
17 }
18
19 BlobChannelSender::~BlobChannelSender() {}
20
21 void BlobChannelSender::Put(const BlobId& id, BlobData data) {
22 DCHECK(data.get());
Wez 2016/04/19 00:01:57 nit: Just DCHECK(data) Do you also want to DCHECK
Kevin M 2016/04/19 23:39:23 Done.
23
24 if (cache_->Contains(id)) {
25 return;
26 }
27
28 VLOG(2) << "Put blob: " << base::HexEncode(id.data(), id.size());
29 cache_->Put(id, data);
30 }
31
32 void BlobChannelSender::Deliver(const BlobId& id) {
33 if (!cache_->Contains(id)) {
34 DLOG(FATAL) << "Attempted to push invalid blob ID: "
35 << base::HexEncode(id.data(), id.size());
36 return;
37 }
38 if (receiver_cache_contents_.find(id) != receiver_cache_contents_.end()) {
39 DVLOG(3) << "Suppressed redundant push: "
40 << base::HexEncode(id.data(), id.size());
41 return;
42 }
43
44 VLOG(2) << "Deliver blob: " << base::HexEncode(id.data(), id.size());
45 delegate_->Deliver(id, cache_->Get(id));
46 receiver_cache_contents_.insert(id);
47 }
48
49 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698