| OLD | NEW |
| 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/net/blob_channel/blob_channel_sender.h" | 5 #include "blimp/net/blob_channel/blob_channel_sender_impl.h" |
| 6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "blimp/common/blob_cache/blob_cache.h" | 8 #include "blimp/common/blob_cache/blob_cache.h" |
| 9 #include "blimp/common/blob_cache/id_util.h" | 9 #include "blimp/common/blob_cache/id_util.h" |
| 10 | 10 |
| 11 namespace blimp { | 11 namespace blimp { |
| 12 | 12 |
| 13 BlobChannelSender::BlobChannelSender(std::unique_ptr<BlobCache> cache, | 13 BlobChannelSenderImpl::BlobChannelSenderImpl(std::unique_ptr<BlobCache> cache, |
| 14 std::unique_ptr<Delegate> delegate) | 14 std::unique_ptr<Delegate> delegate) |
| 15 : cache_(std::move(cache)), delegate_(std::move(delegate)) { | 15 : cache_(std::move(cache)), delegate_(std::move(delegate)) { |
| 16 DCHECK(cache_); | 16 DCHECK(cache_); |
| 17 DCHECK(delegate_); | 17 DCHECK(delegate_); |
| 18 } | 18 } |
| 19 | 19 |
| 20 BlobChannelSender::~BlobChannelSender() {} | 20 BlobChannelSenderImpl::~BlobChannelSenderImpl() {} |
| 21 | 21 |
| 22 void BlobChannelSender::PutBlob(const BlobId& id, BlobDataPtr data) { | 22 void BlobChannelSenderImpl::PutBlob(const BlobId& id, BlobDataPtr data) { |
| 23 DCHECK(data); | 23 DCHECK(data); |
| 24 DCHECK(!id.empty()); | 24 DCHECK(!id.empty()); |
| 25 | 25 |
| 26 if (cache_->Contains(id)) { | 26 if (cache_->Contains(id)) { |
| 27 return; | 27 return; |
| 28 } | 28 } |
| 29 | 29 |
| 30 VLOG(2) << "Put blob: " << BlobIdToString(id); | 30 VLOG(2) << "Put blob: " << BlobIdToString(id); |
| 31 cache_->Put(id, data); | 31 cache_->Put(id, data); |
| 32 } | 32 } |
| 33 | 33 |
| 34 void BlobChannelSender::DeliverBlob(const BlobId& id) { | 34 void BlobChannelSenderImpl::DeliverBlob(const BlobId& id) { |
| 35 if (!cache_->Contains(id)) { | 35 if (!cache_->Contains(id)) { |
| 36 DLOG(FATAL) << "Attempted to push unknown blob: " << BlobIdToString(id); | 36 DLOG(FATAL) << "Attempted to push unknown blob: " << BlobIdToString(id); |
| 37 return; | 37 return; |
| 38 } | 38 } |
| 39 | 39 |
| 40 if (receiver_cache_contents_.find(id) != receiver_cache_contents_.end()) { | 40 if (receiver_cache_contents_.find(id) != receiver_cache_contents_.end()) { |
| 41 DVLOG(3) << "Suppressed redundant push: " << BlobIdToString(id); | 41 DVLOG(3) << "Suppressed redundant push: " << BlobIdToString(id); |
| 42 return; | 42 return; |
| 43 } | 43 } |
| 44 receiver_cache_contents_.insert(id); | 44 receiver_cache_contents_.insert(id); |
| 45 | 45 |
| 46 VLOG(2) << "Deliver blob: " << BlobIdToString(id); | 46 VLOG(2) << "Deliver blob: " << BlobIdToString(id); |
| 47 delegate_->DeliverBlob(id, cache_->Get(id)); | 47 delegate_->DeliverBlob(id, cache_->Get(id)); |
| 48 } | 48 } |
| 49 | 49 |
| 50 } // namespace blimp | 50 } // namespace blimp |
| OLD | NEW |