| 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_impl.h" | 5 #include "blimp/net/blob_channel/blob_channel_sender_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 11 #include "blimp/common/blob_cache/blob_cache.h" | 11 #include "blimp/common/blob_cache/blob_cache.h" |
| 12 #include "blimp/common/blob_cache/id_util.h" | 12 #include "blimp/common/blob_cache/id_util.h" |
| 13 | 13 |
| 14 namespace blimp { | 14 namespace blimp { |
| 15 | 15 |
| 16 BlobChannelSenderImpl::BlobChannelSenderImpl(std::unique_ptr<BlobCache> cache, | 16 BlobChannelSenderImpl::BlobChannelSenderImpl(std::unique_ptr<BlobCache> cache, |
| 17 std::unique_ptr<Delegate> delegate) | 17 std::unique_ptr<Delegate> delegate) |
| 18 : cache_(std::move(cache)), delegate_(std::move(delegate)) { | 18 : cache_(std::move(cache)), |
| 19 delegate_(std::move(delegate)), |
| 20 weak_factory_(this) { |
| 19 DCHECK(cache_); | 21 DCHECK(cache_); |
| 20 DCHECK(delegate_); | 22 DCHECK(delegate_); |
| 21 } | 23 } |
| 22 | 24 |
| 23 BlobChannelSenderImpl::~BlobChannelSenderImpl() {} | 25 BlobChannelSenderImpl::~BlobChannelSenderImpl() {} |
| 24 | 26 |
| 27 base::WeakPtr<BlobChannelSenderImpl> BlobChannelSenderImpl::GetWeakPtr() { |
| 28 return weak_factory_.GetWeakPtr(); |
| 29 } |
| 30 |
| 25 std::vector<BlobChannelSender::CacheStateEntry> | 31 std::vector<BlobChannelSender::CacheStateEntry> |
| 26 BlobChannelSenderImpl::GetCachedBlobIds() const { | 32 BlobChannelSenderImpl::GetCachedBlobIds() const { |
| 27 const auto cache_state = cache_->GetCachedBlobIds(); | 33 const auto cache_state = cache_->GetCachedBlobIds(); |
| 28 std::vector<CacheStateEntry> output; | 34 std::vector<CacheStateEntry> output; |
| 29 output.reserve(cache_state.size()); | 35 output.reserve(cache_state.size()); |
| 30 for (const std::string& cached_id : cache_state) { | 36 for (const std::string& cached_id : cache_state) { |
| 31 CacheStateEntry next_output; | 37 CacheStateEntry next_output; |
| 32 next_output.id = cached_id; | 38 next_output.id = cached_id; |
| 33 next_output.was_delivered = | 39 next_output.was_delivered = |
| 34 base::ContainsKey(receiver_cache_contents_, cached_id); | 40 base::ContainsKey(receiver_cache_contents_, cached_id); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 59 DVLOG(3) << "Suppressed redundant push: " << BlobIdToString(id); | 65 DVLOG(3) << "Suppressed redundant push: " << BlobIdToString(id); |
| 60 return; | 66 return; |
| 61 } | 67 } |
| 62 receiver_cache_contents_.insert(id); | 68 receiver_cache_contents_.insert(id); |
| 63 | 69 |
| 64 VLOG(2) << "Deliver blob: " << BlobIdToString(id); | 70 VLOG(2) << "Deliver blob: " << BlobIdToString(id); |
| 65 delegate_->DeliverBlob(id, cache_->Get(id)); | 71 delegate_->DeliverBlob(id, cache_->Get(id)); |
| 66 } | 72 } |
| 67 | 73 |
| 68 } // namespace blimp | 74 } // namespace blimp |
| OLD | NEW |