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

Side by Side Diff: cc/base/contiguous_container.cc

Issue 1866203004: Convert //cc from scoped_ptr to std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptrcc: rebase 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 | « cc/base/contiguous_container.h ('k') | cc/base/list_container.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 "cc/base/contiguous_container.h" 5 #include "cc/base/contiguous_container.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 26 matching lines...) Expand all
37 DCHECK_LE(begin(), object); 37 DCHECK_LE(begin(), object);
38 DCHECK_LT(object, end_); 38 DCHECK_LT(object, end_);
39 end_ = static_cast<char*>(object); 39 end_ = static_cast<char*>(object);
40 } 40 }
41 41
42 private: 42 private:
43 char* begin() { return &data_[0]; } 43 char* begin() { return &data_[0]; }
44 const char* begin() const { return &data_[0]; } 44 const char* begin() const { return &data_[0]; }
45 45
46 // begin() <= end_ <= begin() + capacity_ 46 // begin() <= end_ <= begin() + capacity_
47 scoped_ptr<char[]> data_; 47 std::unique_ptr<char[]> data_;
48 char* end_; 48 char* end_;
49 size_t capacity_; 49 size_t capacity_;
50 }; 50 };
51 51
52 ContiguousContainerBase::ContiguousContainerBase(size_t max_object_size) 52 ContiguousContainerBase::ContiguousContainerBase(size_t max_object_size)
53 : end_index_(0), max_object_size_(max_object_size) {} 53 : end_index_(0), max_object_size_(max_object_size) {}
54 54
55 ContiguousContainerBase::ContiguousContainerBase(size_t max_object_size, 55 ContiguousContainerBase::ContiguousContainerBase(size_t max_object_size,
56 size_t initial_size_bytes) 56 size_t initial_size_bytes)
57 : ContiguousContainerBase(max_object_size) { 57 : ContiguousContainerBase(max_object_size) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 elements_.swap(other.elements_); 129 elements_.swap(other.elements_);
130 buffers_.swap(other.buffers_); 130 buffers_.swap(other.buffers_);
131 std::swap(end_index_, other.end_index_); 131 std::swap(end_index_, other.end_index_);
132 std::swap(max_object_size_, other.max_object_size_); 132 std::swap(max_object_size_, other.max_object_size_);
133 } 133 }
134 134
135 ContiguousContainerBase::Buffer* 135 ContiguousContainerBase::Buffer*
136 ContiguousContainerBase::AllocateNewBufferForNextAllocation( 136 ContiguousContainerBase::AllocateNewBufferForNextAllocation(
137 size_t buffer_size) { 137 size_t buffer_size) {
138 DCHECK(buffers_.empty() || end_index_ == buffers_.size() - 1); 138 DCHECK(buffers_.empty() || end_index_ == buffers_.size() - 1);
139 scoped_ptr<Buffer> new_buffer(new Buffer(buffer_size)); 139 std::unique_ptr<Buffer> new_buffer(new Buffer(buffer_size));
140 Buffer* buffer_to_return = new_buffer.get(); 140 Buffer* buffer_to_return = new_buffer.get();
141 buffers_.push_back(std::move(new_buffer)); 141 buffers_.push_back(std::move(new_buffer));
142 end_index_ = buffers_.size() - 1; 142 end_index_ = buffers_.size() - 1;
143 return buffer_to_return; 143 return buffer_to_return;
144 } 144 }
145 145
146 } // namespace cc 146 } // namespace cc
OLDNEW
« no previous file with comments | « cc/base/contiguous_container.h ('k') | cc/base/list_container.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698