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

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

Issue 594733004: BufferedDataSource: don't reallocate buffer unnecessarily (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 | « no previous file | 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/buffered_data_source.h" 5 #include "media/blink/buffered_data_source.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/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "media/base/media_log.h" 10 #include "media/base/media_log.h"
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 return; 309 return;
310 310
311 position = read_op_->position(); 311 position = read_op_->position();
312 size = read_op_->size(); 312 size = read_op_->size();
313 } 313 }
314 314
315 // First we prepare the intermediate read buffer for BufferedResourceLoader 315 // First we prepare the intermediate read buffer for BufferedResourceLoader
316 // to write to. 316 // to write to.
317 if (size > intermediate_read_buffer_size_) { 317 if (size > intermediate_read_buffer_size_) {
318 intermediate_read_buffer_.reset(new uint8[size]); 318 intermediate_read_buffer_.reset(new uint8[size]);
319 intermediate_read_buffer_size_ = size;
xhwang 2014/09/23 20:56:22 Thanks for fixing this! The fix looks good. But I
319 } 320 }
320 321
321 // Perform the actual read with BufferedResourceLoader. 322 // Perform the actual read with BufferedResourceLoader.
322 loader_->Read(position, 323 loader_->Read(position,
323 size, 324 size,
324 intermediate_read_buffer_.get(), 325 intermediate_read_buffer_.get(),
325 base::Bind(&BufferedDataSource::ReadCallback, 326 base::Bind(&BufferedDataSource::ReadCallback,
326 weak_factory_.GetWeakPtr())); 327 weak_factory_.GetWeakPtr()));
327 } 328 }
328 329
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 } 527 }
527 528
528 // If media is currently playing or the page indicated preload=auto or the 529 // If media is currently playing or the page indicated preload=auto or the
529 // the server does not support the byte range request or we do not want to go 530 // the server does not support the byte range request or we do not want to go
530 // too far ahead of the read head, use threshold strategy to enable/disable 531 // too far ahead of the read head, use threshold strategy to enable/disable
531 // deferring when the buffer is full/depleted. 532 // deferring when the buffer is full/depleted.
532 loader_->UpdateDeferStrategy(BufferedResourceLoader::kCapacityDefer); 533 loader_->UpdateDeferStrategy(BufferedResourceLoader::kCapacityDefer);
533 } 534 }
534 535
535 } // namespace media 536 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698