This source file includes following definitions.
- m_asyncEventQueue
- add
- remove
- clear
- scheduleEvent
- interfaceName
- executionContext
- trace
#include "config.h"
#include "modules/mediasource/SourceBufferList.h"
#include "core/events/Event.h"
#include "core/events/GenericEventQueue.h"
#include "modules/mediasource/SourceBuffer.h"
namespace WebCore {
SourceBufferList::SourceBufferList(ExecutionContext* context, GenericEventQueue* asyncEventQueue)
: m_executionContext(context)
, m_asyncEventQueue(asyncEventQueue)
{
ScriptWrappable::init(this);
}
SourceBufferList::~SourceBufferList()
{
ASSERT(m_list.isEmpty());
}
void SourceBufferList::add(PassRefPtrWillBeRawPtr<SourceBuffer> buffer)
{
m_list.append(buffer);
scheduleEvent(EventTypeNames::addsourcebuffer);
}
void SourceBufferList::remove(SourceBuffer* buffer)
{
size_t index = m_list.find(buffer);
if (index == kNotFound)
return;
m_list.remove(index);
scheduleEvent(EventTypeNames::removesourcebuffer);
}
void SourceBufferList::clear()
{
m_list.clear();
scheduleEvent(EventTypeNames::removesourcebuffer);
}
void SourceBufferList::scheduleEvent(const AtomicString& eventName)
{
ASSERT(m_asyncEventQueue);
RefPtrWillBeRawPtr<Event> event = Event::create(eventName);
event->setTarget(this);
m_asyncEventQueue->enqueueEvent(event.release());
}
const AtomicString& SourceBufferList::interfaceName() const
{
return EventTargetNames::SourceBufferList;
}
ExecutionContext* SourceBufferList::executionContext() const
{
return m_executionContext;
}
void SourceBufferList::trace(Visitor* visitor)
{
visitor->trace(m_list);
}
}