Chromium Code Reviews| 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_IMPL_H_ | 5 #ifndef BLIMP_NET_BLOB_CHANNEL_BLOB_CHANNEL_SENDER_IMPL_H_ |
| 6 #define BLIMP_NET_BLOB_CHANNEL_BLOB_CHANNEL_SENDER_IMPL_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 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/weak_ptr.h" | |
| 14 #include "base/threading/thread_checker.h" | 15 #include "base/threading/thread_checker.h" |
| 15 #include "blimp/common/blob_cache/blob_cache.h" | 16 #include "blimp/common/blob_cache/blob_cache.h" |
| 16 #include "blimp/net/blimp_net_export.h" | 17 #include "blimp/net/blimp_net_export.h" |
| 17 #include "blimp/net/blob_channel/blob_channel_sender.h" | 18 #include "blimp/net/blob_channel/blob_channel_sender.h" |
| 18 | 19 |
| 19 namespace blimp { | 20 namespace blimp { |
| 20 | 21 |
| 21 // Sends blobs to a remote receiver. | 22 // Sends blobs to a remote receiver. |
| 22 // The transport-specific details are provided by the caller using the Delegate | 23 // The transport-specific details are provided by the caller using the Delegate |
| 23 // subclass. | 24 // subclass. |
| 24 class BLIMP_NET_EXPORT BlobChannelSenderImpl : public BlobChannelSender { | 25 class BLIMP_NET_EXPORT BlobChannelSenderImpl : public BlobChannelSender { |
| 25 public: | 26 public: |
| 26 // Delegate interface for transport-specific implementations of blob transfer | 27 // Delegate interface for transport-specific implementations of blob transfer |
| 27 // commands. | 28 // commands. |
| 28 class Delegate { | 29 class Delegate { |
| 29 public: | 30 public: |
| 30 virtual ~Delegate() {} | 31 virtual ~Delegate() {} |
| 31 | 32 |
| 32 // Send blob |id| with payload |data| to the receiver. | 33 // Send blob |id| with payload |data| to the receiver. |
| 33 virtual void DeliverBlob(const BlobId& id, BlobDataPtr data) = 0; | 34 virtual void DeliverBlob(const BlobId& id, BlobDataPtr data) = 0; |
| 34 }; | 35 }; |
| 35 | 36 |
| 36 BlobChannelSenderImpl(std::unique_ptr<BlobCache> cache, | 37 BlobChannelSenderImpl(std::unique_ptr<BlobCache> cache, |
| 37 std::unique_ptr<Delegate> delegate); | 38 std::unique_ptr<Delegate> delegate); |
| 38 ~BlobChannelSenderImpl() override; | 39 ~BlobChannelSenderImpl() override; |
| 39 | 40 |
| 41 base::WeakPtr<BlobChannelSenderImpl> GetWeakPtr(); | |
|
Wez
2016/08/19 19:15:50
Rather than pollute BlobChannelSenderImpl with Wea
Kevin M
2016/08/19 21:43:33
Done.
| |
| 42 | |
| 40 // BlobChannelSender implementation. | 43 // BlobChannelSender implementation. |
| 41 std::vector<BlobChannelSender::CacheStateEntry> GetCachedBlobIds() | 44 std::vector<BlobChannelSender::CacheStateEntry> GetCachedBlobIds() |
| 42 const override; | 45 const override; |
| 43 void PutBlob(const BlobId& id, BlobDataPtr data) override; | 46 void PutBlob(const BlobId& id, BlobDataPtr data) override; |
| 44 void DeliverBlob(const BlobId& id) override; | 47 void DeliverBlob(const BlobId& id) override; |
| 45 | 48 |
| 46 private: | 49 private: |
| 47 std::unique_ptr<BlobCache> cache_; | 50 std::unique_ptr<BlobCache> cache_; |
| 48 std::unique_ptr<Delegate> delegate_; | 51 std::unique_ptr<Delegate> delegate_; |
| 49 | 52 |
| 50 // Used to track the item IDs in the receiver's cache. This may differ from | 53 // Used to track the item IDs in the receiver's cache. This may differ from |
| 51 // the set of IDs in |cache_|, for instance if an ID hasn't yet been | 54 // the set of IDs in |cache_|, for instance if an ID hasn't yet been |
| 52 // delivered, or has been evicted at the receiver. | 55 // delivered, or has been evicted at the receiver. |
| 53 std::set<BlobId> receiver_cache_contents_; | 56 std::set<BlobId> receiver_cache_contents_; |
| 54 | 57 |
| 58 base::ThreadChecker thread_checker_; | |
|
Wez
2016/08/19 19:15:50
Doesn't look like you're actually using the thread
Kevin M
2016/08/19 21:43:34
Done.
| |
| 59 | |
| 60 base::WeakPtrFactory<BlobChannelSenderImpl> weak_factory_; | |
| 61 | |
| 55 DISALLOW_COPY_AND_ASSIGN(BlobChannelSenderImpl); | 62 DISALLOW_COPY_AND_ASSIGN(BlobChannelSenderImpl); |
| 56 }; | 63 }; |
| 57 | 64 |
| 58 } // namespace blimp | 65 } // namespace blimp |
| 59 | 66 |
| 60 #endif // BLIMP_NET_BLOB_CHANNEL_BLOB_CHANNEL_SENDER_IMPL_H_ | 67 #endif // BLIMP_NET_BLOB_CHANNEL_BLOB_CHANNEL_SENDER_IMPL_H_ |
| OLD | NEW |