1 // Copyright 2018 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "content/browser/media/keyboard_mic_registration.h"
6 
7 #include "chromeos/audio/cras_audio_handler.h"
8 #include "content/public/browser/browser_thread.h"
9 
10 namespace content {
11 
12 KeyboardMicRegistration::KeyboardMicRegistration() = default;
13 
~KeyboardMicRegistration()14 KeyboardMicRegistration::~KeyboardMicRegistration() {
15   DCHECK_CURRENTLY_ON(BrowserThread::UI);
16   DCHECK_EQ(0, register_count_);
17 }
18 
Register()19 void KeyboardMicRegistration::Register() {
20   DCHECK_CURRENTLY_ON(BrowserThread::UI);
21   if (++register_count_ == 1)
22     chromeos::CrasAudioHandler::Get()->SetKeyboardMicActive(true);
23 }
24 
Deregister()25 void KeyboardMicRegistration::Deregister() {
26   DCHECK_CURRENTLY_ON(BrowserThread::UI);
27   if (--register_count_ == 0)
28     chromeos::CrasAudioHandler::Get()->SetKeyboardMicActive(false);
29 }
30 
31 }  // namespace content
32