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..4fd189cdf2445feaf5706fd17a32683d58209233 100644 |
--- a/blimp/net/blob_channel/blob_channel_receiver.h |
+++ b/blimp/net/blob_channel/blob_channel_receiver.h |
@@ -16,7 +16,6 @@ namespace blimp { |
class BlobCache; |
-// Receives blobs from a remote sender. |
class BLIMP_NET_EXPORT BlobChannelReceiver { |
public: |
class Delegate { |
@@ -24,44 +23,51 @@ class BLIMP_NET_EXPORT BlobChannelReceiver { |
Delegate(); |
virtual ~Delegate(); |
+ // Sets the Receiver object which will take incoming blobs. |
+ void SetReceiver(BlobChannelReceiver* receiver); |
+ |
protected: |
// Forwards incoming blob data to |receiver_|. |
void OnBlobReceived(const BlobId& id, BlobDataPtr data); |
private: |
- friend class BlobChannelReceiver; |
- |
- // Sets the Receiver object which will take incoming blobs. |
- void SetReceiver(BlobChannelReceiver* receiver); |
- |
BlobChannelReceiver* receiver_ = nullptr; |
DISALLOW_COPY_AND_ASSIGN(Delegate); |
}; |
- BlobChannelReceiver(std::unique_ptr<BlobCache> cache, |
- std::unique_ptr<Delegate> delegate); |
- ~BlobChannelReceiver(); |
+ BlobChannelReceiver(); |
Wez
2016/05/20 21:46:17
This is a pure interface, so no need for ctor to b
Kevin M
2016/05/23 20:48:07
Done.
|
+ virtual ~BlobChannelReceiver(); |
Wez
2016/05/20 21:46:17
Pure interface, so no-op virtual dtor can be decla
Kevin M
2016/05/23 20:48:07
Done.
|
// 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); |
+ virtual void OnBlobReceived(const BlobId& id, BlobDataPtr data) = 0; |
+}; |
+ |
+// Receives blobs from a remote sender. |
Wez
2016/05/20 21:46:17
And does what with them? :)
Kevin M
2016/05/23 20:48:07
Done.
|
+class BLIMP_NET_EXPORT BlobChannelReceiverImpl : public BlobChannelReceiver { |
Wez
2016/05/20 21:46:17
Rather than declare this implementation in the hea
Kevin M
2016/05/23 20:48:07
Done.
|
+ public: |
+ BlobChannelReceiverImpl(std::unique_ptr<BlobCache> cache, |
+ std::unique_ptr<Delegate> delegate); |
+ ~BlobChannelReceiverImpl() override; |
+ // BlobChannelReceiver implementation. |
+ BlobDataPtr Get(const BlobId& id) override; |
+ void OnBlobReceived(const BlobId& id, BlobDataPtr data) override; |
+ |
+ private: |
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); |
+ DISALLOW_COPY_AND_ASSIGN(BlobChannelReceiverImpl); |
}; |
} // namespace blimp |