Chromium Code Reviews| Index: media/blink/multibuffer.h |
| diff --git a/media/blink/multibuffer.h b/media/blink/multibuffer.h |
| index d469d43fc146f5c6c323bb371bfc4ecdbd4853e6..22b5e748b51bca060e82364e1fe0578ac4f386d3 100644 |
| --- a/media/blink/multibuffer.h |
| +++ b/media/blink/multibuffer.h |
| @@ -23,8 +23,14 @@ |
| namespace media { |
| +// Used to identify a block of data in the multibuffer. |
| +// Our blocks are 32kb (1 << 15), so our maximum cacheable file size |
|
xhwang
2015/11/23 23:09:21
s/\ \ /\ /
hubbe
2015/11/24 22:55:10
Done.
|
| +// is 1 << (15 + 31) = 64Tb |
| typedef int32_t MultiBufferBlockId; |
| class MultiBuffer; |
| + |
| +// This type is used to identify a block in the LRU, which is shared between |
| +// multibuffers. |
| typedef std::pair<MultiBuffer*, MultiBufferBlockId> MultiBufferGlobalBlockId; |
| } // namespace media |
| @@ -72,8 +78,6 @@ const int kMaxWaitForWriterOffset = 5; |
| // This is the size of the look-behind region. |
| const int kMaxWaitForReaderOffset = 50; |
| -class MultiBuffer; |
| - |
| // MultiBuffers are multi-reader multi-writer cache/buffers with |
| // prefetching and pinning. Data is stored internally in ref-counted |
| // blocks of identical size. |block_size_shift| is log2 of the block |
| @@ -119,9 +123,6 @@ class MEDIA_BLINK_EXPORT MultiBuffer { |
| // DataBuffer. |
| virtual scoped_refptr<DataBuffer> Read() = 0; |
| - // |cb| is called every time Available() becomes true. |
| - virtual void SetAvailableCallback(const base::Closure& cb) = 0; |
| - |
| // Ask the data provider to stop giving us data. |
| // It's ok if the effect is not immediate. |
| virtual void SetDeferred(bool deferred) = 0; |
| @@ -229,8 +230,8 @@ class MEDIA_BLINK_EXPORT MultiBuffer { |
| // not call it anymore. |
| scoped_ptr<DataProvider> RemoveProvider(DataProvider* provider); |
| - // Add a writer to this cache. Cache takes ownership and |
| - // may choose to destroy it. |
| + // Add a writer to this cache. Cache takes ownership, and may |
| + // destroy |provider| later. (Not during this call.) |
| void AddProvider(scoped_ptr<DataProvider> provider); |
| // Transfer all data from |other| to this. |
| @@ -240,13 +241,23 @@ class MEDIA_BLINK_EXPORT MultiBuffer { |
| const DataMap& map() const { return data_; } |
| int32_t block_size_shift() const { return block_size_shift_; } |
| + // Callback which notifies us that a data provider has |
| + // some data for us. Also called when it might be appropriate |
| + // for a provider in a deferred state to wake up. |
| + void OnDataProviderEvent(DataProvider* provider); |
|
xhwang
2015/11/23 23:09:21
On...Event seems okay since you have multiple even
hubbe
2015/11/24 22:55:10
Acknowledged.
|
| + |
| protected: |
| // Create a new writer at |pos| and return it. |
| // Users needs to implemement this method. |
| - virtual DataProvider* CreateWriter(const BlockId& pos) = 0; |
| + virtual scoped_ptr<DataProvider> CreateWriter(const BlockId& pos) = 0; |
| virtual bool RangeSupported() const = 0; |
| + // Called when the cache becomes empty. Implementations can use this |
| + // as a signal for when we should free this object and any metadata |
| + // that goes with it. |
| + virtual void OnEmpty(); |
| + |
| private: |
| // For testing. |
| friend class TestMultiBuffer; |
| @@ -276,11 +287,6 @@ class MEDIA_BLINK_EXPORT MultiBuffer { |
| void NotifyAvailableRange(const Interval<MultiBufferBlockId>& observer_range, |
| const Interval<MultiBufferBlockId>& new_range); |
| - // Callback which notifies us that a data provider has |
| - // some data for us. Also called when it might be apprperiate |
| - // for a provider in a deferred state to wake up. |
| - void DataProviderEvent(DataProvider* provider); |
| - |
| // Max number of blocks. |
| int64_t max_size_; |