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

Unified Diff: media/blink/multibuffer.h

Issue 1399603003: Tie multibuffers to URLs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@media_cache
Patch Set: comments addressed Created 5 years, 1 month 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: media/blink/multibuffer.h
diff --git a/media/blink/multibuffer.h b/media/blink/multibuffer.h
index d469d43fc146f5c6c323bb371bfc4ecdbd4853e6..e9a8da8051c09810887bf045ac3fad110070f766 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
+// 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 apprperiate
liberato (no reviews please) 2015/11/23 19:07:10 /appreperiat/appropriate/
hubbe 2015/11/23 20:17:30 Done.
+ // for a provider in a deferred state to wake up.
+ void OnDataProviderEvent(DataProvider* provider);
+
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 destroy this object and any metadata
+ // that goes with it.
liberato (no reviews please) 2015/11/23 19:07:10 'destroy this object': as in 'delete this'?
hubbe 2015/11/23 20:17:30 s/destroy/free/
+ 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_;

Powered by Google App Engine
This is Rietveld 408576698