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

Side by Side Diff: content/browser/media/capture/web_contents_audio_muter.cc

Issue 667943003: Standardize usage of virtual/override/final in content/browser/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/media/capture/web_contents_audio_muter.h" 5 #include "content/browser/media/capture/web_contents_audio_muter.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "content/browser/media/capture/audio_mirroring_manager.h" 9 #include "content/browser/media/capture/audio_mirroring_manager.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
(...skipping 15 matching lines...) Expand all
26 // TODO(miu): media::FakeAudioOutputStream does pretty much the same thing as 26 // TODO(miu): media::FakeAudioOutputStream does pretty much the same thing as
27 // this class, but requires construction/destruction via media::AudioManagerBase 27 // this class, but requires construction/destruction via media::AudioManagerBase
28 // on the audio thread. Once that's fixed, this class will no longer be needed. 28 // on the audio thread. Once that's fixed, this class will no longer be needed.
29 // http://crbug.com/416278 29 // http://crbug.com/416278
30 class AudioDiscarder : public media::AudioOutputStream { 30 class AudioDiscarder : public media::AudioOutputStream {
31 public: 31 public:
32 explicit AudioDiscarder(const media::AudioParameters& params) 32 explicit AudioDiscarder(const media::AudioParameters& params)
33 : consumer_(media::AudioManager::Get()->GetWorkerTaskRunner(), params) {} 33 : consumer_(media::AudioManager::Get()->GetWorkerTaskRunner(), params) {}
34 34
35 // AudioOutputStream implementation. 35 // AudioOutputStream implementation.
36 virtual bool Open() override { return true; } 36 bool Open() override { return true; }
37 virtual void Start(AudioSourceCallback* callback) override { 37 void Start(AudioSourceCallback* callback) override {
38 consumer_.Start(base::Bind(&AudioDiscarder::FetchAudioData, callback)); 38 consumer_.Start(base::Bind(&AudioDiscarder::FetchAudioData, callback));
39 } 39 }
40 virtual void Stop() override { consumer_.Stop(); } 40 void Stop() override { consumer_.Stop(); }
41 virtual void SetVolume(double volume) override {} 41 void SetVolume(double volume) override {}
42 virtual void GetVolume(double* volume) override { *volume = 0; } 42 void GetVolume(double* volume) override { *volume = 0; }
43 virtual void Close() override { delete this; } 43 void Close() override { delete this; }
44 44
45 private: 45 private:
46 virtual ~AudioDiscarder() {} 46 ~AudioDiscarder() override {}
47 47
48 static void FetchAudioData(AudioSourceCallback* callback, 48 static void FetchAudioData(AudioSourceCallback* callback,
49 media::AudioBus* audio_bus) { 49 media::AudioBus* audio_bus) {
50 callback->OnMoreData(audio_bus, 0); 50 callback->OnMoreData(audio_bus, 0);
51 } 51 }
52 52
53 // Calls FetchAudioData() at regular intervals and discards the data. 53 // Calls FetchAudioData() at regular intervals and discards the data.
54 media::FakeAudioConsumer consumer_; 54 media::FakeAudioConsumer consumer_;
55 55
56 DISALLOW_COPY_AND_ASSIGN(AudioDiscarder); 56 DISALLOW_COPY_AND_ASSIGN(AudioDiscarder);
57 }; 57 };
58 58
59 } // namespace 59 } // namespace
60 60
61 // A simple AudioMirroringManager::MirroringDestination implementation that 61 // A simple AudioMirroringManager::MirroringDestination implementation that
62 // identifies the audio streams rendered by a WebContents and provides 62 // identifies the audio streams rendered by a WebContents and provides
63 // AudioDiscarders to AudioMirroringManager. 63 // AudioDiscarders to AudioMirroringManager.
64 class WebContentsAudioMuter::MuteDestination 64 class WebContentsAudioMuter::MuteDestination
65 : public base::RefCountedThreadSafe<MuteDestination>, 65 : public base::RefCountedThreadSafe<MuteDestination>,
66 public AudioMirroringManager::MirroringDestination { 66 public AudioMirroringManager::MirroringDestination {
67 public: 67 public:
68 explicit MuteDestination(WebContents* web_contents) 68 explicit MuteDestination(WebContents* web_contents)
69 : web_contents_(web_contents) {} 69 : web_contents_(web_contents) {}
70 70
71 private: 71 private:
72 friend class base::RefCountedThreadSafe<MuteDestination>; 72 friend class base::RefCountedThreadSafe<MuteDestination>;
73 73
74 typedef AudioMirroringManager::SourceFrameRef SourceFrameRef; 74 typedef AudioMirroringManager::SourceFrameRef SourceFrameRef;
75 75
76 virtual ~MuteDestination() {} 76 ~MuteDestination() override {}
77 77
78 virtual void QueryForMatches( 78 void QueryForMatches(const std::set<SourceFrameRef>& candidates,
79 const std::set<SourceFrameRef>& candidates, 79 const MatchesCallback& results_callback) override {
80 const MatchesCallback& results_callback) override {
81 BrowserThread::PostTask( 80 BrowserThread::PostTask(
82 BrowserThread::UI, 81 BrowserThread::UI,
83 FROM_HERE, 82 FROM_HERE,
84 base::Bind(&MuteDestination::QueryForMatchesOnUIThread, 83 base::Bind(&MuteDestination::QueryForMatchesOnUIThread,
85 this, 84 this,
86 candidates, 85 candidates,
87 media::BindToCurrentLoop(results_callback))); 86 media::BindToCurrentLoop(results_callback)));
88 } 87 }
89 88
90 void QueryForMatchesOnUIThread(const std::set<SourceFrameRef>& candidates, 89 void QueryForMatchesOnUIThread(const std::set<SourceFrameRef>& candidates,
91 const MatchesCallback& results_callback) { 90 const MatchesCallback& results_callback) {
92 DCHECK_CURRENTLY_ON(BrowserThread::UI); 91 DCHECK_CURRENTLY_ON(BrowserThread::UI);
93 std::set<SourceFrameRef> matches; 92 std::set<SourceFrameRef> matches;
94 // Add each ID to |matches| if it maps to a RenderFrameHost that maps to the 93 // Add each ID to |matches| if it maps to a RenderFrameHost that maps to the
95 // WebContents being muted. 94 // WebContents being muted.
96 for (std::set<SourceFrameRef>::const_iterator i = candidates.begin(); 95 for (std::set<SourceFrameRef>::const_iterator i = candidates.begin();
97 i != candidates.end(); ++i) { 96 i != candidates.end(); ++i) {
98 WebContents* const contents_containing_frame = 97 WebContents* const contents_containing_frame =
99 WebContents::FromRenderFrameHost( 98 WebContents::FromRenderFrameHost(
100 RenderFrameHost::FromID(i->first, i->second)); 99 RenderFrameHost::FromID(i->first, i->second));
101 if (contents_containing_frame == web_contents_) 100 if (contents_containing_frame == web_contents_)
102 matches.insert(*i); 101 matches.insert(*i);
103 } 102 }
104 results_callback.Run(matches); 103 results_callback.Run(matches);
105 } 104 }
106 105
107 virtual media::AudioOutputStream* AddInput( 106 media::AudioOutputStream* AddInput(
108 const media::AudioParameters& params) override { 107 const media::AudioParameters& params) override {
109 return new AudioDiscarder(params); 108 return new AudioDiscarder(params);
110 } 109 }
111 110
112 WebContents* const web_contents_; 111 WebContents* const web_contents_;
113 112
114 DISALLOW_COPY_AND_ASSIGN(MuteDestination); 113 DISALLOW_COPY_AND_ASSIGN(MuteDestination);
115 }; 114 };
116 115
117 WebContentsAudioMuter::WebContentsAudioMuter(WebContents* web_contents) 116 WebContentsAudioMuter::WebContentsAudioMuter(WebContents* web_contents)
(...skipping 26 matching lines...) Expand all
144 is_muting_ = false; 143 is_muting_ = false;
145 BrowserThread::PostTask( 144 BrowserThread::PostTask(
146 BrowserThread::IO, 145 BrowserThread::IO,
147 FROM_HERE, 146 FROM_HERE,
148 base::Bind(&AudioMirroringManager::StopMirroring, 147 base::Bind(&AudioMirroringManager::StopMirroring,
149 base::Unretained(AudioMirroringManager::GetInstance()), 148 base::Unretained(AudioMirroringManager::GetInstance()),
150 destination_)); 149 destination_));
151 } 150 }
152 151
153 } // namespace content 152 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/media/capture/web_contents_audio_input_stream.cc ('k') | content/browser/media/capture/web_contents_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698