Chromium Code Reviews| 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 <set> | |
| 9 #include <string> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/macros.h" | |
| 13 #include "base/threading/thread_checker.h" | |
| 14 #include "blimp/net/blimp_net_export.h" | |
| 15 #include "blimp/net/blob_channel/types.h" | |
| 16 | |
| 17 namespace blimp { | |
| 18 | |
| 19 class BlobCache; | |
| 20 | |
| 21 // Sends blobs to a remote receiver. | |
| 22 // The transport-specific details are provided by the caller using the Delegate | |
| 23 // subclass. | |
| 24 class BLIMP_NET_EXPORT BlobChannelSender { | |
| 25 public: | |
| 26 // Delegate interface for transport-specific implementations of blob transfer | |
| 27 // commands. | |
| 28 class Delegate { | |
| 29 public: | |
| 30 // Send blob |id| with payload |data| to the receiver. | |
| 31 virtual void Deliver(const BlobId& id, BlobData data) = 0; | |
|
Wez
2016/04/19 00:01:57
nit: Suggest DeliverBob, in case the implementer d
Kevin M
2016/04/19 23:39:23
Done.
| |
| 32 }; | |
| 33 | |
| 34 // Caller is responsible for ensuring that |cache| and |delegate| outlive | |
| 35 // |this|. | |
| 36 BlobChannelSender(BlobCache* cache, Delegate* delegate); | |
|
Wez
2016/04/19 00:01:57
Can/should the Sender own the cache object?
Kevin M
2016/04/19 23:39:23
Hmmm. I don't have a reason why not. Made |cache|
| |
| 37 ~BlobChannelSender(); | |
| 38 | |
| 39 // Puts a blob in the local BlobChannel. The blob can then be pushed to the | |
| 40 // remote receiver via "Deliver()". | |
| 41 // Does nothing if there is already a blob |id| in the channel. | |
|
Wez
2016/04/19 00:01:57
As previously discussed, what if |data| is differe
Kevin M
2016/04/19 23:39:23
|id| is content-keyed, so it's safe to assume that
Wez
2016/05/03 22:11:05
Could we just pass |data| and calculate the Id int
| |
| 42 void Put(const BlobId& id, BlobData data); | |
| 43 | |
| 44 // Sends the blob |id| to the remote side, if the remote side doesn't already | |
| 45 // have the blob. | |
|
Wez
2016/04/19 00:01:57
Sorry, still not clear from this interface why Put
Kevin M
2016/04/19 23:39:23
As discussed offline - breaking this into differen
Wez
2016/05/03 22:11:04
Acknowledged.
| |
| 46 void Deliver(const BlobId& id); | |
| 47 | |
| 48 private: | |
| 49 BlobCache* cache_; | |
| 50 Delegate* delegate_; | |
| 51 | |
| 52 // A set of the cache item IDs in the receiver's cache. | |
| 53 // Allows the sender to determine if a cache item should be sent to the | |
| 54 // receiver. | |
| 55 std::set<BlobId> receiver_cache_contents_; | |
|
Wez
2016/04/19 00:01:57
This won't work well if the Client-side has a purg
Kevin M
2016/04/19 23:39:23
We don't have the ability to control data retentio
Wez
2016/05/03 22:11:05
Acknowledged.
| |
| 56 | |
| 57 DISALLOW_COPY_AND_ASSIGN(BlobChannelSender); | |
| 58 }; | |
| 59 | |
| 60 } // namespace blimp | |
| 61 | |
| 62 #endif // BLIMP_NET_BLOB_CHANNEL_BLOB_CHANNEL_SENDER_H_ | |
| OLD | NEW |