Chromium Code Reviews| Index: blimp/net/blob_channel/blob_channel_receiver.cc |
| diff --git a/blimp/net/blob_channel/blob_channel_receiver.cc b/blimp/net/blob_channel/blob_channel_receiver.cc |
| index 7200dd3219e3b17cb3fb460793c1ff1e4d11181c..c5d33bb71982478fd4ce44b34d8988c69366b12f 100644 |
| --- a/blimp/net/blob_channel/blob_channel_receiver.cc |
| +++ b/blimp/net/blob_channel/blob_channel_receiver.cc |
| @@ -13,39 +13,48 @@ namespace blimp { |
| BlobChannelReceiver::Delegate::Delegate() {} |
| BlobChannelReceiver::Delegate::~Delegate() { |
| - DCHECK(!receiver_); |
| + DCHECK(receiver_); |
| } |
| void BlobChannelReceiver::Delegate::SetReceiver(BlobChannelReceiver* receiver) { |
| + DCHECK(receiver); |
| + DCHECK(!receiver_); |
| + |
| receiver_ = receiver; |
| } |
| void BlobChannelReceiver::Delegate::OnBlobReceived(const BlobId& id, |
| BlobDataPtr data) { |
|
haibinlu
2016/05/12 18:20:09
DCHECK not needed?
Kevin M
2016/05/13 18:40:24
Done.
|
| - if (receiver_) { |
| - receiver_->OnBlobReceived(id, data); |
| - } |
| + DCHECK(receiver_); |
| + |
| + receiver_->OnBlobReceived(id, data); |
| } |
| -BlobChannelReceiver::BlobChannelReceiver(std::unique_ptr<BlobCache> cache, |
| - std::unique_ptr<Delegate> delegate) |
| +BlobChannelReceiver::BlobChannelReceiver() {} |
| + |
| +BlobChannelReceiver::~BlobChannelReceiver() {} |
| + |
| +BlobChannelReceiverImpl::BlobChannelReceiverImpl( |
| + std::unique_ptr<BlobCache> cache, |
| + std::unique_ptr<Delegate> delegate) |
| : cache_(std::move(cache)), delegate_(std::move(delegate)) { |
| DCHECK(cache_); |
| + DCHECK(delegate_); |
|
haibinlu
2016/05/12 18:20:09
ditto
Kevin M
2016/05/13 18:40:24
Done.
|
| + |
| delegate_->SetReceiver(this); |
| } |
| -BlobChannelReceiver::~BlobChannelReceiver() { |
| - delegate_->SetReceiver(nullptr); |
| -} |
| +BlobChannelReceiverImpl::~BlobChannelReceiverImpl() {} |
| -BlobDataPtr BlobChannelReceiver::Get(const BlobId& id) { |
| +BlobDataPtr BlobChannelReceiverImpl::Get(const BlobId& id) { |
| DVLOG(2) << "Get blob: " << id; |
| base::AutoLock lock(cache_lock_); |
| return cache_->Get(id); |
| } |
| -void BlobChannelReceiver::OnBlobReceived(const BlobId& id, BlobDataPtr data) { |
| +void BlobChannelReceiverImpl::OnBlobReceived(const BlobId& id, |
| + BlobDataPtr data) { |
| DVLOG(2) << "Blob received: " << id; |
| base::AutoLock lock(cache_lock_); |