OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_RENDERER_MEDIA_RENDER_MEDIA_LOG_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_RENDER_MEDIA_LOG_H_ |
6 #define CONTENT_RENDERER_MEDIA_RENDER_MEDIA_LOG_H_ | 6 #define CONTENT_RENDERER_MEDIA_RENDER_MEDIA_LOG_H_ |
7 | 7 |
8 #include <string> | |
8 #include <vector> | 9 #include <vector> |
9 | 10 |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
11 #include "base/synchronization/lock.h" | 12 #include "base/synchronization/lock.h" |
12 #include "base/time/time.h" | 13 #include "base/time/time.h" |
13 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
14 #include "media/base/media_log.h" | 15 #include "media/base/media_log.h" |
15 | 16 |
16 namespace base { | 17 namespace base { |
17 class TickClock; | 18 class TickClock; |
18 } | 19 } |
19 | 20 |
20 namespace content { | 21 namespace content { |
21 | 22 |
22 // RenderMediaLog is an implementation of MediaLog that forwards events to the | 23 // RenderMediaLog is an implementation of MediaLog that forwards events to the |
23 // browser process, throttling as necessary. | 24 // browser process, throttling as necessary. |
24 // | 25 // |
26 // It also caches the last error messages to support renderer-side reporting to | |
watk
2016/04/04 23:47:25
s/messages/events?
wolenetz
2016/04/05 00:23:27
Done.
| |
27 // entities like HTMLMediaElement and devtools console. | |
28 // | |
25 // To minimize the number of events sent over the wire, only the latest event | 29 // To minimize the number of events sent over the wire, only the latest event |
26 // added is sent for high frequency events (e.g., BUFFERED_EXTENTS_CHANGED). | 30 // added is sent for high frequency events (e.g., BUFFERED_EXTENTS_CHANGED). |
27 // | 31 // |
28 // It must be constructed on the render thread. | 32 // It must be constructed on the render thread. |
29 class CONTENT_EXPORT RenderMediaLog : public media::MediaLog { | 33 class CONTENT_EXPORT RenderMediaLog : public media::MediaLog { |
30 public: | 34 public: |
31 RenderMediaLog(); | 35 RenderMediaLog(); |
32 | 36 |
33 // MediaLog implementation. | 37 // MediaLog implementation. |
34 void AddEvent(scoped_ptr<media::MediaLogEvent> event) override; | 38 void AddEvent(scoped_ptr<media::MediaLogEvent> event) override; |
39 std::string GetLastErrorMessage() override; | |
35 | 40 |
36 // Will reset |last_ipc_send_time_| with the value of NowTicks(). | 41 // Will reset |last_ipc_send_time_| with the value of NowTicks(). |
37 void SetTickClockForTesting(scoped_ptr<base::TickClock> tick_clock); | 42 void SetTickClockForTesting(scoped_ptr<base::TickClock> tick_clock); |
38 void SetTaskRunnerForTesting( | 43 void SetTaskRunnerForTesting( |
39 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); | 44 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); |
40 | 45 |
41 private: | 46 private: |
42 ~RenderMediaLog() override; | 47 ~RenderMediaLog() override; |
43 | 48 |
44 // Posted as a delayed task on |task_runner_| to throttle ipc message | 49 // Posted as a delayed task on |task_runner_| to throttle ipc message |
45 // frequency. | 50 // frequency. |
46 void SendQueuedMediaEvents(); | 51 void SendQueuedMediaEvents(); |
47 | 52 |
48 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 53 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
49 | 54 |
50 // |lock_| serializes access to |tick_clock_|, |last_ipc_send_time_|, | 55 // |lock_| serializes access to |tick_clock_|, |last_ipc_send_time_|, |
51 // |queued_media_events_|, |ipc_send_pending_| and | 56 // |queued_media_events_|, |ipc_send_pending_|, |
52 // |last_buffered_extents_changed_event_|. It allows any render process thread | 57 // |last_buffered_extents_changed_event_|, |last_media_error_log_entry_| and |
53 // to AddEvent(), while preserving their sequence for throttled send on | 58 // |last_pipeline_error_|. It allows any render process thread to AddEvent(), |
watk
2016/04/04 23:47:25
You could say lock protects access to all followin
wolenetz
2016/04/05 00:23:27
Done.
| |
54 // |task_runner_|. | 59 // while preserving their sequence for throttled send on |task_runner_| and |
60 // coherent retrieval by GetLastErrorMessage(). | |
55 mutable base::Lock lock_; | 61 mutable base::Lock lock_; |
56 scoped_ptr<base::TickClock> tick_clock_; | 62 scoped_ptr<base::TickClock> tick_clock_; |
57 base::TimeTicks last_ipc_send_time_; | 63 base::TimeTicks last_ipc_send_time_; |
58 std::vector<media::MediaLogEvent> queued_media_events_; | 64 std::vector<media::MediaLogEvent> queued_media_events_; |
59 | 65 |
60 // For enforcing max 1 pending send. | 66 // For enforcing max 1 pending send. |
61 bool ipc_send_pending_; | 67 bool ipc_send_pending_; |
62 | 68 |
63 // Limits the number buffered extents changed events we send over IPC to one. | 69 // Limits the number buffered extents changed events we send over IPC to one. |
64 scoped_ptr<media::MediaLogEvent> last_buffered_extents_changed_event_; | 70 scoped_ptr<media::MediaLogEvent> last_buffered_extents_changed_event_; |
65 | 71 |
72 // Holds a copy of the most recent MEDIA_ERROR_LOG_ENTRY, if any. | |
73 scoped_ptr<media::MediaLogEvent> last_media_error_log_entry_; | |
74 | |
75 // Holds a copy of the most recent PIPELINE_ERROR, if any. | |
76 scoped_ptr<media::MediaLogEvent> last_pipeline_error_; | |
77 | |
66 DISALLOW_COPY_AND_ASSIGN(RenderMediaLog); | 78 DISALLOW_COPY_AND_ASSIGN(RenderMediaLog); |
67 }; | 79 }; |
68 | 80 |
69 } // namespace content | 81 } // namespace content |
70 | 82 |
71 #endif // CONTENT_RENDERER_MEDIA_RENDER_MEDIA_LOG_H_ | 83 #endif // CONTENT_RENDERER_MEDIA_RENDER_MEDIA_LOG_H_ |
OLD | NEW |