Chromium Code Reviews| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 43 namespace content { | 43 namespace content { |
| 44 | 44 |
| 45 RenderMediaLog::RenderMediaLog(const GURL& security_origin) | 45 RenderMediaLog::RenderMediaLog(const GURL& security_origin) |
| 46 : security_origin_(security_origin), | 46 : security_origin_(security_origin), |
| 47 task_runner_(base::ThreadTaskRunnerHandle::Get()), | 47 task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| 48 tick_clock_(new base::DefaultTickClock()), | 48 tick_clock_(new base::DefaultTickClock()), |
| 49 last_ipc_send_time_(tick_clock_->NowTicks()), | 49 last_ipc_send_time_(tick_clock_->NowTicks()), |
| 50 ipc_send_pending_(false) { | 50 ipc_send_pending_(false) { |
| 51 DCHECK(RenderThread::Get()) | 51 DCHECK(RenderThread::Get()) |
| 52 << "RenderMediaLog must be constructed on the render thread"; | 52 << "RenderMediaLog must be constructed on the render thread"; |
| 53 queued_media_events_.push_back( | |
| 54 *CreateEvent(media::MediaLogEvent::MEDIALOG_CREATED)); | |
|
wolenetz
2017/03/21 00:21:26
In a hypothetical scenario where someone just crea
| |
| 53 } | 55 } |
| 54 | 56 |
| 55 void RenderMediaLog::AddEvent(std::unique_ptr<media::MediaLogEvent> event) { | 57 void RenderMediaLog::AddEvent(std::unique_ptr<media::MediaLogEvent> event) { |
| 56 Log(event.get()); | 58 Log(event.get()); |
| 57 | 59 |
| 58 // For enforcing delay until it's been a second since the last ipc message was | 60 // For enforcing delay until it's been a second since the last ipc message was |
| 59 // sent. | 61 // sent. |
| 60 base::TimeDelta delay_for_next_ipc_send; | 62 base::TimeDelta delay_for_next_ipc_send; |
| 61 | 63 |
| 62 { | 64 { |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 84 queued_media_events_.push_back(*event); | 86 queued_media_events_.push_back(*event); |
| 85 last_pipeline_error_.swap(event); | 87 last_pipeline_error_.swap(event); |
| 86 break; | 88 break; |
| 87 case media::MediaLogEvent::MEDIA_ERROR_LOG_ENTRY: | 89 case media::MediaLogEvent::MEDIA_ERROR_LOG_ENTRY: |
| 88 queued_media_events_.push_back(*event); | 90 queued_media_events_.push_back(*event); |
| 89 last_media_error_log_entry_.swap(event); | 91 last_media_error_log_entry_.swap(event); |
| 90 break; | 92 break; |
| 91 | 93 |
| 92 // Just enqueue all other event types for throttled transmission. | 94 // Just enqueue all other event types for throttled transmission. |
| 93 default: | 95 default: |
| 96 DCHECK_NE(media::MediaLogEvent::MEDIALOG_CREATED, event->type) | |
| 97 << "MEDIALOG_CREATED events should not be sent manually"; | |
| 94 queued_media_events_.push_back(*event); | 98 queued_media_events_.push_back(*event); |
| 95 } | 99 } |
| 96 | 100 |
| 97 if (ipc_send_pending_) | 101 if (ipc_send_pending_) |
| 98 return; | 102 return; |
| 99 | 103 |
| 100 ipc_send_pending_ = true; | 104 ipc_send_pending_ = true; |
| 101 delay_for_next_ipc_send = base::TimeDelta::FromSeconds(1) - | 105 delay_for_next_ipc_send = base::TimeDelta::FromSeconds(1) - |
| 102 (tick_clock_->NowTicks() - last_ipc_send_time_); | 106 (tick_clock_->NowTicks() - last_ipc_send_time_); |
| 103 } | 107 } |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 180 tick_clock_.swap(tick_clock); | 184 tick_clock_.swap(tick_clock); |
| 181 last_ipc_send_time_ = tick_clock_->NowTicks(); | 185 last_ipc_send_time_ = tick_clock_->NowTicks(); |
| 182 } | 186 } |
| 183 | 187 |
| 184 void RenderMediaLog::SetTaskRunnerForTesting( | 188 void RenderMediaLog::SetTaskRunnerForTesting( |
| 185 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { | 189 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { |
| 186 task_runner_ = task_runner; | 190 task_runner_ = task_runner; |
| 187 } | 191 } |
| 188 | 192 |
| 189 } // namespace content | 193 } // namespace content |
| OLD | NEW |