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

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: comments addressed 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
« no previous file with comments | « media/blink/multibuffer_data_source_unittest.cc ('k') | media/blink/multibuffer_unittest.cc » ('j') | no next file with comments »
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 #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 // We may be destroyed, do not touch |this|. 189 << multibuffer_->block_size_shift()) +
190 multibuffer_->UncommittedBytesAt(range.end))));
190 } 191 }
191 } 192 }
192 193
193 void MultiBufferReader::UpdateInternalState() { 194 void MultiBufferReader::UpdateInternalState() {
194 int64_t effective_preload = loading_ ? preload_high_ : preload_low_; 195 int64_t effective_preload = loading_ ? preload_high_ : preload_low_;
195 196
196 loading_ = false; 197 loading_ = false;
197 if (preload_pos_ == -1) { 198 if (preload_pos_ == -1) {
198 preload_pos_ = block(pos_); 199 preload_pos_ = block(pos_);
199 DCHECK_GE(preload_pos_, 0); 200 DCHECK_GE(preload_pos_, 0);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 // Use a rangemap to compute the diff in pinning. 240 // Use a rangemap to compute the diff in pinning.
240 IntervalMap<MultiBuffer::BlockId, int32_t> tmp; 241 IntervalMap<MultiBuffer::BlockId, int32_t> tmp;
241 tmp.IncrementInterval(pinned_range_.begin, pinned_range_.end, -1); 242 tmp.IncrementInterval(pinned_range_.begin, pinned_range_.end, -1);
242 tmp.IncrementInterval(begin, end, 1); 243 tmp.IncrementInterval(begin, end, 1);
243 multibuffer_->PinRanges(tmp); 244 multibuffer_->PinRanges(tmp);
244 pinned_range_.begin = begin; 245 pinned_range_.begin = begin;
245 pinned_range_.end = end; 246 pinned_range_.end = end;
246 } 247 }
247 248
248 } // namespace media 249 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/multibuffer_data_source_unittest.cc ('k') | media/blink/multibuffer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698