This source file includes following definitions.
- last_ipc_send_time_
- AddEvent
- SetTickClockForTesting
#include "content/renderer/media/render_media_log.h"
#include "base/bind.h"
#include "base/logging.h"
#include "base/message_loop/message_loop_proxy.h"
#include "content/common/view_messages.h"
#include "content/public/renderer/render_thread.h"
namespace content {
RenderMediaLog::RenderMediaLog()
: render_loop_(base::MessageLoopProxy::current()),
tick_clock_(new base::DefaultTickClock()),
last_ipc_send_time_(tick_clock_->NowTicks()) {
DCHECK(RenderThread::Get()) <<
"RenderMediaLog must be constructed on the render thread";
}
void RenderMediaLog::AddEvent(scoped_ptr<media::MediaLogEvent> event) {
if (!RenderThread::Get()) {
render_loop_->PostTask(FROM_HERE, base::Bind(
&RenderMediaLog::AddEvent, this, base::Passed(&event)));
return;
}
if (event->type == media::MediaLogEvent::BUFFERED_EXTENTS_CHANGED)
last_buffered_extents_changed_event_.swap(event);
else
queued_media_events_.push_back(*event);
base::TimeTicks curr_time = tick_clock_->NowTicks();
if ((curr_time - last_ipc_send_time_) < base::TimeDelta::FromSeconds(1))
return;
last_ipc_send_time_ = curr_time;
if (last_buffered_extents_changed_event_) {
queued_media_events_.push_back(*last_buffered_extents_changed_event_);
last_buffered_extents_changed_event_.reset();
}
DVLOG(1) << "media log events array size " << queued_media_events_.size();
RenderThread::Get()->Send(
new ViewHostMsg_MediaLogEvents(queued_media_events_));
queued_media_events_.clear();
}
RenderMediaLog::~RenderMediaLog() {}
void RenderMediaLog::SetTickClockForTesting(
scoped_ptr<base::TickClock> tick_clock) {
tick_clock_.swap(tick_clock);
last_ipc_send_time_ = tick_clock_->NowTicks();
}
}