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

Unified Diff: content/renderer/media/media_stream_video_capturer_source.h

Issue 843943002: Refactor VideoCapturerDelegate to use WeakPtr instead of refcount. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix source_formats_callback_.reset Created 5 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
Index: content/renderer/media/media_stream_video_capturer_source.h
diff --git a/content/renderer/media/media_stream_video_capturer_source.h b/content/renderer/media/media_stream_video_capturer_source.h
index e22b6db9c6052354a20993684f4b05d86f2e41df..a2154e0526ae90bb911e6245b910f349272634a5 100644
--- a/content/renderer/media/media_stream_video_capturer_source.h
+++ b/content/renderer/media/media_stream_video_capturer_source.h
@@ -7,6 +7,7 @@
#include "base/callback.h"
#include "base/gtest_prod_util.h"
+#include "base/memory/weak_ptr.h"
#include "base/message_loop/message_loop_proxy.h"
#include "base/threading/thread_checker.h"
#include "content/common/media/video_capture.h"
@@ -19,12 +20,12 @@ namespace content {
// and receive I420 frames from Chrome's video capture implementation.
//
// This is a render thread only object.
-class CONTENT_EXPORT VideoCapturerDelegate
- : public base::RefCountedThreadSafe<VideoCapturerDelegate> {
+class CONTENT_EXPORT VideoCapturerDelegate {
public:
typedef base::Callback<void(MediaStreamRequestResult result)> RunningCallback;
explicit VideoCapturerDelegate(const StreamDeviceInfo& device_info);
+ virtual ~VideoCapturerDelegate();
// Collects the formats that can currently be used.
// |max_requested_height|, |max_requested_width|, and
@@ -57,8 +58,6 @@ class CONTENT_EXPORT VideoCapturerDelegate
friend class base::RefCountedThreadSafe<VideoCapturerDelegate>;
friend class MockVideoCapturerDelegate;
- virtual ~VideoCapturerDelegate();
-
void OnStateUpdateOnRenderThread(VideoCaptureState state);
void OnDeviceFormatsInUseReceived(const media::VideoCaptureFormats& formats);
void OnDeviceSupportedFormatsEnumerated(
@@ -81,6 +80,8 @@ class CONTENT_EXPORT VideoCapturerDelegate
// Bound to the render thread.
base::ThreadChecker thread_checker_;
+ base::WeakPtrFactory<VideoCapturerDelegate> weak_factory_;
+
DISALLOW_COPY_AND_ASSIGN(VideoCapturerDelegate);
};
@@ -94,7 +95,7 @@ class CONTENT_EXPORT MediaStreamVideoCapturerSource
MediaStreamVideoCapturerSource(
const StreamDeviceInfo& device_info,
const SourceStoppedCallback& stop_callback,
- const scoped_refptr<VideoCapturerDelegate>& delegate);
+ scoped_ptr<VideoCapturerDelegate> delegate);
virtual ~MediaStreamVideoCapturerSource();
@@ -114,7 +115,7 @@ class CONTENT_EXPORT MediaStreamVideoCapturerSource
private:
// The delegate that provides video frames.
- scoped_refptr<VideoCapturerDelegate> delegate_;
+ scoped_ptr<VideoCapturerDelegate> delegate_;
DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoCapturerSource);
};

Powered by Google App Engine
This is Rietveld 408576698