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

Unified Diff: media/video/video_encode_accelerator.h

Issue 292183011: Make DefaultDeleter for Video{De|En}codeAccelerator (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile for Impl Created 6 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
Index: media/video/video_encode_accelerator.h
diff --git a/media/video/video_encode_accelerator.h b/media/video/video_encode_accelerator.h
index fd934dde447c6fe2c9e347c960a48d999cdfa4cd..011248ff7710f2c51cf72a429139f3aa8ce11deb 100644
--- a/media/video/video_encode_accelerator.h
+++ b/media/video/video_encode_accelerator.h
@@ -22,8 +22,6 @@ class VideoFrame;
// Video encoder interface.
class MEDIA_EXPORT VideoEncodeAccelerator {
public:
- virtual ~VideoEncodeAccelerator();
-
// Specification of an encoding profile supported by an encoder.
struct SupportedProfile {
VideoCodecProfile profile;
@@ -143,8 +141,31 @@ class MEDIA_EXPORT VideoEncodeAccelerator {
// this method returns no more callbacks will be made on the client. Deletes
// |this| unconditionally, so make sure to drop all pointers to it!
virtual void Destroy() = 0;
+
+ protected:
+ // Do not delete directly; use Destroy() or own it with a scoped_ptr, which
+ // will delete it properly by default.
Ami GONE FROM CHROMIUM 2014/05/27 20:06:02 s/delete/Destroy()/
dmichael (off chromium) 2014/05/28 22:31:25 Done.
+ virtual ~VideoEncodeAccelerator();
};
} // namespace media
+namespace base {
+
+template <class T>
+struct DefaultDeleter;
+
+// Specialize DefaultDeleter so that scoped_ptr<VideoEncodeAccelerator> always
+// uses "Destroy()" instead of trying to use the destructor.
+template <>
+struct DefaultDeleter<media::VideoEncodeAccelerator> {
+ public:
+ inline void operator()(void* video_encode_accelerator) const {
+ static_cast<media::VideoEncodeAccelerator*>(video_encode_accelerator)
Ami GONE FROM CHROMIUM 2014/05/27 20:06:02 can this be not inline?
dmichael (off chromium) 2014/05/28 22:31:25 operator()'s implementation is inline... do you m
+ ->Destroy();
+ }
+};
+
+} // namespace base
+
#endif // MEDIA_VIDEO_VIDEO_ENCODE_ACCELERATOR_H_
« media/filters/gpu_video_decoder.cc ('K') | « media/video/video_decode_accelerator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698