1// Copyright (c) 2012 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#ifndef CONTENT_RENDERER_MEDIA_RENDER_MEDIA_LOG_H_ 6#define CONTENT_RENDERER_MEDIA_RENDER_MEDIA_LOG_H_ 7 8#include <vector> 9 10#include "base/time/time.h" 11#include "content/common/content_export.h" 12#include "media/base/media_log.h" 13 14namespace base { 15class MessageLoopProxy; 16} 17 18namespace content { 19 20// RenderMediaLog is an implementation of MediaLog that forwards events to the 21// browser process, throttling as necessary. 22// 23// To minimize the number of events sent over the wire, only the latest event 24// added is sent for high frequency events (e.g., BUFFERED_EXTENTS_CHANGED). 25class CONTENT_EXPORT RenderMediaLog : public media::MediaLog { 26 public: 27 RenderMediaLog(); 28 29 // MediaLog implementation. 30 virtual void AddEvent(scoped_ptr<media::MediaLogEvent> event) OVERRIDE; 31 32 // Will reset |last_ipc_send_time_| with the value of NowTicks(). 33 void SetTickClockForTesting(scoped_ptr<base::TickClock> tick_clock); 34 35 private: 36 virtual ~RenderMediaLog(); 37 38 scoped_refptr<base::MessageLoopProxy> render_loop_; 39 scoped_ptr<base::TickClock> tick_clock_; 40 base::TimeTicks last_ipc_send_time_; 41 std::vector<media::MediaLogEvent> queued_media_events_; 42 43 // Limits the number buffered extents changed events we send over IPC to one. 44 scoped_ptr<media::MediaLogEvent> last_buffered_extents_changed_event_; 45 46 DISALLOW_COPY_AND_ASSIGN(RenderMediaLog); 47}; 48 49} // namespace content 50 51#endif // CONTENT_RENDERER_MEDIA_RENDER_MEDIA_LOG_H_ 52