Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / content / renderer / media / render_media_log.h
blobb5e41a560e5136789a95cfb85e798eebffacec52
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.
5 #ifndef CONTENT_RENDERER_MEDIA_RENDER_MEDIA_LOG_H_
6 #define CONTENT_RENDERER_MEDIA_RENDER_MEDIA_LOG_H_
8 #include <vector>
10 #include "base/time/time.h"
11 #include "content/common/content_export.h"
12 #include "media/base/media_log.h"
14 namespace content {
16 // RenderMediaLog is an implementation of MediaLog that forwards events to the
17 // browser process, throttling as necessary.
19 // To minimize the number of events sent over the wire, only the latest event
20 // added is sent for high frequency events (e.g., BUFFERED_EXTENTS_CHANGED).
22 // It must be constructed on the render thread.
23 class CONTENT_EXPORT RenderMediaLog : public media::MediaLog {
24 public:
25 RenderMediaLog();
27 // MediaLog implementation.
28 void AddEvent(scoped_ptr<media::MediaLogEvent> event) override;
30 // Will reset |last_ipc_send_time_| with the value of NowTicks().
31 void SetTickClockForTesting(scoped_ptr<base::TickClock> tick_clock);
32 void SetTaskRunnerForTesting(
33 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
35 private:
36 ~RenderMediaLog() override;
38 // Add event on the |task_runner_|.
39 void AddEventInternal(scoped_ptr<media::MediaLogEvent> event);
41 // Posted as a delayed task to throttle ipc message frequency.
42 void SendQueuedMediaEvents();
44 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
45 scoped_ptr<base::TickClock> tick_clock_;
46 base::TimeTicks last_ipc_send_time_;
47 std::vector<media::MediaLogEvent> queued_media_events_;
49 // Limits the number buffered extents changed events we send over IPC to one.
50 scoped_ptr<media::MediaLogEvent> last_buffered_extents_changed_event_;
52 DISALLOW_COPY_AND_ASSIGN(RenderMediaLog);
55 } // namespace content
57 #endif // CONTENT_RENDERER_MEDIA_RENDER_MEDIA_LOG_H_