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

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

Issue 1970463004: Blimp: Add BlobChannel Helium messages and delegate impls. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 7 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_receiver.h
diff --git a/blimp/net/blob_channel/blob_channel_receiver.h b/blimp/net/blob_channel/blob_channel_receiver.h
index bdfcd236bd62e5a58da2c0d41f1fe0cc1592b75e..d9ae4a03db921ea921012de513570db91b9e7c5a 100644
--- a/blimp/net/blob_channel/blob_channel_receiver.h
+++ b/blimp/net/blob_channel/blob_channel_receiver.h
@@ -16,52 +16,31 @@ namespace blimp {
class BlobCache;
-// Receives blobs from a remote sender.
class BLIMP_NET_EXPORT BlobChannelReceiver {
public:
class Delegate {
public:
- Delegate();
- virtual ~Delegate();
-
- protected:
- // Forwards incoming blob data to |receiver_|.
- void OnBlobReceived(const BlobId& id, BlobDataPtr data);
-
- private:
- friend class BlobChannelReceiver;
+ virtual ~Delegate() {}
// Sets the Receiver object which will take incoming blobs.
- void SetReceiver(BlobChannelReceiver* receiver);
-
- BlobChannelReceiver* receiver_ = nullptr;
-
- DISALLOW_COPY_AND_ASSIGN(Delegate);
+ virtual void SetReceiver(BlobChannelReceiver* receiver) = 0;
};
- BlobChannelReceiver(std::unique_ptr<BlobCache> cache,
- std::unique_ptr<Delegate> delegate);
- ~BlobChannelReceiver();
+ virtual ~BlobChannelReceiver() {}
+
+ // Constructs a BlobChannelReceiverImpl object for use.
+ static std::unique_ptr<BlobChannelReceiver> Create(
+ std::unique_ptr<BlobCache> cache,
+ std::unique_ptr<Delegate> delegate);
// Gets a blob from the BlobChannel.
// Returns nullptr if the blob is not available in the channel.
// Can be accessed concurrently from any thread. Calling code must ensure that
// the object instance outlives all calls to Get().
- BlobDataPtr Get(const BlobId& id);
-
- private:
- friend class Delegate;
+ virtual BlobDataPtr Get(const BlobId& id) = 0;
// Called by Delegate::OnBlobReceived() when a blob arrives over the channel.
- void OnBlobReceived(const BlobId& id, BlobDataPtr data);
-
- std::unique_ptr<BlobCache> cache_;
- std::unique_ptr<Delegate> delegate_;
-
- // Guards against concurrent access to |cache_|.
- base::Lock cache_lock_;
-
- DISALLOW_COPY_AND_ASSIGN(BlobChannelReceiver);
+ virtual void OnBlobReceived(const BlobId& id, BlobDataPtr data) = 0;
};
} // namespace blimp
« no previous file with comments | « blimp/net/blob_channel/blob_channel_integration_test.cc ('k') | blimp/net/blob_channel/blob_channel_receiver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698