Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Unified Diff: content/browser/renderer_host/media/audio_renderer_host.cc

Issue 2121223002: AudioOutputDevice authorization timeout UMA histograms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 50 buckets Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/renderer_host/media/audio_renderer_host.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/media/audio_renderer_host.cc
diff --git a/content/browser/renderer_host/media/audio_renderer_host.cc b/content/browser/renderer_host/media/audio_renderer_host.cc
index 947c00cd4331e84959852f61e8023fffb8a00680..616478945420cf9dffc2c319893785bd7aa66595 100644
--- a/content/browser/renderer_host/media/audio_renderer_host.cc
+++ b/content/browser/renderer_host/media/audio_renderer_host.cc
@@ -109,6 +109,13 @@ void MaybeFixAudioParameters(media::AudioParameters* params) {
*params = media::AudioParameters::UnavailableDeviceParams();
}
+void UMALogDeviceAuthorizationTime(base::TimeTicks auth_start_time) {
+ UMA_HISTOGRAM_CUSTOM_TIMES("Media.Audio.OutputDeviceAuthorizationTime",
+ base::TimeTicks::Now() - auth_start_time,
+ base::TimeDelta::FromMilliseconds(1),
+ base::TimeDelta::FromMilliseconds(5000), 50);
+}
+
} // namespace
class AudioRendererHost::AudioEntry
@@ -398,6 +405,8 @@ void AudioRendererHost::OnRequestDeviceAuthorization(
const std::string& device_id,
const url::Origin& security_origin) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ const base::TimeTicks auth_start_time = base::TimeTicks::Now();
+
DVLOG(1) << "AudioRendererHost@" << this << "::OnRequestDeviceAuthorization"
<< "(stream_id=" << stream_id
<< ", render_frame_id=" << render_frame_id
@@ -408,6 +417,7 @@ void AudioRendererHost::OnRequestDeviceAuthorization(
return;
if (!IsValidDeviceId(device_id)) {
+ UMALogDeviceAuthorizationTime(auth_start_time);
Send(new AudioMsg_NotifyDeviceAuthorized(
stream_id, media::OUTPUT_DEVICE_STATUS_ERROR_NOT_FOUND,
media::AudioParameters::UnavailableDeviceParams(), std::string()));
@@ -432,6 +442,7 @@ void AudioRendererHost::OnRequestDeviceAuthorization(
authorizations_.insert(MakeAuthorizationData(
stream_id, true, info->device.matched_output_device_id));
MaybeFixAudioParameters(&output_params);
+ UMALogDeviceAuthorizationTime(auth_start_time);
// Hash matched device id and pass it to the renderer
Send(new AudioMsg_NotifyDeviceAuthorized(
stream_id, media::OUTPUT_DEVICE_STATUS_OK, output_params,
@@ -446,22 +457,26 @@ void AudioRendererHost::OnRequestDeviceAuthorization(
CheckOutputDeviceAccess(
render_frame_id, device_id, security_origin,
base::Bind(&AudioRendererHost::OnDeviceAuthorized, this, stream_id,
- device_id, security_origin));
+ device_id, security_origin, auth_start_time));
}
void AudioRendererHost::OnDeviceAuthorized(int stream_id,
const std::string& device_id,
const url::Origin& security_origin,
+ base::TimeTicks auth_start_time,
bool have_access) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
const auto& auth_data = authorizations_.find(stream_id);
// A close request was received while access check was in progress.
- if (auth_data == authorizations_.end())
+ if (auth_data == authorizations_.end()) {
+ UMALogDeviceAuthorizationTime(auth_start_time);
return;
+ }
if (!have_access) {
authorizations_.erase(auth_data);
+ UMALogDeviceAuthorizationTime(auth_start_time);
Send(new AudioMsg_NotifyDeviceAuthorized(
stream_id, media::OUTPUT_DEVICE_STATUS_ERROR_NOT_AUTHORIZED,
media::AudioParameters::UnavailableDeviceParams(), std::string()));
@@ -479,29 +494,33 @@ void AudioRendererHost::OnDeviceAuthorized(int stream_id,
audio_manager_->GetTaskRunner(), FROM_HERE,
base::Bind(&GetDefaultDeviceInfoOnDeviceThread, audio_manager_),
base::Bind(&AudioRendererHost::OnDeviceIDTranslated, this, stream_id,
- true));
+ auth_start_time, true));
} else {
media_stream_manager_->audio_output_device_enumerator()->Enumerate(
base::Bind(&AudioRendererHost::TranslateDeviceID, this, device_id,
security_origin,
base::Bind(&AudioRendererHost::OnDeviceIDTranslated, this,
- stream_id)));
+ stream_id, auth_start_time)));
}
}
void AudioRendererHost::OnDeviceIDTranslated(
int stream_id,
+ base::TimeTicks auth_start_time,
bool device_found,
const AudioOutputDeviceInfo& device_info) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
const auto& auth_data = authorizations_.find(stream_id);
// A close request was received while translation was in progress
- if (auth_data == authorizations_.end())
+ if (auth_data == authorizations_.end()) {
+ UMALogDeviceAuthorizationTime(auth_start_time);
return;
+ }
if (!device_found) {
authorizations_.erase(auth_data);
+ UMALogDeviceAuthorizationTime(auth_start_time);
Send(new AudioMsg_NotifyDeviceAuthorized(
stream_id, media::OUTPUT_DEVICE_STATUS_ERROR_NOT_FOUND,
media::AudioParameters::UnavailableDeviceParams(), std::string()));
@@ -513,6 +532,7 @@ void AudioRendererHost::OnDeviceIDTranslated(
media::AudioParameters output_params = device_info.output_params;
MaybeFixAudioParameters(&output_params);
+ UMALogDeviceAuthorizationTime(auth_start_time);
Send(new AudioMsg_NotifyDeviceAuthorized(
stream_id, media::OUTPUT_DEVICE_STATUS_OK, output_params, std::string()));
}
« no previous file with comments | « content/browser/renderer_host/media/audio_renderer_host.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698