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

Unified Diff: skia/ext/refptr.h

Issue 19267024: cc: Don't leak a ref to SkColorFilter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: filterleak: refptr Created 7 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 | « cc/output/gl_renderer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: skia/ext/refptr.h
diff --git a/skia/ext/refptr.h b/skia/ext/refptr.h
index a3900f61ba4502c0d59c3b8664cf6bb4dd3c4aa1..1e66a5215791a599dc869d3dd7bb779d484333a1 100644
--- a/skia/ext/refptr.h
+++ b/skia/ext/refptr.h
@@ -5,6 +5,8 @@
#ifndef SKIA_EXT_REFPTR_H_
#define SKIA_EXT_REFPTR_H_
+#include "base/basictypes.h"
+#include "base/logging.h"
#include "third_party/skia/include/core/SkRefCnt.h"
namespace skia {
@@ -87,6 +89,30 @@ class RefPtr {
return ptr_ ? &RefPtr::ptr_ : NULL;
}
+ class Receiver {
+ public:
+ ~Receiver() {
+ DCHECK(!*refptr_) << "RefPtr must be empty.";
+ refptr_->ptr_ = ptr_;
+ }
+
+ operator T**() { return &ptr_; }
+
+ private:
+ friend class RefPtr;
+
+ Receiver(RefPtr* refptr) : refptr_(refptr), ptr_(NULL) {
awong 2013/07/17 23:12:59 explicit?
danakj 2013/07/17 23:18:46 Done.
+ DCHECK(!*refptr_) << "RefPtr must be empty.";
+ }
+
+ RefPtr* refptr_;
+ T* ptr_;
+
+ DISALLOW_COPY_AND_ASSIGN(Receiver);
+ };
+
+ Receiver ReceiveAndAdoptRef() { return Receiver(this); }
awong 2013/07/17 23:12:59 Add comment saying to not use this as part of a su
danakj 2013/07/17 23:18:46 Good point! Done, with examples.
+
private:
T* ptr_;
« no previous file with comments | « cc/output/gl_renderer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698