| 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/browser/renderer_host/media/audio_renderer_host.h" | 5 #include "content/browser/renderer_host/media/audio_renderer_host.h" | 
| 6 | 6 | 
| 7 #include <stdint.h> | 7 #include <stdint.h> | 
| 8 | 8 | 
| 9 #include "base/bind.h" | 9 #include "base/bind.h" | 
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
| 28 #include "media/base/audio_bus.h" | 28 #include "media/base/audio_bus.h" | 
| 29 #include "media/base/limits.h" | 29 #include "media/base/limits.h" | 
| 30 | 30 | 
| 31 using media::AudioBus; | 31 using media::AudioBus; | 
| 32 using media::AudioManager; | 32 using media::AudioManager; | 
| 33 | 33 | 
| 34 namespace content { | 34 namespace content { | 
| 35 | 35 | 
| 36 namespace { | 36 namespace { | 
| 37 | 37 | 
| 38 void UMALogDeviceAuthorizationTime(base::TimeTicks auth_start_time) { | 38 void UMALogAudioDeviceAuthorizationTime(base::TimeTicks auth_start_time) { | 
| 39   UMA_HISTOGRAM_CUSTOM_TIMES("Media.Audio.OutputDeviceAuthorizationTime", | 39   UMA_HISTOGRAM_CUSTOM_TIMES("Media.Audio.OutputDeviceAuthorizationTime", | 
| 40                              base::TimeTicks::Now() - auth_start_time, | 40                              base::TimeTicks::Now() - auth_start_time, | 
| 41                              base::TimeDelta::FromMilliseconds(1), | 41                              base::TimeDelta::FromMilliseconds(1), | 
| 42                              base::TimeDelta::FromMilliseconds(5000), 50); | 42                              base::TimeDelta::FromMilliseconds(5000), 50); | 
| 43 } | 43 } | 
| 44 | 44 | 
| 45 // Check that the routing ID references a valid RenderFrameHost, and run | 45 // Check that the routing ID references a valid RenderFrameHost, and run | 
| 46 // |callback| on the IO thread with true if the ID is valid. | 46 // |callback| on the IO thread with true if the ID is valid. | 
| 47 void ValidateRenderFrameId(int render_process_id, | 47 void ValidateRenderFrameId(int render_process_id, | 
| 48                            int render_frame_id, | 48                            int render_frame_id, | 
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 194 | 194 | 
| 195 void AudioRendererHost::AuthorizationCompleted( | 195 void AudioRendererHost::AuthorizationCompleted( | 
| 196     int stream_id, | 196     int stream_id, | 
| 197     base::TimeTicks auth_start_time, | 197     base::TimeTicks auth_start_time, | 
| 198     media::OutputDeviceStatus status, | 198     media::OutputDeviceStatus status, | 
| 199     const media::AudioParameters& params, | 199     const media::AudioParameters& params, | 
| 200     const std::string& raw_device_id, | 200     const std::string& raw_device_id, | 
| 201     const std::string& device_id_for_renderer) { | 201     const std::string& device_id_for_renderer) { | 
| 202   DCHECK_CURRENTLY_ON(BrowserThread::IO); | 202   DCHECK_CURRENTLY_ON(BrowserThread::IO); | 
| 203 | 203 | 
| 204   UMALogDeviceAuthorizationTime(auth_start_time); | 204   UMALogAudioDeviceAuthorizationTime(auth_start_time); | 
| 205 | 205 | 
| 206   auto auth_data = authorizations_.find(stream_id); | 206   auto auth_data = authorizations_.find(stream_id); | 
| 207   if (auth_data == authorizations_.end()) | 207   if (auth_data == authorizations_.end()) | 
| 208     return;  // Stream was closed before finishing authorization | 208     return;  // Stream was closed before finishing authorization | 
| 209 | 209 | 
| 210   if (status == media::OUTPUT_DEVICE_STATUS_OK) { | 210   if (status == media::OUTPUT_DEVICE_STATUS_OK) { | 
| 211     auth_data->second.first = true; | 211     auth_data->second.first = true; | 
| 212     auth_data->second.second = raw_device_id; | 212     auth_data->second.second = raw_device_id; | 
| 213     Send(new AudioMsg_NotifyDeviceAuthorized(stream_id, status, params, | 213     Send(new AudioMsg_NotifyDeviceAuthorized(stream_id, status, params, | 
| 214                                              device_id_for_renderer)); | 214                                              device_id_for_renderer)); | 
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 371 | 371 | 
| 372 bool AudioRendererHost::IsAuthorizationStarted(int stream_id) { | 372 bool AudioRendererHost::IsAuthorizationStarted(int stream_id) { | 
| 373   DCHECK_CURRENTLY_ON(BrowserThread::IO); | 373   DCHECK_CURRENTLY_ON(BrowserThread::IO); | 
| 374   return authorizations_.find(stream_id) != authorizations_.end(); | 374   return authorizations_.find(stream_id) != authorizations_.end(); | 
| 375 } | 375 } | 
| 376 | 376 | 
| 377 void AudioRendererHost::OverrideDevicePermissionsForTesting(bool has_access) { | 377 void AudioRendererHost::OverrideDevicePermissionsForTesting(bool has_access) { | 
| 378   authorization_handler_.OverridePermissionsForTesting(has_access); | 378   authorization_handler_.OverridePermissionsForTesting(has_access); | 
| 379 } | 379 } | 
| 380 }  // namespace content | 380 }  // namespace content | 
| OLD | NEW | 
|---|