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

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

Issue 2671613003: Add checked_cast to size_t conversion in multibuffer_data_source.cc (Closed)
Patch Set: Created 3 years, 10 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/multibuffer_data_source.h" 5 #include "media/blink/multibuffer_data_source.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/numerics/safe_conversions.h"
13 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
14 #include "media/base/media_log.h" 15 #include "media/base/media_log.h"
15 #include "media/blink/buffered_data_source_host_impl.h" 16 #include "media/blink/buffered_data_source_host_impl.h"
16 #include "media/blink/multibuffer_reader.h" 17 #include "media/blink/multibuffer_reader.h"
17 #include "net/base/net_errors.h" 18 #include "net/base/net_errors.h"
18 19
19 using blink::WebFrame; 20 using blink::WebFrame;
20 21
21 namespace { 22 namespace {
22 23
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 if (reader_ && (always_cancel || (preload_ == METADATA && 329 if (reader_ && (always_cancel || (preload_ == METADATA &&
329 !media_has_played_ && !IsStreaming()))) { 330 !media_has_played_ && !IsStreaming()))) {
330 cancel_on_defer_ = true; 331 cancel_on_defer_ = true;
331 if (!loading_) 332 if (!loading_)
332 reader_.reset(nullptr); 333 reader_.reset(nullptr);
333 } 334 }
334 } 335 }
335 336
336 int64_t MultibufferDataSource::GetMemoryUsage() const { 337 int64_t MultibufferDataSource::GetMemoryUsage() const {
337 // TODO(hubbe): Make more accurate when url_data_ is shared. 338 // TODO(hubbe): Make more accurate when url_data_ is shared.
338 return url_data_->CachedSize() 339 return base::checked_cast<int64_t>(url_data_->CachedSize())
brucedawson 2017/02/02 22:22:52 Why do we need a checked cast for converting to a
jrummell 2017/02/03 01:35:40 My understanding is that on some systems size_t is
339 << url_data_->multibuffer()->block_size_shift(); 340 << url_data_->multibuffer()->block_size_shift();
340 } 341 }
341 342
342 GURL MultibufferDataSource::GetUrlAfterRedirects() const { 343 GURL MultibufferDataSource::GetUrlAfterRedirects() const {
343 return url_data_->url(); 344 return url_data_->url();
344 } 345 }
345 346
346 void MultibufferDataSource::Read(int64_t position, 347 void MultibufferDataSource::Read(int64_t position,
347 int size, 348 int size,
348 uint8_t* data, 349 uint8_t* data,
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 reader_->SetPinRange(pin_backward, pin_forward); 634 reader_->SetPinRange(pin_backward, pin_forward);
634 635
635 if (preload_ == METADATA) { 636 if (preload_ == METADATA) {
636 reader_->SetPreload(0, 0); 637 reader_->SetPreload(0, 0);
637 } else { 638 } else {
638 reader_->SetPreload(preload_high, preload); 639 reader_->SetPreload(preload_high, preload);
639 } 640 }
640 } 641 }
641 642
642 } // namespace media 643 } // 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