Commit 9624dedb authored by Marina Ciocea's avatar Marina Ciocea Committed by Commit Bot

Temporary check global histogram allocator in audio service output controller.

Add a temporary check to investigate audio service experiment output controller
histograms count mismatch. If histogram persistent memory is not setup before
output controller metrics are reported, the check will fail
(see https://crbug.com/867827#c40). This CL will be reverted in a couple of days
after gathering data from canary.

Bug: 867827
Change-Id: I1f18c12c2aa2741a27c0bf82f383de70e273fd24
Reviewed-on: https://chromium-review.googlesource.com/1205606Reviewed-by: default avatarOlga Sharonova <olka@chromium.org>
Commit-Queue: Marina Ciocea <marinaciocea@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589117}
parent c4b5d63d
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/bind_helpers.h" #include "base/bind_helpers.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/metrics/persistent_histogram_allocator.h"
#include "base/numerics/safe_conversions.h" #include "base/numerics/safe_conversions.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
...@@ -42,6 +43,8 @@ enum StreamCreationResult { ...@@ -42,6 +43,8 @@ enum StreamCreationResult {
void LogStreamCreationResult(bool for_device_change, void LogStreamCreationResult(bool for_device_change,
StreamCreationResult result) { StreamCreationResult result) {
// TODO(https://crbug.com/867827) remove histogram allocator check.
CHECK(base::GlobalHistogramAllocator::Get());
if (for_device_change) { if (for_device_change) {
UMA_HISTOGRAM_ENUMERATION( UMA_HISTOGRAM_ENUMERATION(
"Media.AudioOutputController.ProxyStreamCreationResultForDeviceChange", "Media.AudioOutputController.ProxyStreamCreationResultForDeviceChange",
...@@ -65,6 +68,8 @@ OutputController::ErrorStatisticsTracker::ErrorStatisticsTracker() ...@@ -65,6 +68,8 @@ OutputController::ErrorStatisticsTracker::ErrorStatisticsTracker()
} }
OutputController::ErrorStatisticsTracker::~ErrorStatisticsTracker() { OutputController::ErrorStatisticsTracker::~ErrorStatisticsTracker() {
// TODO(https://crbug.com/867827) remove histogram allocator check.
CHECK(base::GlobalHistogramAllocator::Get());
UMA_HISTOGRAM_LONG_TIMES("Media.OutputStreamDuration", UMA_HISTOGRAM_LONG_TIMES("Media.OutputStreamDuration",
base::TimeTicks::Now() - start_time_); base::TimeTicks::Now() - start_time_);
UMA_HISTOGRAM_BOOLEAN("Media.AudioOutputController.CallbackError", UMA_HISTOGRAM_BOOLEAN("Media.AudioOutputController.CallbackError",
...@@ -131,6 +136,9 @@ OutputController::~OutputController() { ...@@ -131,6 +136,9 @@ OutputController::~OutputController() {
bool OutputController::Create(bool is_for_device_change) { bool OutputController::Create(bool is_for_device_change) {
DCHECK(task_runner_->BelongsToCurrentThread()); DCHECK(task_runner_->BelongsToCurrentThread());
// TODO(https://crbug.com/867827) remove histogram allocator check.
CHECK(base::GlobalHistogramAllocator::Get());
SCOPED_UMA_HISTOGRAM_TIMER("Media.AudioOutputController.CreateTime"); SCOPED_UMA_HISTOGRAM_TIMER("Media.AudioOutputController.CreateTime");
TRACE_EVENT0("audio", "OutputController::Create"); TRACE_EVENT0("audio", "OutputController::Create");
handler_->OnLog(is_for_device_change handler_->OnLog(is_for_device_change
...@@ -201,6 +209,9 @@ bool OutputController::Create(bool is_for_device_change) { ...@@ -201,6 +209,9 @@ bool OutputController::Create(bool is_for_device_change) {
void OutputController::Play() { void OutputController::Play() {
DCHECK(task_runner_->BelongsToCurrentThread()); DCHECK(task_runner_->BelongsToCurrentThread());
// TODO(https://crbug.com/867827) remove histogram allocator check.
CHECK(base::GlobalHistogramAllocator::Get());
SCOPED_UMA_HISTOGRAM_TIMER("Media.AudioOutputController.PlayTime"); SCOPED_UMA_HISTOGRAM_TIMER("Media.AudioOutputController.PlayTime");
TRACE_EVENT0("audio", "OutputController::Play"); TRACE_EVENT0("audio", "OutputController::Play");
handler_->OnLog("OutputController::Play"); handler_->OnLog("OutputController::Play");
...@@ -246,6 +257,9 @@ void OutputController::StopStream() { ...@@ -246,6 +257,9 @@ void OutputController::StopStream() {
void OutputController::Pause() { void OutputController::Pause() {
DCHECK(task_runner_->BelongsToCurrentThread()); DCHECK(task_runner_->BelongsToCurrentThread());
// TODO(https://crbug.com/867827) remove histogram allocator check.
CHECK(base::GlobalHistogramAllocator::Get());
SCOPED_UMA_HISTOGRAM_TIMER("Media.AudioOutputController.PauseTime"); SCOPED_UMA_HISTOGRAM_TIMER("Media.AudioOutputController.PauseTime");
TRACE_EVENT0("audio", "OutputController::Pause"); TRACE_EVENT0("audio", "OutputController::Pause");
handler_->OnLog("OutputController::Pause"); handler_->OnLog("OutputController::Pause");
...@@ -265,6 +279,9 @@ void OutputController::Pause() { ...@@ -265,6 +279,9 @@ void OutputController::Pause() {
void OutputController::Close() { void OutputController::Close() {
DCHECK(task_runner_->BelongsToCurrentThread()); DCHECK(task_runner_->BelongsToCurrentThread());
// TODO(https://crbug.com/867827) remove histogram allocator check.
CHECK(base::GlobalHistogramAllocator::Get());
SCOPED_UMA_HISTOGRAM_TIMER("Media.AudioOutputController.CloseTime"); SCOPED_UMA_HISTOGRAM_TIMER("Media.AudioOutputController.CloseTime");
TRACE_EVENT0("audio", "OutputController::Close"); TRACE_EVENT0("audio", "OutputController::Close");
handler_->OnLog("OutputController::Close"); handler_->OnLog("OutputController::Close");
...@@ -513,6 +530,9 @@ void OutputController::OnMemberLeftGroup(StreamMonitor* monitor) { ...@@ -513,6 +530,9 @@ void OutputController::OnMemberLeftGroup(StreamMonitor* monitor) {
void OutputController::OnDeviceChange() { void OutputController::OnDeviceChange() {
DCHECK(task_runner_->BelongsToCurrentThread()); DCHECK(task_runner_->BelongsToCurrentThread());
// TODO(https://crbug.com/867827) remove histogram allocator check.
CHECK(base::GlobalHistogramAllocator::Get());
SCOPED_UMA_HISTOGRAM_TIMER("Media.AudioOutputController.DeviceChangeTime"); SCOPED_UMA_HISTOGRAM_TIMER("Media.AudioOutputController.DeviceChangeTime");
TRACE_EVENT0("audio", "OutputController::OnDeviceChange"); TRACE_EVENT0("audio", "OutputController::OnDeviceChange");
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/metrics/persistent_histogram_allocator.h"
#include "base/optional.h" #include "base/optional.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/single_thread_task_runner.h" #include "base/single_thread_task_runner.h"
...@@ -330,6 +331,14 @@ class OutputControllerTest : public ::testing::Test { ...@@ -330,6 +331,14 @@ class OutputControllerTest : public ::testing::Test {
std::string(), &mock_sync_reader_, std::string(), &mock_sync_reader_,
&stream_monitor_coordinator_, processing_id_); &stream_monitor_coordinator_, processing_id_);
controller_->SetVolume(kTestVolume); controller_->SetVolume(kTestVolume);
// TODO(https://crbug.com/867827) remove histogram allocator creation when
// removing output controller checks.
if (!base::GlobalHistogramAllocator::Get()) {
const int32_t kAllocatorMemorySize = 8 << 20;
base::GlobalHistogramAllocator::CreateWithLocalMemory(
kAllocatorMemorySize, 0, "HistogramAllocatorTest");
}
} }
void TearDown() override { controller_ = base::nullopt; } void TearDown() override { controller_ = base::nullopt; }
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <utility> #include <utility>
#include "base/metrics/persistent_histogram_allocator.h"
#include "base/test/mock_callback.h" #include "base/test/mock_callback.h"
#include "base/test/scoped_task_environment.h" #include "base/test/scoped_task_environment.h"
#include "base/unguessable_token.h" #include "base/unguessable_token.h"
...@@ -116,6 +117,14 @@ class TestEnvironment { ...@@ -116,6 +117,14 @@ class TestEnvironment {
stream_factory_binding_(&stream_factory_, stream_factory_binding_(&stream_factory_,
mojo::MakeRequest(&stream_factory_ptr_)) { mojo::MakeRequest(&stream_factory_ptr_)) {
mojo::core::SetDefaultProcessErrorCallback(bad_message_callback_.Get()); mojo::core::SetDefaultProcessErrorCallback(bad_message_callback_.Get());
// TODO(https://crbug.com/867827) remove histogram allocator creation when
// removing output controller checks.
if (!base::GlobalHistogramAllocator::Get()) {
const int32_t kAllocatorMemorySize = 8 << 20;
base::GlobalHistogramAllocator::CreateWithLocalMemory(
kAllocatorMemorySize, 0, "HistogramAllocatorTest");
}
} }
~TestEnvironment() { ~TestEnvironment() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment