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

Side by Side Diff: media/cdm/simple_cdm_buffer.cc

Issue 1802183002: Convert CreateCdmBuffer() to use size_t for |capacity| (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DCHECKs Created 4 years, 9 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/cdm/simple_cdm_buffer.h ('k') | media/mojo/common/mojo_shared_buffer_video_frame.h » ('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 "media/cdm/simple_cdm_buffer.h" 5 #include "media/cdm/simple_cdm_buffer.h"
6 6
7 #include <limits>
8
7 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/numerics/safe_conversions.h"
8 11
9 namespace media { 12 namespace media {
10 13
11 // static 14 // static
12 SimpleCdmBuffer* SimpleCdmBuffer::Create(uint32_t capacity) { 15 SimpleCdmBuffer* SimpleCdmBuffer::Create(size_t capacity) {
13 DCHECK(capacity); 16 DCHECK(capacity);
14 return new SimpleCdmBuffer(capacity); 17
18 // cdm::Buffer interface limits capacity to uint32.
19 DCHECK_LE(capacity,
20 static_cast<size_t>(std::numeric_limits<uint32_t>::max()));
xhwang 2016/03/15 18:57:37 OOC, can you drop the static_cast since both size_
jrummell 2016/03/15 19:43:12 Done.
21 return new SimpleCdmBuffer(base::checked_cast<uint32_t>(capacity));
15 } 22 }
16 23
17 SimpleCdmBuffer::SimpleCdmBuffer(uint32_t capacity) 24 SimpleCdmBuffer::SimpleCdmBuffer(uint32_t capacity)
18 : buffer_(capacity), size_(0) {} 25 : buffer_(capacity), size_(0) {}
19 26
20 SimpleCdmBuffer::~SimpleCdmBuffer() {} 27 SimpleCdmBuffer::~SimpleCdmBuffer() {}
21 28
22 void SimpleCdmBuffer::Destroy() { 29 void SimpleCdmBuffer::Destroy() {
23 delete this; 30 delete this;
24 } 31 }
25 32
26 uint32_t SimpleCdmBuffer::Capacity() const { 33 uint32_t SimpleCdmBuffer::Capacity() const {
27 return buffer_.size(); 34 return buffer_.size();
28 } 35 }
29 36
30 uint8_t* SimpleCdmBuffer::Data() { 37 uint8_t* SimpleCdmBuffer::Data() {
31 return buffer_.data(); 38 return buffer_.data();
32 } 39 }
33 40
34 void SimpleCdmBuffer::SetSize(uint32_t size) { 41 void SimpleCdmBuffer::SetSize(uint32_t size) {
35 DCHECK(size <= Capacity()); 42 DCHECK(size <= Capacity());
36 size_ = size > Capacity() ? 0 : size; 43 size_ = size > Capacity() ? 0 : size;
37 } 44 }
38 45
39 uint32_t SimpleCdmBuffer::Size() const { 46 uint32_t SimpleCdmBuffer::Size() const {
40 return size_; 47 return size_;
41 } 48 }
42 49
43 } // namespace media 50 } // namespace media
OLDNEW
« no previous file with comments | « media/cdm/simple_cdm_buffer.h ('k') | media/mojo/common/mojo_shared_buffer_video_frame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698