This source file includes following definitions.
- create
- m_callback
- ownerDocument
- start
- succeed
- stop
#include "config.h"
#include "modules/mediastream/MediaDevicesRequest.h"
#include "bindings/v8/ExceptionState.h"
#include "core/dom/Document.h"
#include "modules/mediastream/UserMediaController.h"
namespace WebCore {
PassRefPtr<MediaDevicesRequest> MediaDevicesRequest::create(ExecutionContext* context, UserMediaController* controller, PassOwnPtr<MediaDeviceInfoCallback> callback, ExceptionState& exceptionState)
{
RefPtr<MediaDevicesRequest> request = adoptRef(new MediaDevicesRequest(context, controller, callback));
request->suspendIfNeeded();
return request.release();
}
MediaDevicesRequest::MediaDevicesRequest(ExecutionContext* context, UserMediaController* controller, PassOwnPtr<MediaDeviceInfoCallback> callback)
: ActiveDOMObject(context)
, m_controller(controller)
, m_callback(callback)
{
}
MediaDevicesRequest::~MediaDevicesRequest()
{
}
Document* MediaDevicesRequest::ownerDocument()
{
if (ExecutionContext* context = executionContext()) {
return toDocument(context);
}
return 0;
}
void MediaDevicesRequest::start()
{
if (m_controller)
m_controller->requestMediaDevices(this);
}
void MediaDevicesRequest::succeed(const MediaDeviceInfoVector& mediaDevices)
{
if (!executionContext() || !m_callback)
return;
m_callback->handleEvent(mediaDevices);
}
void MediaDevicesRequest::stop()
{
m_callback.clear();
m_controller = 0;
}
}