Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3135)

Unified Diff: blimp/net/blob_channel/blob_channel_sender.h

Issue 1887013003: Blimp: Add BlobChannelSender implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blobchannel-blobcache
Patch Set: Wez feedback. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: blimp/net/blob_channel/blob_channel_sender.h
diff --git a/blimp/net/blob_channel/blob_channel_sender.h b/blimp/net/blob_channel/blob_channel_sender.h
new file mode 100644
index 0000000000000000000000000000000000000000..17d48274350cdec901e5db5034d3e19cde68e083
--- /dev/null
+++ b/blimp/net/blob_channel/blob_channel_sender.h
@@ -0,0 +1,62 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BLIMP_NET_BLOB_CHANNEL_BLOB_CHANNEL_SENDER_H_
+#define BLIMP_NET_BLOB_CHANNEL_BLOB_CHANNEL_SENDER_H_
+
+#include <set>
+#include <string>
+#include <vector>
+
+#include "base/macros.h"
+#include "base/threading/thread_checker.h"
+#include "blimp/net/blimp_net_export.h"
+#include "blimp/net/blob_channel/types.h"
+
+namespace blimp {
+
+class BlobCache;
+
+// Sends blobs to a remote receiver.
+// The transport-specific details are provided by the caller using the Delegate
+// subclass.
+class BLIMP_NET_EXPORT BlobChannelSender {
+ public:
+ // Delegate interface for transport-specific implementations of blob transfer
+ // commands.
+ class Delegate {
+ public:
+ // Send blob |id| with payload |data| to the receiver.
+ 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.
+ };
+
+ // Caller is responsible for ensuring that |cache| and |delegate| outlive
+ // |this|.
+ 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|
+ ~BlobChannelSender();
+
+ // Puts a blob in the local BlobChannel. The blob can then be pushed to the
+ // remote receiver via "Deliver()".
+ // 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
+ void Put(const BlobId& id, BlobData data);
+
+ // Sends the blob |id| to the remote side, if the remote side doesn't already
+ // 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.
+ void Deliver(const BlobId& id);
+
+ private:
+ BlobCache* cache_;
+ Delegate* delegate_;
+
+ // A set of the cache item IDs in the receiver's cache.
+ // Allows the sender to determine if a cache item should be sent to the
+ // receiver.
+ 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.
+
+ DISALLOW_COPY_AND_ASSIGN(BlobChannelSender);
+};
+
+} // namespace blimp
+
+#endif // BLIMP_NET_BLOB_CHANNEL_BLOB_CHANNEL_SENDER_H_

Powered by Google App Engine
This is Rietveld 408576698