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" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 13 #include "base/threading/thread_task_runner_handle.h" | 13 #include "base/threading/thread_task_runner_handle.h" |
| 14 #include "base/time/default_tick_clock.h" | 14 #include "base/time/default_tick_clock.h" |
| 15 #include "content/common/metrics.mojom.h" | |
| 15 #include "content/common/view_messages.h" | 16 #include "content/common/view_messages.h" |
| 16 #include "content/public/common/content_client.h" | 17 #include "content/public/common/content_client.h" |
| 17 #include "content/public/renderer/content_renderer_client.h" | 18 #include "content/public/renderer/content_renderer_client.h" |
| 18 #include "content/public/renderer/render_thread.h" | 19 #include "content/public/renderer/render_thread.h" |
| 20 #include "services/service_manager/public/cpp/interface_provider.h" | |
| 19 | 21 |
| 20 #ifndef MEDIA_EVENT_LOG_UTILITY | 22 #ifndef MEDIA_EVENT_LOG_UTILITY |
| 21 #define MEDIA_EVENT_LOG_UTILITY DVLOG(1) | 23 #define MEDIA_EVENT_LOG_UTILITY DVLOG(1) |
| 22 #endif | 24 #endif |
| 23 | 25 |
| 24 namespace { | 26 namespace { |
| 25 | 27 |
| 26 // Print an event to the chromium log. | 28 // Print an event to the chromium log. |
| 27 void Log(media::MediaLogEvent* event) { | 29 void Log(media::MediaLogEvent* event) { |
| 28 if (event->type == media::MediaLogEvent::PIPELINE_ERROR || | 30 if (event->type == media::MediaLogEvent::PIPELINE_ERROR || |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 43 namespace content { | 45 namespace content { |
| 44 | 46 |
| 45 RenderMediaLog::RenderMediaLog(const GURL& security_origin) | 47 RenderMediaLog::RenderMediaLog(const GURL& security_origin) |
| 46 : security_origin_(security_origin), | 48 : security_origin_(security_origin), |
| 47 task_runner_(base::ThreadTaskRunnerHandle::Get()), | 49 task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| 48 tick_clock_(new base::DefaultTickClock()), | 50 tick_clock_(new base::DefaultTickClock()), |
| 49 last_ipc_send_time_(tick_clock_->NowTicks()), | 51 last_ipc_send_time_(tick_clock_->NowTicks()), |
| 50 ipc_send_pending_(false) { | 52 ipc_send_pending_(false) { |
| 51 DCHECK(RenderThread::Get()) | 53 DCHECK(RenderThread::Get()) |
| 52 << "RenderMediaLog must be constructed on the render thread"; | 54 << "RenderMediaLog must be constructed on the render thread"; |
| 55 | |
| 56 mojom::OneShotMetricHostPtr one_shot_metric; | |
|
bcwhite
2017/02/21 12:37:54
Why is the renderer accessing a "host" object?
DaleCurtis
2017/02/21 17:54:29
Eh, it's just the naming scheme commonly used by m
| |
| 57 RenderThread::Get()->GetRemoteInterfaces()->GetInterface(&one_shot_metric); | |
| 58 one_shot_metric->Initialize("Media.UnderflowCount", 1, 100, 50); | |
| 59 one_shot_metric->SetSample(5); | |
| 60 one_shot_metric->SetSample(7); | |
| 61 | |
| 62 mojom::OneShotMetricHostPtr one_shot_metric2; | |
| 63 RenderThread::Get()->GetRemoteInterfaces()->GetInterface(&one_shot_metric2); | |
| 64 one_shot_metric2->Initialize("Media.UnderflowCount", 1, 100, 50); | |
| 65 one_shot_metric2->SetSample(70); | |
| 66 one_shot_metric2->SetSample(100); | |
| 53 } | 67 } |
| 54 | 68 |
| 55 void RenderMediaLog::AddEvent(std::unique_ptr<media::MediaLogEvent> event) { | 69 void RenderMediaLog::AddEvent(std::unique_ptr<media::MediaLogEvent> event) { |
| 56 Log(event.get()); | 70 Log(event.get()); |
| 57 | 71 |
| 58 // For enforcing delay until it's been a second since the last ipc message was | 72 // For enforcing delay until it's been a second since the last ipc message was |
| 59 // sent. | 73 // sent. |
| 60 base::TimeDelta delay_for_next_ipc_send; | 74 base::TimeDelta delay_for_next_ipc_send; |
| 61 | 75 |
| 62 { | 76 { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 180 tick_clock_.swap(tick_clock); | 194 tick_clock_.swap(tick_clock); |
| 181 last_ipc_send_time_ = tick_clock_->NowTicks(); | 195 last_ipc_send_time_ = tick_clock_->NowTicks(); |
| 182 } | 196 } |
| 183 | 197 |
| 184 void RenderMediaLog::SetTaskRunnerForTesting( | 198 void RenderMediaLog::SetTaskRunnerForTesting( |
| 185 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { | 199 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { |
| 186 task_runner_ = task_runner; | 200 task_runner_ = task_runner; |
| 187 } | 201 } |
| 188 | 202 |
| 189 } // namespace content | 203 } // namespace content |
| OLD | NEW |