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

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

Issue 2330543002: Change unique_ptr::reset() for std::move (Closed)
Patch Set: Change unique_ptr::reset() for std::move Created 4 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 | « AUTHORS ('k') | media/base/video_frame.cc » ('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 27 matching lines...) Expand all
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 std::unique_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_ = std::move(new_buffer);
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.
53 memmove(buffer_.get(), front(), used_); 53 memmove(buffer_.get(), front(), used_);
54 offset_ = 0; 54 offset_ = 0;
55 } 55 }
56 56
57 memcpy(front() + used_, data, size); 57 memcpy(front() + used_, data, size);
58 used_ += size; 58 used_ += size;
(...skipping 17 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 | « AUTHORS ('k') | media/base/video_frame.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698