| 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 base::TimeTicks auth_start_time, | 199 base::TimeTicks auth_start_time, |
| 200 media::OutputDeviceStatus status, | 200 media::OutputDeviceStatus status, |
| 201 const media::AudioParameters& params, | 201 const media::AudioParameters& params, |
| 202 const std::string& raw_device_id, | 202 const std::string& raw_device_id, |
| 203 const std::string& device_id_for_renderer) { | 203 const std::string& device_id_for_renderer) { |
| 204 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 204 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 205 auto auth_data = authorizations_.find(stream_id); | 205 auto auth_data = authorizations_.find(stream_id); |
| 206 if (auth_data == authorizations_.end()) | 206 if (auth_data == authorizations_.end()) |
| 207 return; // Stream was closed before finishing authorization | 207 return; // Stream was closed before finishing authorization |
| 208 | 208 |
| 209 UMALogDeviceAuthorizationTime(auth_start_time); | 209 UMALogAudioDeviceAuthorizationTime(auth_start_time); |
| 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)); |
| 215 } else { | 215 } else { |
| 216 authorizations_.erase(auth_data); | 216 authorizations_.erase(auth_data); |
| 217 Send(new AudioMsg_NotifyDeviceAuthorized( | 217 Send(new AudioMsg_NotifyDeviceAuthorized( |
| 218 stream_id, status, media::AudioParameters::UnavailableDeviceParams(), | 218 stream_id, status, media::AudioParameters::UnavailableDeviceParams(), |
| 219 std::string())); | 219 std::string())); |
| (...skipping 151 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 |