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

Side by Side Diff: base/memory/scoped_vector.h

Issue 6646051: Fix DCHECK, memory leak, and refactor PasswordStore to use CancelableRequest (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: use non-zero tests until http://crbug.com/77650 is addressed. Created 9 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 | Annotate | Revision Log
« no previous file with comments | « base/base.gyp ('k') | base/memory/scoped_vector_unittest.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 #ifndef BASE_MEMORY_SCOPED_VECTOR_H_ 5 #ifndef BASE_MEMORY_SCOPED_VECTOR_H_
6 #define BASE_MEMORY_SCOPED_VECTOR_H_ 6 #define BASE_MEMORY_SCOPED_VECTOR_H_
7 #pragma once 7 #pragma once
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 55
56 void reset() { STLDeleteElements(&v); } 56 void reset() { STLDeleteElements(&v); }
57 void reserve(size_t capacity) { v.reserve(capacity); } 57 void reserve(size_t capacity) { v.reserve(capacity); }
58 void resize(size_t new_size) { v.resize(new_size); } 58 void resize(size_t new_size) { v.resize(new_size); }
59 59
60 // Lets the ScopedVector take ownership of |x|. 60 // Lets the ScopedVector take ownership of |x|.
61 iterator insert(iterator position, T* x) { 61 iterator insert(iterator position, T* x) {
62 return v.insert(position, x); 62 return v.insert(position, x);
63 } 63 }
64 64
65 // Lets the ScopedVector take ownership of elements in [first,last).
66 template<typename InputIterator>
67 void insert(iterator position, InputIterator first, InputIterator last) {
68 v.insert(position, first, last);
69 }
70
65 iterator erase(iterator position) { 71 iterator erase(iterator position) {
66 delete *position; 72 delete *position;
67 return v.erase(position); 73 return v.erase(position);
68 } 74 }
69 75
70 iterator erase(iterator first, iterator last) { 76 iterator erase(iterator first, iterator last) {
71 STLDeleteContainerPointers(first, last); 77 STLDeleteContainerPointers(first, last);
72 return v.erase(first, last); 78 return v.erase(first, last);
73 } 79 }
74 80
75 // Like |erase()|, but doesn't delete the element at |position|. 81 // Like |erase()|, but doesn't delete the element at |position|.
76 iterator weak_erase(iterator position) { 82 iterator weak_erase(iterator position) {
77 return v.erase(position); 83 return v.erase(position);
78 } 84 }
79 85
80 // Like |erase()|, but doesn't delete the elements in [first, last). 86 // Like |erase()|, but doesn't delete the elements in [first, last).
81 iterator weak_erase(iterator first, iterator last) { 87 iterator weak_erase(iterator first, iterator last) {
82 return v.erase(first, last); 88 return v.erase(first, last);
83 } 89 }
84 private: 90 private:
85 std::vector<T*> v; 91 std::vector<T*> v;
86 92
87 DISALLOW_COPY_AND_ASSIGN(ScopedVector); 93 DISALLOW_COPY_AND_ASSIGN(ScopedVector);
88 }; 94 };
89 95
90 #endif // BASE_MEMORY_SCOPED_VECTOR_H_ 96 #endif // BASE_MEMORY_SCOPED_VECTOR_H_
OLDNEW
« no previous file with comments | « base/base.gyp ('k') | base/memory/scoped_vector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698