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

Side by Side Diff: media/blink/resource_multibuffer_data_provider.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/resource_multibuffer_data_provider.h ('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 "media/blink/resource_multibuffer_data_provider.h" 5 #include "media/blink/resource_multibuffer_data_provider.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 bool ResourceMultiBufferDataProvider::Available() const { 123 bool ResourceMultiBufferDataProvider::Available() const {
124 if (fifo_.empty()) 124 if (fifo_.empty())
125 return false; 125 return false;
126 if (fifo_.back()->end_of_stream()) 126 if (fifo_.back()->end_of_stream())
127 return true; 127 return true;
128 if (fifo_.front()->data_size() == block_size()) 128 if (fifo_.front()->data_size() == block_size())
129 return true; 129 return true;
130 return false; 130 return false;
131 } 131 }
132 132
133 int64_t ResourceMultiBufferDataProvider::AvailableBytes() const {
134 int64_t bytes = 0;
135 for (const auto i : fifo_) {
136 if (i->end_of_stream())
137 break;
138 bytes += i->data_size();
139 }
140 return bytes;
141 }
142
133 scoped_refptr<DataBuffer> ResourceMultiBufferDataProvider::Read() { 143 scoped_refptr<DataBuffer> ResourceMultiBufferDataProvider::Read() {
134 DCHECK(Available()); 144 DCHECK(Available());
135 scoped_refptr<DataBuffer> ret = fifo_.front(); 145 scoped_refptr<DataBuffer> ret = fifo_.front();
136 fifo_.pop_front(); 146 fifo_.pop_front();
137 ++pos_; 147 ++pos_;
138 return ret; 148 return ret;
139 } 149 }
140 150
141 void ResourceMultiBufferDataProvider::SetDeferred(bool deferred) { 151 void ResourceMultiBufferDataProvider::SetDeferred(bool deferred) {
142 if (!active_loader_ || active_loader_->deferred() == deferred) 152 if (!active_loader_ || active_loader_->deferred() == deferred)
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 } 343 }
334 int last_block_size = fifo_.back()->data_size(); 344 int last_block_size = fifo_.back()->data_size();
335 int to_append = std::min<int>(data_length, block_size() - last_block_size); 345 int to_append = std::min<int>(data_length, block_size() - last_block_size);
336 DCHECK_GT(to_append, 0); 346 DCHECK_GT(to_append, 0);
337 memcpy(fifo_.back()->writable_data() + last_block_size, data, to_append); 347 memcpy(fifo_.back()->writable_data() + last_block_size, data, to_append);
338 data += to_append; 348 data += to_append;
339 fifo_.back()->set_data_size(last_block_size + to_append); 349 fifo_.back()->set_data_size(last_block_size + to_append);
340 data_length -= to_append; 350 data_length -= to_append;
341 } 351 }
342 352
343 if (Available()) 353 url_data_->multibuffer()->OnDataProviderEvent(this);
344 url_data_->multibuffer()->OnDataProviderEvent(this);
345 354
346 // Beware, this object might be deleted here. 355 // Beware, this object might be deleted here.
347 } 356 }
348 357
349 void ResourceMultiBufferDataProvider::didDownloadData(WebURLLoader* loader, 358 void ResourceMultiBufferDataProvider::didDownloadData(WebURLLoader* loader,
350 int dataLength, 359 int dataLength,
351 int encoded_data_length) { 360 int encoded_data_length) {
352 NOTIMPLEMENTED(); 361 NOTIMPLEMENTED();
353 } 362 }
354 363
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 } 507 }
499 508
500 if (byte_pos() != first_byte_position) { 509 if (byte_pos() != first_byte_position) {
501 return false; 510 return false;
502 } 511 }
503 512
504 return true; 513 return true;
505 } 514 }
506 515
507 } // namespace media 516 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/resource_multibuffer_data_provider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698