| 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 #include "content/renderer/media/render_media_log.h" | 5 #include "content/renderer/media/render_media_log.h" |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 switch (event->type) { | 65 switch (event->type) { |
| 66 case media::MediaLogEvent::BUFFERED_EXTENTS_CHANGED: | 66 case media::MediaLogEvent::BUFFERED_EXTENTS_CHANGED: |
| 67 // Keep track of the latest buffered extents properties to avoid sending | 67 // Keep track of the latest buffered extents properties to avoid sending |
| 68 // thousands of events over IPC. See http://crbug.com/352585 for | 68 // thousands of events over IPC. See http://crbug.com/352585 for |
| 69 // details. | 69 // details. |
| 70 last_buffered_extents_changed_event_.swap(event); | 70 last_buffered_extents_changed_event_.swap(event); |
| 71 // SendQueuedMediaEvents() will enqueue the most recent event of this | 71 // SendQueuedMediaEvents() will enqueue the most recent event of this |
| 72 // kind, if any, prior to sending the event batch. | 72 // kind, if any, prior to sending the event batch. |
| 73 break; | 73 break; |
| 74 | 74 |
| 75 case media::MediaLogEvent::DURATION_SET: |
| 76 // Similar to the extents changed message, this may fire many times for |
| 77 // badly muxed media. Suppress within our rate limits here. |
| 78 last_duration_changed_event_.swap(event); |
| 79 break; |
| 80 |
| 75 // Hold onto the most recent PIPELINE_ERROR and MEDIA_LOG_ERROR_ENTRY for | 81 // Hold onto the most recent PIPELINE_ERROR and MEDIA_LOG_ERROR_ENTRY for |
| 76 // use in GetLastErrorMessage(). | 82 // use in GetLastErrorMessage(). |
| 77 case media::MediaLogEvent::PIPELINE_ERROR: | 83 case media::MediaLogEvent::PIPELINE_ERROR: |
| 78 queued_media_events_.push_back(*event); | 84 queued_media_events_.push_back(*event); |
| 79 last_pipeline_error_.swap(event); | 85 last_pipeline_error_.swap(event); |
| 80 break; | 86 break; |
| 81 case media::MediaLogEvent::MEDIA_ERROR_LOG_ENTRY: | 87 case media::MediaLogEvent::MEDIA_ERROR_LOG_ENTRY: |
| 82 queued_media_events_.push_back(*event); | 88 queued_media_events_.push_back(*event); |
| 83 last_media_error_log_entry_.swap(event); | 89 last_media_error_log_entry_.swap(event); |
| 84 break; | 90 break; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 base::AutoLock auto_lock(lock_); | 152 base::AutoLock auto_lock(lock_); |
| 147 | 153 |
| 148 DCHECK(ipc_send_pending_); | 154 DCHECK(ipc_send_pending_); |
| 149 ipc_send_pending_ = false; | 155 ipc_send_pending_ = false; |
| 150 | 156 |
| 151 if (last_buffered_extents_changed_event_) { | 157 if (last_buffered_extents_changed_event_) { |
| 152 queued_media_events_.push_back(*last_buffered_extents_changed_event_); | 158 queued_media_events_.push_back(*last_buffered_extents_changed_event_); |
| 153 last_buffered_extents_changed_event_.reset(); | 159 last_buffered_extents_changed_event_.reset(); |
| 154 } | 160 } |
| 155 | 161 |
| 162 if (last_duration_changed_event_) { |
| 163 queued_media_events_.push_back(*last_duration_changed_event_); |
| 164 last_duration_changed_event_.reset(); |
| 165 } |
| 166 |
| 156 queued_media_events_.swap(events_to_send); | 167 queued_media_events_.swap(events_to_send); |
| 157 last_ipc_send_time_ = tick_clock_->NowTicks(); | 168 last_ipc_send_time_ = tick_clock_->NowTicks(); |
| 158 } | 169 } |
| 159 | 170 |
| 160 RenderThread::Get()->Send(new ViewHostMsg_MediaLogEvents(events_to_send)); | 171 RenderThread::Get()->Send(new ViewHostMsg_MediaLogEvents(events_to_send)); |
| 161 } | 172 } |
| 162 | 173 |
| 163 RenderMediaLog::~RenderMediaLog() { | 174 RenderMediaLog::~RenderMediaLog() { |
| 164 } | 175 } |
| 165 | 176 |
| 166 void RenderMediaLog::SetTickClockForTesting( | 177 void RenderMediaLog::SetTickClockForTesting( |
| 167 std::unique_ptr<base::TickClock> tick_clock) { | 178 std::unique_ptr<base::TickClock> tick_clock) { |
| 168 base::AutoLock auto_lock(lock_); | 179 base::AutoLock auto_lock(lock_); |
| 169 tick_clock_.swap(tick_clock); | 180 tick_clock_.swap(tick_clock); |
| 170 last_ipc_send_time_ = tick_clock_->NowTicks(); | 181 last_ipc_send_time_ = tick_clock_->NowTicks(); |
| 171 } | 182 } |
| 172 | 183 |
| 173 void RenderMediaLog::SetTaskRunnerForTesting( | 184 void RenderMediaLog::SetTaskRunnerForTesting( |
| 174 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { | 185 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { |
| 175 task_runner_ = task_runner; | 186 task_runner_ = task_runner; |
| 176 } | 187 } |
| 177 | 188 |
| 178 } // namespace content | 189 } // namespace content |
| OLD | NEW |