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

Unified Diff: webrtc/modules/desktop_capture/desktop_capturer.h

Issue 1988783003: Use std::unique_ptr<> to pass frame ownership in DesktopCapturer impls. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 6 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: webrtc/modules/desktop_capture/desktop_capturer.h
diff --git a/webrtc/modules/desktop_capture/desktop_capturer.h b/webrtc/modules/desktop_capture/desktop_capturer.h
index ba70e0155373410475cff8b27a8362bae453b265..80d910908b4fe213bb1f139795b329f2446de61f 100644
--- a/webrtc/modules/desktop_capture/desktop_capturer.h
+++ b/webrtc/modules/desktop_capture/desktop_capturer.h
@@ -15,24 +15,45 @@
#include <memory>
+#include "webrtc/modules/desktop_capture/desktop_frame.h"
#include "webrtc/modules/desktop_capture/desktop_capture_types.h"
#include "webrtc/modules/desktop_capture/shared_memory.h"
namespace webrtc {
class DesktopFrame;
-class DesktopRegion;
// Abstract interface for screen and window capturers.
class DesktopCapturer {
public:
+ enum class Result {
+ // The frame was captured successfully.
+ SUCCESS,
+
+ // There was a temporary error. The caller should continue calling
+ // Capture(), in the expectation that it will eventually recover.
+ ERROR_TEMPORARY,
+
+ // Capture has failed and will keep failing if the caller tries calling
+ // Capture() again.
+ ERROR_PERMANENT,
+ };
+
// Interface that must be implemented by the DesktopCapturer consumers.
class Callback {
public:
- // Called after a frame has been captured. Handler must take ownership of
- // |frame|. If capture has failed for any reason |frame| is set to NULL
- // (e.g. the window has been closed).
- virtual void OnCaptureCompleted(DesktopFrame* frame) = 0;
+ // Called after a frame has been captured. |frame| is not nullptr if and
+ // only if |result| is SUCCESS.
+ virtual void OnCaptureResult(Result result,
+ std::unique_ptr<DesktopFrame> frame) {
+ OnCaptureCompleted(frame.release());
+ }
+
+ // Deprecated version of the method above that uses raw pointer instead of
+ // std::unique_ptr<>.
+ // TODO(sergeyu): Remove this method and make OnCaptureResult() pure
+ // virtual. crbug.com/webrtc/5950
+ virtual void OnCaptureCompleted(DesktopFrame* frame) { delete frame; };
protected:
virtual ~Callback() {}

Powered by Google App Engine
This is Rietveld 408576698