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

Side by Side Diff: media/blink/multibuffer.h

Issue 1829163002: Lazily prune the multibuffer block cache. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | media/blink/multibuffer.cc » ('j') | media/blink/multibuffer.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 MEDIA_BLINK_MULTIBUFFER_H_ 5 #ifndef MEDIA_BLINK_MULTIBUFFER_H_
6 #define MEDIA_BLINK_MULTIBUFFER_H_ 6 #define MEDIA_BLINK_MULTIBUFFER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 class MEDIA_BLINK_EXPORT GlobalLRU : public base::RefCounted<GlobalLRU> { 130 class MEDIA_BLINK_EXPORT GlobalLRU : public base::RefCounted<GlobalLRU> {
131 public: 131 public:
132 typedef MultiBufferGlobalBlockId GlobalBlockId; 132 typedef MultiBufferGlobalBlockId GlobalBlockId;
133 GlobalLRU(); 133 GlobalLRU();
134 134
135 // Free elements from cache if needed and possible. 135 // Free elements from cache if needed and possible.
136 // Don't free more than |max_to_free| blocks. 136 // Don't free more than |max_to_free| blocks.
137 // Virtual for testing purposes. 137 // Virtual for testing purposes.
138 void Prune(int64_t max_to_free); 138 void Prune(int64_t max_to_free);
139 139
140 // Returns true if some blocks are prunable.
141 bool Pruneable() const;
142
140 void IncrementDataSize(int64_t blocks); 143 void IncrementDataSize(int64_t blocks);
141 void IncrementMaxSize(int64_t blocks); 144 void IncrementMaxSize(int64_t blocks);
142 145
143 // LRU operations. 146 // LRU operations.
144 void Use(MultiBuffer* multibuffer, MultiBufferBlockId id); 147 void Use(MultiBuffer* multibuffer, MultiBufferBlockId id);
145 void Remove(MultiBuffer* multibuffer, MultiBufferBlockId id); 148 void Remove(MultiBuffer* multibuffer, MultiBufferBlockId id);
146 void Insert(MultiBuffer* multibuffer, MultiBufferBlockId id); 149 void Insert(MultiBuffer* multibuffer, MultiBufferBlockId id);
147 bool Contains(MultiBuffer* multibuffer, MultiBufferBlockId id); 150 bool Contains(MultiBuffer* multibuffer, MultiBufferBlockId id);
148 int64_t Size() const; 151 int64_t Size() const;
149 152
150 private: 153 private:
151 friend class base::RefCounted<GlobalLRU>; 154 friend class base::RefCounted<GlobalLRU>;
152 ~GlobalLRU(); 155 ~GlobalLRU();
153 156
157 // Schedule background pruning, if needed.
158 void SchedulePrune();
159
160 // Perform background pruning.
161 void PruneTask();
162
154 // Max number of blocks. 163 // Max number of blocks.
155 int64_t max_size_; 164 int64_t max_size_;
156 165
157 // Sum of all multibuffer::data_.size(). 166 // Sum of all multibuffer::data_.size().
158 int64_t data_size_; 167 int64_t data_size_;
159 168
169 // True if there is a call to the background pruning outstanding.
170 bool background_pruning_active_;
171
160 // The LRU should contain all blocks which are not pinned from 172 // The LRU should contain all blocks which are not pinned from
161 // all multibuffers. 173 // all multibuffers.
162 LRU<GlobalBlockId> lru_; 174 LRU<GlobalBlockId> lru_;
163 }; 175 };
164 176
165 MultiBuffer(int32_t block_size_shift, 177 MultiBuffer(int32_t block_size_shift,
166 const scoped_refptr<GlobalLRU>& global_lru); 178 const scoped_refptr<GlobalLRU>& global_lru);
167 virtual ~MultiBuffer(); 179 virtual ~MultiBuffer();
168 180
169 // Identifies a block in the cache. 181 // Identifies a block in the cache.
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 // and 0 for all blocks that are not. Used to quickly figure out 323 // and 0 for all blocks that are not. Used to quickly figure out
312 // ranges of available/unavailable blocks without iterating. 324 // ranges of available/unavailable blocks without iterating.
313 IntervalMap<BlockId, int32_t> present_; 325 IntervalMap<BlockId, int32_t> present_;
314 326
315 DISALLOW_COPY_AND_ASSIGN(MultiBuffer); 327 DISALLOW_COPY_AND_ASSIGN(MultiBuffer);
316 }; 328 };
317 329
318 } // namespace media 330 } // namespace media
319 331
320 #endif // MEDIA_BLINK_MULTIBUFFER_H_ 332 #endif // MEDIA_BLINK_MULTIBUFFER_H_
OLDNEW
« no previous file with comments | « no previous file | media/blink/multibuffer.cc » ('j') | media/blink/multibuffer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698