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

Unified Diff: base/memory/ref_counted_memory.cc

Issue 7397021: Re-land r93365 - add RefCountedString (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 9 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/memory/ref_counted_memory.h ('k') | base/memory/ref_counted_memory_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/ref_counted_memory.cc
diff --git a/base/memory/ref_counted_memory.cc b/base/memory/ref_counted_memory.cc
index aa160318a9154c9d6bf711b9a73e7b41c3000f73..7e034f91af622ead5dbd6e85645b5416a1da096a 100644
--- a/base/memory/ref_counted_memory.cc
+++ b/base/memory/ref_counted_memory.cc
@@ -4,6 +4,8 @@
#include "base/memory/ref_counted_memory.h"
+#include "base/logging.h"
+
RefCountedMemory::RefCountedMemory() {
}
@@ -22,25 +24,49 @@ RefCountedBytes::RefCountedBytes() {
}
RefCountedBytes::RefCountedBytes(const std::vector<unsigned char>& initializer)
- : data(initializer) {
+ : data_(initializer) {
}
RefCountedBytes* RefCountedBytes::TakeVector(
std::vector<unsigned char>* to_destroy) {
RefCountedBytes* bytes = new RefCountedBytes;
- bytes->data.swap(*to_destroy);
+ bytes->data_.swap(*to_destroy);
return bytes;
}
const unsigned char* RefCountedBytes::front() const {
// STL will assert if we do front() on an empty vector, but calling code
// expects a NULL.
- return size() ? &data.front() : NULL;
+ return size() ? &data_.front() : NULL;
}
size_t RefCountedBytes::size() const {
- return data.size();
+ return data_.size();
}
RefCountedBytes::~RefCountedBytes() {
}
+
+namespace base {
+
+RefCountedString::RefCountedString() {}
+
+RefCountedString::~RefCountedString() {}
+
+// static
+RefCountedString* RefCountedString::TakeString(std::string* to_destroy) {
+ RefCountedString* self = new RefCountedString;
+ to_destroy->swap(self->data_);
+ return self;
+}
+
+const unsigned char* RefCountedString::front() const {
+ return data_.empty() ? NULL :
+ reinterpret_cast<const unsigned char*>(data_.data());
+}
+
+size_t RefCountedString::size() const {
+ return data_.size();
+}
+
+} // namespace base
« no previous file with comments | « base/memory/ref_counted_memory.h ('k') | base/memory/ref_counted_memory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698