| Index: cc/scoped_ptr_vector.h
|
| diff --git a/cc/own_ptr_vector.h b/cc/scoped_ptr_vector.h
|
| similarity index 72%
|
| copy from cc/own_ptr_vector.h
|
| copy to cc/scoped_ptr_vector.h
|
| index 196f82107e565c680dc4c9424181b6700c213ebd..05e38d9bac9360518425e5512535c05d845bddb9 100644
|
| --- a/cc/own_ptr_vector.h
|
| +++ b/cc/scoped_ptr_vector.h
|
| @@ -2,20 +2,19 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#ifndef CC_OWN_PTR_VECTOR_H_
|
| -#define CC_OWN_PTR_VECTOR_H_
|
| +#ifndef CC_SCOPED_PTR_VECTOR_H_
|
| +#define CC_SCOPED_PTR_VECTOR_H_
|
|
|
| #include "base/basictypes.h"
|
| +#include "base/memory/scoped_ptr.h"
|
| #include "base/stl_util.h"
|
| -#include <wtf/PassOwnPtr.h>
|
| -#include <wtf/OwnPtr.h>
|
|
|
| namespace cc {
|
|
|
| -// This type acts like a Vector<OwnPtr> but based on top of std::vector. The
|
| -// OwnPtrVector has ownership of all elements in the vector.
|
| +// This type acts like a vector<scoped_ptr> based on top of std::vector. The
|
| +// ScopedPtrVector has ownership of all elements in the vector.
|
| template <typename T>
|
| -class OwnPtrVector {
|
| +class ScopedPtrVector {
|
| public:
|
| typedef typename std::vector<T*>::iterator iterator;
|
| typedef typename std::vector<T*>::const_iterator const_iterator;
|
| @@ -23,9 +22,9 @@ class OwnPtrVector {
|
| typedef typename std::vector<T*>::const_reverse_iterator
|
| const_reverse_iterator;
|
|
|
| - OwnPtrVector() {}
|
| + ScopedPtrVector() {}
|
|
|
| - ~OwnPtrVector() { clear(); }
|
| + ~ScopedPtrVector() { clear(); }
|
|
|
| size_t size() const {
|
| return data_.size();
|
| @@ -54,11 +53,11 @@ class OwnPtrVector {
|
| return size() == 0;
|
| }
|
|
|
| - PassOwnPtr<T> take(size_t index) {
|
| + scoped_ptr<T> take(size_t index) {
|
| ASSERT(index < size());
|
| - OwnPtr<T> ret = adoptPtr(data_[index]);
|
| + scoped_ptr<T> ret(data_[index]);
|
| data_[index] = NULL;
|
| - return ret.release();
|
| + return ret.Pass();
|
| }
|
|
|
| void remove(size_t index) {
|
| @@ -71,13 +70,13 @@ class OwnPtrVector {
|
| STLDeleteElements(&data_);
|
| }
|
|
|
| - void append(PassOwnPtr<T> item) {
|
| - data_.push_back(item.leakPtr());
|
| + void append(scoped_ptr<T> item) {
|
| + data_.push_back(item.release());
|
| }
|
|
|
| - void insert(size_t index, PassOwnPtr<T> item) {
|
| + void insert(size_t index, scoped_ptr<T> item) {
|
| ASSERT(index < size());
|
| - data_.insert(data_.begin() + index, item.leakPtr());
|
| + data_.insert(data_.begin() + index, item.release());
|
| }
|
|
|
| iterator begin() { return data_.begin(); }
|
| @@ -93,9 +92,9 @@ class OwnPtrVector {
|
| private:
|
| std::vector<T*> data_;
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(OwnPtrVector);
|
| + DISALLOW_COPY_AND_ASSIGN(ScopedPtrVector);
|
| };
|
|
|
| } // namespace cc
|
|
|
| -#endif // CC_OWN_PTR_VECTOR_H_
|
| +#endif // CC_SCOPED_PTR_VECTOR_H_
|
|
|