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

Unified Diff: Source/platform/heap/Handle.h

Issue 1084313004: Oilpan: keep ImageData on the heap by default. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Ensure timely disposal of temporary ImageData buffers Created 5 years, 7 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 | « Source/core/html/canvas/WebGLRenderingContextBase.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/heap/Handle.h
diff --git a/Source/platform/heap/Handle.h b/Source/platform/heap/Handle.h
index fb0842b946be5bf4b64edaf9eb5c0e244feccce8..414d35647520a25e0f7e8f8cbc8117c305c86cdc 100644
--- a/Source/platform/heap/Handle.h
+++ b/Source/platform/heap/Handle.h
@@ -843,6 +843,31 @@ template<typename T> PassOwnPtrWillBeRawPtr<T> adoptPtrWillBeNoop(T* ptr) { retu
#endif // ENABLE(OILPAN)
+// Abstraction for injecting calls to an object's 'dispose()' method
+// on leaving a stack scope, ensuring earlier release of resources
+// than waiting until the object is eventually GCed.
+template<typename T>
+class ScopedDisposal {
+ STACK_ALLOCATED();
+public:
+ ScopedDisposal(T* object)
+ : m_object(object)
+ {
+ static_assert(IsGarbageCollectedType<T>::value, "can only be used with garbage collected types");
+ }
+
+ ~ScopedDisposal()
+ {
+ if (m_object)
+ m_object->dispose();
+ }
+
+ void clear() { m_object.clear(); }
+
+private:
+ Member<T> m_object;
+};
+
} // namespace blink
namespace WTF {
« no previous file with comments | « Source/core/html/canvas/WebGLRenderingContextBase.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698