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

Unified Diff: base/memory/ref_counted_memory.h

Issue 126103003: Changed RefCountedStaticMemory() to accept a void pointer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 11 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 | « no previous file | 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.h
diff --git a/base/memory/ref_counted_memory.h b/base/memory/ref_counted_memory.h
index d2987c5d21bd3d1cb1c6ebd6bf3c7f827b341491..d3ae3e25b0b77eae90aa323c14f9b7a80047707b 100644
--- a/base/memory/ref_counted_memory.h
+++ b/base/memory/ref_counted_memory.h
@@ -30,6 +30,10 @@ class BASE_EXPORT RefCountedMemory
// Returns true if |other| is byte for byte equal.
bool Equals(const scoped_refptr<RefCountedMemory>& other) const;
+ // Handy method to simplify calling front() with a reinterpret_cast.
+ template<typename T> const T* front_as() const
brettw 2014/01/13 21:52:17 Style nit: if everything doesn't fit on one line,
+ { return reinterpret_cast<const T*>(front()); }
+
protected:
friend class base::RefCountedThreadSafe<RefCountedMemory>;
RefCountedMemory();
@@ -42,8 +46,9 @@ class BASE_EXPORT RefCountedStaticMemory : public RefCountedMemory {
public:
RefCountedStaticMemory()
: data_(NULL), length_(0) {}
- RefCountedStaticMemory(const unsigned char* data, size_t length)
- : data_(length ? data : NULL), length_(length) {}
+ RefCountedStaticMemory(const void* data, size_t length)
brettw 2014/01/13 21:52:17 I feel like void is right here. But then it seems
+ : data_(static_cast<const unsigned char*>(length ? data : NULL)),
+ length_(length) {}
// Overridden from RefCountedMemory:
virtual const unsigned char* front() const OVERRIDE;
« no previous file with comments | « no previous file | base/memory/ref_counted_memory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698