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

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: Sync-only! 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 #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::Put(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: " << FormatBlobId(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: "
37 << FormatBlobId(id);
38 return;
39 }
40
41 if (receiver_cache_contents_.find(id) != receiver_cache_contents_.end()) {
42 DVLOG(3) << "Suppressed redundant push: " << FormatBlobId(id);
43 return;
44 }
45
46 VLOG(2) << "Deliver blob: " << FormatBlobId(id);
47 delegate_->DeliverBlob(id, cache_->Get(id));
48 receiver_cache_contents_.insert(id);
Wez 2016/05/03 22:11:05 nit: Suggest moving this to come immediately after
Kevin M 2016/05/03 22:42:57 Done.
49 }
50
51 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698