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

Unified Diff: media/blink/multibuffer.cc

Issue 1754893006: Fix multibuffer crashing bug (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DCHECK -> CHECK Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | media/blink/multibuffer_data_source_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/blink/multibuffer.cc
diff --git a/media/blink/multibuffer.cc b/media/blink/multibuffer.cc
index a8d981eba88b812ec3694af4fe8698082c49dcf9..cc15b23cd591521774c1dfc722669a79aa3ea1b8 100644
--- a/media/blink/multibuffer.cc
+++ b/media/blink/multibuffer.cc
@@ -115,6 +115,8 @@ MultiBuffer::MultiBuffer(int32_t block_size_shift,
: max_size_(0), block_size_shift_(block_size_shift), lru_(global_lru) {}
MultiBuffer::~MultiBuffer() {
+ CHECK(pinned_.empty());
+ DCHECK_EQ(max_size_, 0);
// Remove all blocks from the LRU.
for (const auto& i : data_) {
lru_->Remove(this, i.first);
@@ -379,6 +381,7 @@ void MultiBuffer::OnDataProviderEvent(DataProvider* provider_tmp) {
void MultiBuffer::MergeFrom(MultiBuffer* other) {
// Import data and update LRU.
+ size_t data_size = data_.size();
for (const auto& data : other->data_) {
if (data_.insert(std::make_pair(data.first, data.second)).second) {
if (!pinned_[data.first]) {
@@ -386,6 +389,7 @@ void MultiBuffer::MergeFrom(MultiBuffer* other) {
}
}
}
+ lru_->IncrementDataSize(static_cast<int64_t>(data_.size() - data_size));
// Update present_
for (const auto& r : other->present_) {
if (r.second) {
@@ -424,6 +428,7 @@ void MultiBuffer::PinRange(const BlockId& from,
auto range = pinned_.find(to - 1);
while (1) {
+ DCHECK_GE(range.value(), 0);
if (range.value() == 0 || range.value() == how_much) {
bool pin = range.value() == how_much;
Interval<BlockId> transition_range =
« no previous file with comments | « no previous file | media/blink/multibuffer_data_source_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698