| 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 #ifndef BLIMP_NET_BLOB_CHANNEL_BLOB_CHANNEL_SENDER_IMPL_H_ | 5 #ifndef BLIMP_NET_BLOB_CHANNEL_BLOB_CHANNEL_SENDER_IMPL_H_ |
| 6 #define BLIMP_NET_BLOB_CHANNEL_BLOB_CHANNEL_SENDER_IMPL_H_ | 6 #define BLIMP_NET_BLOB_CHANNEL_BLOB_CHANNEL_SENDER_IMPL_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> |
| 11 | 12 |
| 12 #include "base/macros.h" | 13 #include "base/macros.h" |
| 13 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
| 14 #include "blimp/common/blob_cache/blob_cache.h" | 15 #include "blimp/common/blob_cache/blob_cache.h" |
| 15 #include "blimp/net/blimp_net_export.h" | 16 #include "blimp/net/blimp_net_export.h" |
| 16 #include "blimp/net/blob_channel/blob_channel_sender.h" | 17 #include "blimp/net/blob_channel/blob_channel_sender.h" |
| 17 | 18 |
| 18 namespace blimp { | 19 namespace blimp { |
| 19 | 20 |
| 20 // Sends blobs to a remote receiver. | 21 // Sends blobs to a remote receiver. |
| 21 // The transport-specific details are provided by the caller using the Delegate | 22 // The transport-specific details are provided by the caller using the Delegate |
| 22 // subclass. | 23 // subclass. |
| 23 class BLIMP_NET_EXPORT BlobChannelSenderImpl : public BlobChannelSender { | 24 class BLIMP_NET_EXPORT BlobChannelSenderImpl : public BlobChannelSender { |
| 24 public: | 25 public: |
| 25 // Delegate interface for transport-specific implementations of blob transfer | 26 // Delegate interface for transport-specific implementations of blob transfer |
| 26 // commands. | 27 // commands. |
| 27 class Delegate { | 28 class Delegate { |
| 28 public: | 29 public: |
| 29 virtual ~Delegate() {} | 30 virtual ~Delegate() {} |
| 30 | 31 |
| 31 // Send blob |id| with payload |data| to the receiver. | 32 // Send blob |id| with payload |data| to the receiver. |
| 32 virtual void DeliverBlob(const BlobId& id, BlobDataPtr data) = 0; | 33 virtual void DeliverBlob(const BlobId& id, BlobDataPtr data) = 0; |
| 33 }; | 34 }; |
| 34 | 35 |
| 35 BlobChannelSenderImpl(std::unique_ptr<BlobCache> cache, | 36 BlobChannelSenderImpl(std::unique_ptr<BlobCache> cache, |
| 36 std::unique_ptr<Delegate> delegate); | 37 std::unique_ptr<Delegate> delegate); |
| 37 ~BlobChannelSenderImpl() override; | 38 ~BlobChannelSenderImpl() override; |
| 38 | 39 |
| 39 // BlobChannelSender implementation. | 40 // BlobChannelSender implementation. |
| 41 std::vector<BlobChannelSender::CacheStateEntry> GetCachedBlobIds() |
| 42 const override; |
| 40 void PutBlob(const BlobId& id, BlobDataPtr data) override; | 43 void PutBlob(const BlobId& id, BlobDataPtr data) override; |
| 41 void DeliverBlob(const BlobId& id) override; | 44 void DeliverBlob(const BlobId& id) override; |
| 42 | 45 |
| 43 private: | 46 private: |
| 44 std::unique_ptr<BlobCache> cache_; | 47 std::unique_ptr<BlobCache> cache_; |
| 45 std::unique_ptr<Delegate> delegate_; | 48 std::unique_ptr<Delegate> delegate_; |
| 46 | 49 |
| 47 // Used to track the item IDs in the receiver's cache. This may differ from | 50 // Used to track the item IDs in the receiver's cache. This may differ from |
| 48 // the set of IDs in |cache_|, for instance if an ID hasn't yet been | 51 // the set of IDs in |cache_|, for instance if an ID hasn't yet been |
| 49 // delivered, or has been evicted at the receiver. | 52 // delivered, or has been evicted at the receiver. |
| 50 std::set<BlobId> receiver_cache_contents_; | 53 std::set<BlobId> receiver_cache_contents_; |
| 51 | 54 |
| 52 DISALLOW_COPY_AND_ASSIGN(BlobChannelSenderImpl); | 55 DISALLOW_COPY_AND_ASSIGN(BlobChannelSenderImpl); |
| 53 }; | 56 }; |
| 54 | 57 |
| 55 } // namespace blimp | 58 } // namespace blimp |
| 56 | 59 |
| 57 #endif // BLIMP_NET_BLOB_CHANNEL_BLOB_CHANNEL_SENDER_IMPL_H_ | 60 #endif // BLIMP_NET_BLOB_CHANNEL_BLOB_CHANNEL_SENDER_IMPL_H_ |
| OLD | NEW |