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