OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |