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

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

Issue 1803263002: base: Make RefCountedBytes::TakeVector return ref ptr instead of raw ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « no previous file | base/memory/ref_counted_memory.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_REF_COUNTED_MEMORY_H_ 5 #ifndef BASE_MEMORY_REF_COUNTED_MEMORY_H_
6 #define BASE_MEMORY_REF_COUNTED_MEMORY_H_ 6 #define BASE_MEMORY_REF_COUNTED_MEMORY_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 // Constructs a RefCountedBytes object by _copying_ from |initializer|. 75 // Constructs a RefCountedBytes object by _copying_ from |initializer|.
76 explicit RefCountedBytes(const std::vector<unsigned char>& initializer); 76 explicit RefCountedBytes(const std::vector<unsigned char>& initializer);
77 77
78 // Constructs a RefCountedBytes object by copying |size| bytes from |p|. 78 // Constructs a RefCountedBytes object by copying |size| bytes from |p|.
79 RefCountedBytes(const unsigned char* p, size_t size); 79 RefCountedBytes(const unsigned char* p, size_t size);
80 80
81 // Constructs a RefCountedBytes object by performing a swap. (To non 81 // Constructs a RefCountedBytes object by performing a swap. (To non
82 // destructively build a RefCountedBytes, use the constructor that takes a 82 // destructively build a RefCountedBytes, use the constructor that takes a
83 // vector.) 83 // vector.)
84 static RefCountedBytes* TakeVector(std::vector<unsigned char>* to_destroy); 84 static scoped_refptr<RefCountedBytes> TakeVector(
85 std::vector<unsigned char>* to_destroy);
85 86
86 // Overridden from RefCountedMemory: 87 // Overridden from RefCountedMemory:
87 const unsigned char* front() const override; 88 const unsigned char* front() const override;
88 size_t size() const override; 89 size_t size() const override;
89 90
90 const std::vector<unsigned char>& data() const { return data_; } 91 const std::vector<unsigned char>& data() const { return data_; }
91 std::vector<unsigned char>& data() { return data_; } 92 std::vector<unsigned char>& data() { return data_; }
92 93
93 private: 94 private:
94 ~RefCountedBytes() override; 95 ~RefCountedBytes() override;
(...skipping 25 matching lines...) Expand all
120 ~RefCountedString() override; 121 ~RefCountedString() override;
121 122
122 std::string data_; 123 std::string data_;
123 124
124 DISALLOW_COPY_AND_ASSIGN(RefCountedString); 125 DISALLOW_COPY_AND_ASSIGN(RefCountedString);
125 }; 126 };
126 127
127 } // namespace base 128 } // namespace base
128 129
129 #endif // BASE_MEMORY_REF_COUNTED_MEMORY_H_ 130 #endif // BASE_MEMORY_REF_COUNTED_MEMORY_H_
OLDNEW
« no previous file with comments | « no previous file | base/memory/ref_counted_memory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698