+class BeepContext {
+ public:
+ BeepContext() : beep_once_(false), automatic_beep_(true) {}
+
+ void SetBeepOnce(bool enable) {
+ base::AutoLock auto_lock(lock_);
+ beep_once_ = enable;
+
+ // Disable the automatic beep if users explicit set |beep_once_| to true.
+ if (enable)
+ automatic_beep_ = false;
+ }
+ bool beep_once() const {
+ base::AutoLock auto_lock(lock_);
+ return beep_once_;
+ }
+ bool automatic_beep() const {
+ base::AutoLock auto_lock(lock_);
+ return automatic_beep_;
+ }
+
+ private:
+ mutable base::Lock lock_;
+ bool beep_once_;
+ bool automatic_beep_;