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

Side by Side Diff: chrome/browser/chromeos/audio_mixer_alsa.cc

Issue 8198007: Remove PrefService::ScheduleSavePersistentPrefs and SavePersistentPrefs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix chromeos Created 9 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/chromeos/audio_mixer_alsa.h" 5 #include "chrome/browser/chromeos/audio_mixer_alsa.h"
6 6
7 #include <unistd.h> 7 #include <unistd.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 base::AutoLock lock(lock_); 131 base::AutoLock lock(lock_);
132 if (isnan(volume_db)) { 132 if (isnan(volume_db)) {
133 LOG(WARNING) << "Got request to set volume to NaN"; 133 LOG(WARNING) << "Got request to set volume to NaN";
134 volume_db = min_volume_db_; 134 volume_db = min_volume_db_;
135 } else { 135 } else {
136 volume_db = min(max(volume_db, min_volume_db_), max_volume_db_); 136 volume_db = min(max(volume_db, min_volume_db_), max_volume_db_);
137 } 137 }
138 } 138 }
139 139
140 prefs_->SetDouble(prefs::kAudioVolume, volume_db); 140 prefs_->SetDouble(prefs::kAudioVolume, volume_db);
141 prefs_->ScheduleSavePersistentPrefs();
142 141
143 base::AutoLock lock(lock_); 142 base::AutoLock lock(lock_);
144 volume_db_ = volume_db; 143 volume_db_ = volume_db;
145 if (!apply_is_pending_) 144 if (!apply_is_pending_)
146 thread_->message_loop()->PostTask(FROM_HERE, 145 thread_->message_loop()->PostTask(FROM_HERE,
147 NewRunnableMethod(this, &AudioMixerAlsa::ApplyState)); 146 NewRunnableMethod(this, &AudioMixerAlsa::ApplyState));
148 } 147 }
149 148
150 bool AudioMixerAlsa::IsMuted() { 149 bool AudioMixerAlsa::IsMuted() {
151 base::AutoLock lock(lock_); 150 base::AutoLock lock(lock_);
152 return is_muted_; 151 return is_muted_;
153 } 152 }
154 153
155 void AudioMixerAlsa::SetMuted(bool muted) { 154 void AudioMixerAlsa::SetMuted(bool muted) {
156 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 155 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
157 prefs_->SetInteger(prefs::kAudioMute, muted ? kPrefMuteOn : kPrefMuteOff); 156 prefs_->SetInteger(prefs::kAudioMute, muted ? kPrefMuteOn : kPrefMuteOff);
158 prefs_->ScheduleSavePersistentPrefs();
159 base::AutoLock lock(lock_); 157 base::AutoLock lock(lock_);
160 is_muted_ = muted; 158 is_muted_ = muted;
161 if (!apply_is_pending_) 159 if (!apply_is_pending_)
162 thread_->message_loop()->PostTask(FROM_HERE, 160 thread_->message_loop()->PostTask(FROM_HERE,
163 NewRunnableMethod(this, &AudioMixerAlsa::ApplyState)); 161 NewRunnableMethod(this, &AudioMixerAlsa::ApplyState));
164 } 162 }
165 163
166 // static 164 // static
167 void AudioMixerAlsa::RegisterPrefs(PrefService* local_state) { 165 void AudioMixerAlsa::RegisterPrefs(PrefService* local_state) {
168 // TODO(derat): Store audio volume percent instead of decibels. 166 // TODO(derat): Store audio volume percent instead of decibels.
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 if (alsa_result != 0) { 437 if (alsa_result != 0) {
440 LOG(WARNING) << "snd_mixer_selem_set_playback_switch_all() failed: " 438 LOG(WARNING) << "snd_mixer_selem_set_playback_switch_all() failed: "
441 << snd_strerror(alsa_result); 439 << snd_strerror(alsa_result);
442 } else { 440 } else {
443 VLOG(1) << "Set playback switch " << snd_mixer_selem_get_name(element) 441 VLOG(1) << "Set playback switch " << snd_mixer_selem_get_name(element)
444 << " to " << mute; 442 << " to " << mute;
445 } 443 }
446 } 444 }
447 445
448 } // namespace chromeos 446 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698