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

Unified Diff: content/browser/renderer_host/media/video_capture_manager.h

Issue 24133002: Make VideoCaptureController single-threaded and not ref counted. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More longwinded hobbledy-nobble Created 7 years, 3 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/browser/renderer_host/media/video_capture_manager.h
diff --git a/content/browser/renderer_host/media/video_capture_manager.h b/content/browser/renderer_host/media/video_capture_manager.h
index fb0a574a3e7ff4a49e77a8262b1c2f110491428d..0e3d45b66c1a7ca64d02808e7bb1618a78e30d00 100644
--- a/content/browser/renderer_host/media/video_capture_manager.h
+++ b/content/browser/renderer_host/media/video_capture_manager.h
@@ -17,6 +17,7 @@
#include <string>
#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
#include "base/process/process_handle.h"
#include "content/browser/renderer_host/media/media_stream_provider.h"
#include "content/browser/renderer_host/media/video_capture_controller_event_handler.h"
@@ -26,13 +27,16 @@
#include "media/video/capture/video_capture_types.h"
namespace content {
-class MockVideoCaptureManager;
class VideoCaptureController;
class VideoCaptureControllerEventHandler;
// VideoCaptureManager opens/closes and start/stops video capture devices.
class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider {
public:
+ // Callback used to signal the completion of a controller lookup.
+ typedef base::Callback<
+ void(const base::WeakPtr<VideoCaptureController>&)> DoneCB;
Ami GONE FROM CHROMIUM 2013/09/14 00:32:24 "DoneCB"? Oh, so your "callback" signifies being
ncarter (slow) 2013/09/14 01:29:31 One must pick one's battles.
+
// Calling |Start| of this id will open the first device, even though open has
// not been called. This is used to be able to use video capture devices
// before MediaStream is implemented in Chrome and WebKit.
@@ -69,12 +73,11 @@ class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider {
// On success, the controller is returned via calling |done_cb|, indicating
// that the client was successfully added. A NULL controller is passed to
// the callback on failure.
- void StartCaptureForClient(
- const media::VideoCaptureParams& capture_params,
- base::ProcessHandle client_render_process,
- VideoCaptureControllerID client_id,
- VideoCaptureControllerEventHandler* client_handler,
- base::Callback<void(VideoCaptureController*)> done_cb);
+ void StartCaptureForClient(const media::VideoCaptureParams& capture_params,
+ base::ProcessHandle client_render_process,
+ VideoCaptureControllerID client_id,
+ VideoCaptureControllerEventHandler* client_handler,
+ DoneCB done_cb);
Ami GONE FROM CHROMIUM 2013/09/14 00:32:24 Shouldn't callbacks be passed by const&?
ncarter (slow) 2013/09/14 01:29:31 Done.
// Called by VideoCaptureHost to remove |client_handler|. If this is the last
// client of the device, the |controller| and its VideoCaptureDevice may be
@@ -94,7 +97,7 @@ class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider {
base::ProcessHandle client_render_process,
VideoCaptureControllerID client_id,
VideoCaptureControllerEventHandler* client_handler,
- base::Callback<void(VideoCaptureController*)> done_cb,
+ DoneCB done_cb,
const media::VideoCaptureDevice::Names& device_names);
// Helper routine implementing StartCaptureForClient().
@@ -103,7 +106,7 @@ class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider {
base::ProcessHandle client_render_process,
VideoCaptureControllerID client_id,
VideoCaptureControllerEventHandler* client_handler,
- base::Callback<void(VideoCaptureController*)> done_cb);
+ DoneCB done_cb);
// Check to see if |entry| has no clients left on its controller. If so,
// remove it from the list of devices, and delete it asynchronously. |entry|
@@ -135,22 +138,17 @@ class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider {
MediaStreamType stream_type);
// Create and Start a new VideoCaptureDevice, storing the result in
- // |entry->video_capture_device|.
+ // |entry->video_capture_device|. Ownership of |handler| passes to
+ // the device.
void DoStartDeviceOnDeviceThread(
DeviceEntry* entry,
const media::VideoCaptureCapability& capture_params,
- media::VideoCaptureDevice::EventHandler* controller_as_handler);
+ scoped_ptr<media::VideoCaptureDevice::EventHandler> handler);
// Stop and destroy the VideoCaptureDevice held in
// |entry->video_capture_device|.
void DoStopDeviceOnDeviceThread(DeviceEntry* entry);
- // Helper to clean up the DeviceEntry* instance, and the
- // VideoCaptureController, on the IO thread. Must happen after
- // DoStopDeviceOnDeviceThread() destroys the VideoCaptureDevice. It is assumed
- // that |dead_device| has already been removed from the |devices_| map.
- void FreeDeviceEntryOnIOThread(scoped_ptr<DeviceEntry> dead_device);
-
// The message loop of media stream device thread, where VCD's live.
scoped_refptr<base::MessageLoopProxy> device_loop_;
@@ -176,14 +174,14 @@ class CONTENT_EXPORT VideoCaptureManager : public MediaStreamProvider {
struct DeviceEntry {
DeviceEntry(MediaStreamType stream_type,
const std::string& id,
- scoped_refptr<VideoCaptureController> controller);
+ scoped_ptr<VideoCaptureController> controller);
~DeviceEntry();
const MediaStreamType stream_type;
const std::string id;
// The controller. Only used from the IO thread.
- scoped_refptr<VideoCaptureController> video_capture_controller;
+ scoped_ptr<VideoCaptureController> video_capture_controller;
// The capture device. Only used from the device thread.
scoped_ptr<media::VideoCaptureDevice> video_capture_device;

Powered by Google App Engine
This is Rietveld 408576698