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

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

Issue 10065037: RefCounted types should not have public destructors, base/ edition (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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
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 #include "base/memory/ref_counted_memory.h" 5 #include "base/memory/ref_counted_memory.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 RefCountedMemory::RefCountedMemory() { 9 RefCountedMemory::RefCountedMemory() {}
10 }
11 10
12 RefCountedMemory::~RefCountedMemory() { 11 RefCountedMemory::~RefCountedMemory() {}
13 }
14 12
15 const unsigned char* RefCountedStaticMemory::front() const { 13 const unsigned char* RefCountedStaticMemory::front() const {
16 return data_; 14 return data_;
17 } 15 }
18 16
19 size_t RefCountedStaticMemory::size() const { 17 size_t RefCountedStaticMemory::size() const {
20 return length_; 18 return length_;
21 } 19 }
22 20
23 RefCountedBytes::RefCountedBytes() { 21 RefCountedStaticMemory::~RefCountedStaticMemory() {}
24 } 22
23 RefCountedBytes::RefCountedBytes() {}
25 24
26 RefCountedBytes::RefCountedBytes(const std::vector<unsigned char>& initializer) 25 RefCountedBytes::RefCountedBytes(const std::vector<unsigned char>& initializer)
27 : data_(initializer) { 26 : data_(initializer) {
28 } 27 }
29 28
30 RefCountedBytes* RefCountedBytes::TakeVector( 29 RefCountedBytes* RefCountedBytes::TakeVector(
31 std::vector<unsigned char>* to_destroy) { 30 std::vector<unsigned char>* to_destroy) {
32 RefCountedBytes* bytes = new RefCountedBytes; 31 RefCountedBytes* bytes = new RefCountedBytes;
33 bytes->data_.swap(*to_destroy); 32 bytes->data_.swap(*to_destroy);
34 return bytes; 33 return bytes;
35 } 34 }
36 35
37 const unsigned char* RefCountedBytes::front() const { 36 const unsigned char* RefCountedBytes::front() const {
38 // STL will assert if we do front() on an empty vector, but calling code 37 // STL will assert if we do front() on an empty vector, but calling code
39 // expects a NULL. 38 // expects a NULL.
40 return size() ? &data_.front() : NULL; 39 return size() ? &data_.front() : NULL;
41 } 40 }
42 41
43 size_t RefCountedBytes::size() const { 42 size_t RefCountedBytes::size() const {
44 return data_.size(); 43 return data_.size();
45 } 44 }
46 45
47 RefCountedBytes::~RefCountedBytes() { 46 RefCountedBytes::~RefCountedBytes() {}
48 }
49 47
50 namespace base { 48 namespace base {
51 49
52 RefCountedString::RefCountedString() {} 50 RefCountedString::RefCountedString() {}
53 51
54 RefCountedString::~RefCountedString() {} 52 RefCountedString::~RefCountedString() {}
55 53
56 // static 54 // static
57 RefCountedString* RefCountedString::TakeString(std::string* to_destroy) { 55 RefCountedString* RefCountedString::TakeString(std::string* to_destroy) {
58 RefCountedString* self = new RefCountedString; 56 RefCountedString* self = new RefCountedString;
59 to_destroy->swap(self->data_); 57 to_destroy->swap(self->data_);
60 return self; 58 return self;
61 } 59 }
62 60
63 const unsigned char* RefCountedString::front() const { 61 const unsigned char* RefCountedString::front() const {
64 return data_.empty() ? NULL : 62 return data_.empty() ? NULL :
65 reinterpret_cast<const unsigned char*>(data_.data()); 63 reinterpret_cast<const unsigned char*>(data_.data());
66 } 64 }
67 65
68 size_t RefCountedString::size() const { 66 size_t RefCountedString::size() const {
69 return data_.size(); 67 return data_.size();
70 } 68 }
71 69
72 } // namespace base 70 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698