Delete FakeWebRtcVcmFactory::OnDestroyed method.

This was called by FakeWebRtcVideoCaptureModule's destructor.
However, since the factory keeps a reference counted pointer to
each FakeWebRtcVideoCaptureModule it has created, no module is
destroyed until the factory is destroyed. And at that point,
coordination is not needed and actually broken, since OnDestroyed
results in Release being called on an object halfway through the
destruction sequence.

Bug: webrtc:9405
Change-Id: I0cf3acb49b58e2b6b83344d840835f594418f7c7
Reviewed-on: https://webrtc-review.googlesource.com/83721
Reviewed-by: Magnus Jedvert <magjed@webrtc.org>
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Commit-Queue: Patrik Höglund <phoglund@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23644}
This commit is contained in:
Niels Möller 2018-06-15 10:34:52 +02:00 committed by Commit Bot
parent 9394f6fda1
commit 6250fdd8fc
2 changed files with 4 additions and 15 deletions

View File

@ -25,7 +25,7 @@ class FakeWebRtcVcmFactory : public cricket::WebRtcVcmFactoryInterface {
const char* device_id) {
if (!device_info.GetDeviceById(device_id)) return NULL;
rtc::scoped_refptr<FakeWebRtcVideoCaptureModule> module(
new rtc::RefCountedObject<FakeWebRtcVideoCaptureModule>(this));
new rtc::RefCountedObject<FakeWebRtcVideoCaptureModule>());
modules.push_back(module);
return module;
}
@ -34,16 +34,8 @@ class FakeWebRtcVcmFactory : public cricket::WebRtcVcmFactoryInterface {
}
virtual void DestroyDeviceInfo(webrtc::VideoCaptureModule::DeviceInfo* info) {
}
void OnDestroyed(webrtc::VideoCaptureModule* module) {
std::remove(modules.begin(), modules.end(), module);
}
FakeWebRtcDeviceInfo device_info;
std::vector<rtc::scoped_refptr<FakeWebRtcVideoCaptureModule>> modules;
};
FakeWebRtcVideoCaptureModule::~FakeWebRtcVideoCaptureModule() {
if (factory_)
factory_->OnDestroyed(this);
}
#endif // MEDIA_ENGINE_FAKEWEBRTCVCMFACTORY_H_

View File

@ -18,14 +18,12 @@
#include "media/engine/webrtcvideocapturer.h"
#include "rtc_base/task_queue_for_test.h"
class FakeWebRtcVcmFactory;
// Fake class for mocking out webrtc::VideoCaptureModule.
class FakeWebRtcVideoCaptureModule : public webrtc::VideoCaptureModule {
public:
explicit FakeWebRtcVideoCaptureModule(FakeWebRtcVcmFactory* factory)
: factory_(factory), callback_(NULL), running_(false) {}
~FakeWebRtcVideoCaptureModule();
FakeWebRtcVideoCaptureModule()
: callback_(NULL), running_(false) {}
~FakeWebRtcVideoCaptureModule() {}
void RegisterCaptureDataCallback(
rtc::VideoSinkInterface<webrtc::VideoFrame>* callback) override {
callback_ = callback;
@ -81,7 +79,6 @@ class FakeWebRtcVideoCaptureModule : public webrtc::VideoCaptureModule {
private:
rtc::test::TaskQueueForTest task_queue_{"FakeWebRtcVideoCaptureModule"};
FakeWebRtcVcmFactory* factory_;
rtc::VideoSinkInterface<webrtc::VideoFrame>* callback_;
bool running_;
webrtc::VideoCaptureCapability cap_;