| 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_receiver.h" | 5 #include "blimp/net/blob_channel/blob_channel_receiver.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "blimp/common/blob_cache/blob_cache.h" | 10 #include "blimp/common/blob_cache/blob_cache.h" |
| 11 #include "blimp/common/blob_cache/id_util.h" |
| 11 | 12 |
| 12 namespace blimp { | 13 namespace blimp { |
| 13 namespace { | 14 namespace { |
| 14 | 15 |
| 15 // Takes incoming blobs from |delegate_| stores them in |cache_|, and provides | 16 // Takes incoming blobs from |delegate_| stores them in |cache_|, and provides |
| 16 // callers a getter interface for accessing blobs from |cache_|. | 17 // callers a getter interface for accessing blobs from |cache_|. |
| 17 class BLIMP_NET_EXPORT BlobChannelReceiverImpl : public BlobChannelReceiver { | 18 class BLIMP_NET_EXPORT BlobChannelReceiverImpl : public BlobChannelReceiver { |
| 18 public: | 19 public: |
| 19 BlobChannelReceiverImpl(std::unique_ptr<BlobCache> cache, | 20 BlobChannelReceiverImpl(std::unique_ptr<BlobCache> cache, |
| 20 std::unique_ptr<Delegate> delegate); | 21 std::unique_ptr<Delegate> delegate); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 49 std::unique_ptr<Delegate> delegate) | 50 std::unique_ptr<Delegate> delegate) |
| 50 : cache_(std::move(cache)), delegate_(std::move(delegate)) { | 51 : cache_(std::move(cache)), delegate_(std::move(delegate)) { |
| 51 DCHECK(cache_); | 52 DCHECK(cache_); |
| 52 | 53 |
| 53 delegate_->SetReceiver(this); | 54 delegate_->SetReceiver(this); |
| 54 } | 55 } |
| 55 | 56 |
| 56 BlobChannelReceiverImpl::~BlobChannelReceiverImpl() {} | 57 BlobChannelReceiverImpl::~BlobChannelReceiverImpl() {} |
| 57 | 58 |
| 58 BlobDataPtr BlobChannelReceiverImpl::Get(const BlobId& id) { | 59 BlobDataPtr BlobChannelReceiverImpl::Get(const BlobId& id) { |
| 59 DVLOG(2) << "Get blob: " << id; | 60 DVLOG(2) << "Get blob: " << BlobIdToString(id); |
| 60 | 61 |
| 61 base::AutoLock lock(cache_lock_); | 62 base::AutoLock lock(cache_lock_); |
| 62 return cache_->Get(id); | 63 return cache_->Get(id); |
| 63 } | 64 } |
| 64 | 65 |
| 65 void BlobChannelReceiverImpl::OnBlobReceived(const BlobId& id, | 66 void BlobChannelReceiverImpl::OnBlobReceived(const BlobId& id, |
| 66 BlobDataPtr data) { | 67 BlobDataPtr data) { |
| 67 DVLOG(2) << "Blob received: " << id; | 68 DVLOG(2) << "Blob received: " << BlobIdToString(id) |
| 69 << ", size: " << data->data.size(); |
| 68 | 70 |
| 69 base::AutoLock lock(cache_lock_); | 71 base::AutoLock lock(cache_lock_); |
| 70 cache_->Put(id, data); | 72 cache_->Put(id, data); |
| 71 } | 73 } |
| 72 | 74 |
| 73 } // namespace blimp | 75 } // namespace blimp |
| OLD | NEW |