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

Side by Side Diff: media/blink/multibuffer_reader.cc

Issue 1971373002: Fix progress reporting for multibuffers to report progress for every byte we receive. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
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 #include <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "media/blink/multibuffer_reader.h" 10 #include "media/blink/multibuffer_reader.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 // Update end_ if we can. 173 // Update end_ if we can.
174 if (range.end > range.begin) { 174 if (range.end > range.begin) {
175 UpdateEnd(range.end); 175 UpdateEnd(range.end);
176 } 176 }
177 UpdateInternalState(); 177 UpdateInternalState();
178 if (!progress_callback_.is_null()) { 178 if (!progress_callback_.is_null()) {
179 // We redirect the call through a weak pointer to ourselves to guarantee 179 // We redirect the call through a weak pointer to ourselves to guarantee
180 // there are no callbacks from us after we've been destroyed. 180 // there are no callbacks from us after we've been destroyed.
181 base::MessageLoop::current()->PostTask( 181 base::MessageLoop::current()->PostTask(
182 FROM_HERE, 182 FROM_HERE,
183 base::Bind(&MultiBufferReader::Call, weak_factory_.GetWeakPtr(), 183 base::Bind(
184 base::Bind(progress_callback_, 184 &MultiBufferReader::Call, weak_factory_.GetWeakPtr(),
185 static_cast<int64_t>(range.begin) 185 base::Bind(progress_callback_,
186 << multibuffer_->block_size_shift(), 186 static_cast<int64_t>(range.begin)
187 static_cast<int64_t>(range.end) 187 << multibuffer_->block_size_shift(),
188 << multibuffer_->block_size_shift()))); 188 (static_cast<int64_t>(range.end)
189 << multibuffer_->block_size_shift()) +
190 multibuffer_->UncommittedBytesAt(range.end))));
189 // We may be destroyed, do not touch |this|. 191 // We may be destroyed, do not touch |this|.
190 } 192 }
191 } 193 }
192 194
193 void MultiBufferReader::UpdateInternalState() { 195 void MultiBufferReader::UpdateInternalState() {
194 int64_t effective_preload = loading_ ? preload_high_ : preload_low_; 196 int64_t effective_preload = loading_ ? preload_high_ : preload_low_;
195 197
196 loading_ = false; 198 loading_ = false;
197 if (preload_pos_ == -1) { 199 if (preload_pos_ == -1) {
198 preload_pos_ = block(pos_); 200 preload_pos_ = block(pos_);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 // Use a rangemap to compute the diff in pinning. 241 // Use a rangemap to compute the diff in pinning.
240 IntervalMap<MultiBuffer::BlockId, int32_t> tmp; 242 IntervalMap<MultiBuffer::BlockId, int32_t> tmp;
241 tmp.IncrementInterval(pinned_range_.begin, pinned_range_.end, -1); 243 tmp.IncrementInterval(pinned_range_.begin, pinned_range_.end, -1);
242 tmp.IncrementInterval(begin, end, 1); 244 tmp.IncrementInterval(begin, end, 1);
243 multibuffer_->PinRanges(tmp); 245 multibuffer_->PinRanges(tmp);
244 pinned_range_.begin = begin; 246 pinned_range_.begin = begin;
245 pinned_range_.end = end; 247 pinned_range_.end = end;
246 } 248 }
247 249
248 } // namespace media 250 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698