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

Side by Side Diff: content/browser/renderer_host/media/audio_output_device_enumerator.cc

Issue 1505353007: Disable enumeration caching for output devices. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 unified diff | Download patch
OLDNEW
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 } 84 }
85 85
86 void AudioOutputDeviceEnumerator::SetCachePolicy(CachePolicy policy) { 86 void AudioOutputDeviceEnumerator::SetCachePolicy(CachePolicy policy) {
87 DCHECK(thread_checker_.CalledOnValidThread()); 87 DCHECK(thread_checker_.CalledOnValidThread());
88 if (policy == CACHE_POLICY_NO_CACHING) 88 if (policy == CACHE_POLICY_NO_CACHING)
89 InvalidateCache(); 89 InvalidateCache();
90 90
91 cache_policy_ = policy; 91 cache_policy_ = policy;
92 } 92 }
93 93
94 bool AudioOutputDeviceEnumerator::IsCacheEnabled() {
95 DCHECK(thread_checker_.CalledOnValidThread());
96 return cache_policy_ != CACHE_POLICY_NO_CACHING;
97 }
98
94 void AudioOutputDeviceEnumerator::DoEnumerateDevices() { 99 void AudioOutputDeviceEnumerator::DoEnumerateDevices() {
95 DCHECK(thread_checker_.CalledOnValidThread()); 100 DCHECK(thread_checker_.CalledOnValidThread());
96 is_enumeration_ongoing_ = true; 101 is_enumeration_ongoing_ = true;
97 seq_last_enumeration_ = NewEventSequence(); 102 seq_last_enumeration_ = NewEventSequence();
98 base::PostTaskAndReplyWithResult( 103 base::PostTaskAndReplyWithResult(
99 audio_manager_->GetWorkerTaskRunner().get(), FROM_HERE, 104 audio_manager_->GetWorkerTaskRunner().get(), FROM_HERE,
100 base::Bind(&EnumerateDevicesOnDeviceThread, audio_manager_), 105 base::Bind(&EnumerateDevicesOnDeviceThread, audio_manager_),
101 base::Bind(&AudioOutputDeviceEnumerator::DevicesEnumerated, 106 base::Bind(&AudioOutputDeviceEnumerator::DevicesEnumerated,
102 weak_factory_.GetWeakPtr())); 107 weak_factory_.GetWeakPtr()));
103 } 108 }
(...skipping 21 matching lines...) Expand all
125 return ++current_event_sequence_; 130 return ++current_event_sequence_;
126 } 131 }
127 132
128 bool AudioOutputDeviceEnumerator::IsLastEnumerationValid() const { 133 bool AudioOutputDeviceEnumerator::IsLastEnumerationValid() const {
129 DCHECK(thread_checker_.CalledOnValidThread()); 134 DCHECK(thread_checker_.CalledOnValidThread());
130 return seq_last_enumeration_ > seq_last_invalidation_ && 135 return seq_last_enumeration_ > seq_last_invalidation_ &&
131 !is_enumeration_ongoing_; 136 !is_enumeration_ongoing_;
132 } 137 }
133 138
134 } // namespace content 139 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698