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

Side by Side Diff: media/blink/multibuffer.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.h ('k') | media/blink/multibuffer_data_source_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 <utility> 5 #include <utility>
6 6
7 #include "media/blink/multibuffer.h" 7 #include "media/blink/multibuffer.h"
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 lru_->Use(this, pos); 382 lru_->Use(this, pos);
383 ++pos; 383 ++pos;
384 } 384 }
385 int64_t blocks_after = data_.size(); 385 int64_t blocks_after = data_.size();
386 int64_t blocks_added = blocks_after - blocks_before; 386 int64_t blocks_added = blocks_after - blocks_before;
387 387
388 if (pos > start_pos) { 388 if (pos > start_pos) {
389 present_.SetInterval(start_pos, pos, 1); 389 present_.SetInterval(start_pos, pos, 1);
390 Interval<BlockId> expanded_range = present_.find(start_pos).interval(); 390 Interval<BlockId> expanded_range = present_.find(start_pos).interval();
391 NotifyAvailableRange(expanded_range, expanded_range); 391 NotifyAvailableRange(expanded_range, expanded_range);
392
393 lru_->IncrementDataSize(blocks_added); 392 lru_->IncrementDataSize(blocks_added);
394 Prune(blocks_added * kMaxFreesPerAdd + 1); 393 Prune(blocks_added * kMaxFreesPerAdd + 1);
394 } else {
395 // Make sure to give progress reports even when there
396 // aren't any new blocks yet.
397 NotifyAvailableRange(Interval<BlockId>(start_pos, start_pos + 1),
398 Interval<BlockId>(start_pos, start_pos));
395 } 399 }
396 400
397 // Check that it's still there before we try to delete it. 401 // Check that it's still there before we try to delete it.
398 // In case of EOF or a collision, we might not have called AddProvider above. 402 // In case of EOF or a collision, we might not have called AddProvider above.
399 // Even if we did call AddProvider, calling NotifyAvailableRange can cause 403 // Even if we did call AddProvider, calling NotifyAvailableRange can cause
400 // readers to seek or self-destruct and clean up any associated writers. 404 // readers to seek or self-destruct and clean up any associated writers.
401 auto i = writer_index_.find(pos); 405 auto i = writer_index_.find(pos);
402 if (i != writer_index_.end() && i->second.get() == provider_tmp) { 406 if (i != writer_index_.end() && i->second.get() == provider_tmp) {
403 switch (SuggestProviderState(pos)) { 407 switch (SuggestProviderState(pos)) {
404 case ProviderStateLoad: 408 case ProviderStateLoad:
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 } 515 }
512 } 516 }
513 517
514 void MultiBuffer::IncrementMaxSize(int32_t size) { 518 void MultiBuffer::IncrementMaxSize(int32_t size) {
515 max_size_ += size; 519 max_size_ += size;
516 lru_->IncrementMaxSize(size); 520 lru_->IncrementMaxSize(size);
517 DCHECK_GE(max_size_, 0); 521 DCHECK_GE(max_size_, 0);
518 // Pruning only happens when blocks are added. 522 // Pruning only happens when blocks are added.
519 } 523 }
520 524
525 int64_t MultiBuffer::UncommittedBytesAt(const MultiBuffer::BlockId& block) {
526 auto i = writer_index_.find(block);
527 if (writer_index_.end() == i)
528 return 0;
529 return i->second->AvailableBytes();
530 }
531
521 } // namespace media 532 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/multibuffer.h ('k') | media/blink/multibuffer_data_source_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698