| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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_output_device_enumerator.h" | 5 #include "content/browser/renderer_host/media/audio_output_device_enumerator.h" |
| 6 | 6 |
| 7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/task_runner_util.h" | 10 #include "base/task_runner_util.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 bool AudioOutputDeviceEnumerator::IsCacheEnabled() { | 110 bool AudioOutputDeviceEnumerator::IsCacheEnabled() { |
| 111 DCHECK(thread_checker_.CalledOnValidThread()); | 111 DCHECK(thread_checker_.CalledOnValidThread()); |
| 112 return cache_policy_ != CACHE_POLICY_NO_CACHING; | 112 return cache_policy_ != CACHE_POLICY_NO_CACHING; |
| 113 } | 113 } |
| 114 | 114 |
| 115 void AudioOutputDeviceEnumerator::DoEnumerateDevices() { | 115 void AudioOutputDeviceEnumerator::DoEnumerateDevices() { |
| 116 DCHECK(thread_checker_.CalledOnValidThread()); | 116 DCHECK(thread_checker_.CalledOnValidThread()); |
| 117 is_enumeration_ongoing_ = true; | 117 is_enumeration_ongoing_ = true; |
| 118 seq_last_enumeration_ = NewEventSequence(); | 118 seq_last_enumeration_ = NewEventSequence(); |
| 119 base::PostTaskAndReplyWithResult( | 119 base::PostTaskAndReplyWithResult( |
| 120 audio_manager_->GetTaskRunner().get(), FROM_HERE, | 120 audio_manager_->GetTaskRunner(), FROM_HERE, |
| 121 base::Bind(&EnumerateDevicesOnDeviceThread, audio_manager_), | 121 base::Bind(&EnumerateDevicesOnDeviceThread, audio_manager_), |
| 122 base::Bind(&AudioOutputDeviceEnumerator::DevicesEnumerated, | 122 base::Bind(&AudioOutputDeviceEnumerator::DevicesEnumerated, |
| 123 weak_factory_.GetWeakPtr())); | 123 weak_factory_.GetWeakPtr())); |
| 124 } | 124 } |
| 125 | 125 |
| 126 void AudioOutputDeviceEnumerator::DevicesEnumerated( | 126 void AudioOutputDeviceEnumerator::DevicesEnumerated( |
| 127 const AudioOutputDeviceEnumeration& snapshot) { | 127 const AudioOutputDeviceEnumeration& snapshot) { |
| 128 DCHECK(thread_checker_.CalledOnValidThread()); | 128 DCHECK(thread_checker_.CalledOnValidThread()); |
| 129 is_enumeration_ongoing_ = false; | 129 is_enumeration_ongoing_ = false; |
| 130 if (IsLastEnumerationValid()) { | 130 if (IsLastEnumerationValid()) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 146 return ++current_event_sequence_; | 146 return ++current_event_sequence_; |
| 147 } | 147 } |
| 148 | 148 |
| 149 bool AudioOutputDeviceEnumerator::IsLastEnumerationValid() const { | 149 bool AudioOutputDeviceEnumerator::IsLastEnumerationValid() const { |
| 150 DCHECK(thread_checker_.CalledOnValidThread()); | 150 DCHECK(thread_checker_.CalledOnValidThread()); |
| 151 return seq_last_enumeration_ > seq_last_invalidation_ && | 151 return seq_last_enumeration_ > seq_last_invalidation_ && |
| 152 !is_enumeration_ongoing_; | 152 !is_enumeration_ongoing_; |
| 153 } | 153 } |
| 154 | 154 |
| 155 } // namespace content | 155 } // namespace content |
| OLD | NEW |