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