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

Side by Side Diff: base/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: git try works all platforms now. Created 9 years, 9 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_SCOPED_VECTOR_H_ 5 #ifndef BASE_SCOPED_VECTOR_H_
6 #define BASE_SCOPED_VECTOR_H_ 6 #define BASE_SCOPED_VECTOR_H_
7 #pragma once 7 #pragma once
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 std::vector<T*>& get() { return v; } 48 std::vector<T*>& get() { return v; }
49 const std::vector<T*>& get() const { return v; } 49 const std::vector<T*>& get() const { return v; }
50 void swap(ScopedVector<T>& other) { v.swap(other.v); } 50 void swap(ScopedVector<T>& other) { v.swap(other.v); }
51 void release(std::vector<T*>* out) { 51 void release(std::vector<T*>* out) {
52 out->swap(v); 52 out->swap(v);
53 v.clear(); 53 v.clear();
54 } 54 }
55 55
56 void reset() { STLDeleteElements(&v); } 56 void reset() { STLDeleteElements(&v); }
57 void reset(const std::vector<T*>& vec) {
James Hawkins 2011/03/16 22:39:35 You're essentially adding operator= by another nam
Sheridan Rawlins 2011/03/18 15:45:48 Ok, discussing alternative as you know on chromium
Sheridan Rawlins 2011/03/20 08:13:11 I'd like to tackle the idea of moving ScopedVector
58 reset();
59 v = vec;
60 }
stuartmorgan 2011/03/16 23:25:20 I don't feel comfortable being the reviewer for ad
Sheridan Rawlins 2011/03/18 15:45:48 This may be moot if I take alternative. o/w I'll
Sheridan Rawlins 2011/03/20 08:13:11 Nico seems to have some commits in base/scoped_vec
57 void reserve(size_t capacity) { v.reserve(capacity); } 61 void reserve(size_t capacity) { v.reserve(capacity); }
58 void resize(size_t new_size) { v.resize(new_size); } 62 void resize(size_t new_size) { v.resize(new_size); }
59 63
60 // Lets the ScopedVector take ownership of |x|. 64 // Lets the ScopedVector take ownership of |x|.
61 iterator insert(iterator position, T* x) { 65 iterator insert(iterator position, T* x) {
62 return v.insert(position, x); 66 return v.insert(position, x);
63 } 67 }
64 68
65 iterator erase(iterator position) { 69 iterator erase(iterator position) {
66 delete *position; 70 delete *position;
(...skipping 14 matching lines...) Expand all
81 iterator weak_erase(iterator first, iterator last) { 85 iterator weak_erase(iterator first, iterator last) {
82 return v.erase(first, last); 86 return v.erase(first, last);
83 } 87 }
84 private: 88 private:
85 std::vector<T*> v; 89 std::vector<T*> v;
86 90
87 DISALLOW_COPY_AND_ASSIGN(ScopedVector); 91 DISALLOW_COPY_AND_ASSIGN(ScopedVector);
88 }; 92 };
89 93
90 #endif // BASE_SCOPED_VECTOR_H_ 94 #endif // BASE_SCOPED_VECTOR_H_
OLDNEW
« no previous file with comments | « base/base.gyp ('k') | base/scoped_vector_unittest.cc » ('j') | base/scoped_vector_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698