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

Side by Side Diff: media/base/byte_queue.cc

Issue 1906423005: Replace scoped_ptr with std::unique_ptr in //media/base. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptr-media-base: android Created 4 years, 8 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/base/byte_queue.h ('k') | media/base/cdm_factory.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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/base/byte_queue.h" 5 #include "media/base/byte_queue.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 namespace media { 9 namespace media {
10 10
(...skipping 21 matching lines...) Expand all
32 32
33 // Check to see if we need a bigger buffer. 33 // Check to see if we need a bigger buffer.
34 if (size_needed > size_) { 34 if (size_needed > size_) {
35 size_t new_size = 2 * size_; 35 size_t new_size = 2 * size_;
36 while (size_needed > new_size && new_size > size_) 36 while (size_needed > new_size && new_size > size_)
37 new_size *= 2; 37 new_size *= 2;
38 38
39 // Sanity check to make sure we didn't overflow. 39 // Sanity check to make sure we didn't overflow.
40 CHECK_GT(new_size, size_); 40 CHECK_GT(new_size, size_);
41 41
42 scoped_ptr<uint8_t[]> new_buffer(new uint8_t[new_size]); 42 std::unique_ptr<uint8_t[]> new_buffer(new uint8_t[new_size]);
43 43
44 // Copy the data from the old buffer to the start of the new one. 44 // Copy the data from the old buffer to the start of the new one.
45 if (used_ > 0) 45 if (used_ > 0)
46 memcpy(new_buffer.get(), front(), used_); 46 memcpy(new_buffer.get(), front(), used_);
47 47
48 buffer_.reset(new_buffer.release()); 48 buffer_.reset(new_buffer.release());
49 size_ = new_size; 49 size_ = new_size;
50 offset_ = 0; 50 offset_ = 0;
51 } else if ((offset_ + used_ + size) > size_) { 51 } else if ((offset_ + used_ + size) > size_) {
52 // The buffer is big enough, but we need to move the data in the queue. 52 // The buffer is big enough, but we need to move the data in the queue.
(...skipping 23 matching lines...) Expand all
76 DCHECK_EQ(used_, 0); 76 DCHECK_EQ(used_, 0);
77 offset_ = 0; 77 offset_ = 0;
78 } 78 }
79 } 79 }
80 80
81 uint8_t* ByteQueue::front() const { 81 uint8_t* ByteQueue::front() const {
82 return buffer_.get() + offset_; 82 return buffer_.get() + offset_;
83 } 83 }
84 84
85 } // namespace media 85 } // namespace media
OLDNEW
« no previous file with comments | « media/base/byte_queue.h ('k') | media/base/cdm_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698