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

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

Issue 2481673004: media: Make sure we transition back to a non-loading state (Closed)
Patch Set: merged Created 4 years, 1 month 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') | no next file » | 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/location.h" 9 #include "base/location.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 } 171 }
172 172
173 void MultiBufferReader::NotifyAvailableRange( 173 void MultiBufferReader::NotifyAvailableRange(
174 const Interval<MultiBufferBlockId>& range) { 174 const Interval<MultiBufferBlockId>& range) {
175 // Update end_ if we can. 175 // Update end_ if we can.
176 if (range.end > range.begin) { 176 if (range.end > range.begin) {
177 UpdateEnd(range.end); 177 UpdateEnd(range.end);
178 } 178 }
179 UpdateInternalState(); 179 UpdateInternalState();
180 if (!progress_callback_.is_null()) { 180 if (!progress_callback_.is_null()) {
181 // We redirect the call through a weak pointer to ourselves to guarantee
182 // there are no callbacks from us after we've been destroyed.
183 base::ThreadTaskRunnerHandle::Get()->PostTask( 181 base::ThreadTaskRunnerHandle::Get()->PostTask(
184 FROM_HERE, 182 FROM_HERE,
185 base::Bind( 183 base::Bind(progress_callback_, static_cast<int64_t>(range.begin)
186 &MultiBufferReader::Call, weak_factory_.GetWeakPtr(), 184 << multibuffer_->block_size_shift(),
187 base::Bind(progress_callback_, 185 (static_cast<int64_t>(range.end)
188 static_cast<int64_t>(range.begin) 186 << multibuffer_->block_size_shift()) +
189 << multibuffer_->block_size_shift(), 187 multibuffer_->UncommittedBytesAt(range.end)));
190 (static_cast<int64_t>(range.end)
191 << multibuffer_->block_size_shift()) +
192 multibuffer_->UncommittedBytesAt(range.end))));
193 } 188 }
194 } 189 }
195 190
196 void MultiBufferReader::UpdateInternalState() { 191 void MultiBufferReader::UpdateInternalState() {
197 int64_t effective_preload = loading_ ? preload_high_ : preload_low_; 192 int64_t effective_preload = loading_ ? preload_high_ : preload_low_;
198 193
199 loading_ = false; 194 loading_ = false;
200 if (preload_pos_ == -1) { 195 if (preload_pos_ == -1) {
201 preload_pos_ = block(pos_); 196 preload_pos_ = block(pos_);
202 DCHECK_GE(preload_pos_, 0); 197 DCHECK_GE(preload_pos_, 0);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 // Use a rangemap to compute the diff in pinning. 237 // Use a rangemap to compute the diff in pinning.
243 IntervalMap<MultiBuffer::BlockId, int32_t> tmp; 238 IntervalMap<MultiBuffer::BlockId, int32_t> tmp;
244 tmp.IncrementInterval(pinned_range_.begin, pinned_range_.end, -1); 239 tmp.IncrementInterval(pinned_range_.begin, pinned_range_.end, -1);
245 tmp.IncrementInterval(begin, end, 1); 240 tmp.IncrementInterval(begin, end, 1);
246 multibuffer_->PinRanges(tmp); 241 multibuffer_->PinRanges(tmp);
247 pinned_range_.begin = begin; 242 pinned_range_.begin = begin;
248 pinned_range_.end = end; 243 pinned_range_.end = end;
249 } 244 }
250 245
251 } // namespace media 246 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/multibuffer_data_source_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698