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

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

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