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

Side by Side Diff: chrome/browser/extensions/api/webrtc_audio_private/webrtc_audio_private_api.h

Issue 666153002: Standardize usage of virtual/override/final in chrome/browser/extensions/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef CHROME_BROWSER_EXTENSIONS_API_WEBRTC_AUDIO_PRIVATE_WEBRTC_AUDIO_PRIVATE_ API_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_WEBRTC_AUDIO_PRIVATE_WEBRTC_AUDIO_PRIVATE_ API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_WEBRTC_AUDIO_PRIVATE_WEBRTC_AUDIO_PRIVATE_ API_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_WEBRTC_AUDIO_PRIVATE_WEBRTC_AUDIO_PRIVATE_ API_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/system_monitor/system_monitor.h" 9 #include "base/system_monitor/system_monitor.h"
10 #include "chrome/browser/extensions/chrome_extension_function.h" 10 #include "chrome/browser/extensions/chrome_extension_function.h"
11 #include "chrome/common/extensions/api/webrtc_audio_private.h" 11 #include "chrome/common/extensions/api/webrtc_audio_private.h"
12 #include "content/public/browser/render_view_host.h" 12 #include "content/public/browser/render_view_host.h"
13 #include "extensions/browser/browser_context_keyed_api_factory.h" 13 #include "extensions/browser/browser_context_keyed_api_factory.h"
14 #include "media/audio/audio_device_name.h" 14 #include "media/audio/audio_device_name.h"
15 #include "url/gurl.h" 15 #include "url/gurl.h"
16 16
17 namespace content { 17 namespace content {
18 class ResourceContext; 18 class ResourceContext;
19 } 19 }
20 20
21 namespace extensions { 21 namespace extensions {
22 22
23 // Listens for device changes and forwards as an extension event. 23 // Listens for device changes and forwards as an extension event.
24 class WebrtcAudioPrivateEventService 24 class WebrtcAudioPrivateEventService
25 : public BrowserContextKeyedAPI, 25 : public BrowserContextKeyedAPI,
26 public base::SystemMonitor::DevicesChangedObserver { 26 public base::SystemMonitor::DevicesChangedObserver {
27 public: 27 public:
28 explicit WebrtcAudioPrivateEventService(content::BrowserContext* context); 28 explicit WebrtcAudioPrivateEventService(content::BrowserContext* context);
29 virtual ~WebrtcAudioPrivateEventService(); 29 ~WebrtcAudioPrivateEventService() override;
30 30
31 // BrowserContextKeyedAPI implementation. 31 // BrowserContextKeyedAPI implementation.
32 virtual void Shutdown() override; 32 void Shutdown() override;
33 static BrowserContextKeyedAPIFactory<WebrtcAudioPrivateEventService>* 33 static BrowserContextKeyedAPIFactory<WebrtcAudioPrivateEventService>*
34 GetFactoryInstance(); 34 GetFactoryInstance();
35 static const char* service_name(); 35 static const char* service_name();
36 36
37 // base::SystemMonitor::DevicesChangedObserver implementation. 37 // base::SystemMonitor::DevicesChangedObserver implementation.
38 virtual void OnDevicesChanged( 38 void OnDevicesChanged(base::SystemMonitor::DeviceType device_type) override;
39 base::SystemMonitor::DeviceType device_type) override;
40 39
41 private: 40 private:
42 friend class BrowserContextKeyedAPIFactory<WebrtcAudioPrivateEventService>; 41 friend class BrowserContextKeyedAPIFactory<WebrtcAudioPrivateEventService>;
43 42
44 void SignalEvent(); 43 void SignalEvent();
45 44
46 content::BrowserContext* browser_context_; 45 content::BrowserContext* browser_context_;
47 }; 46 };
48 47
49 // Common base for WebrtcAudioPrivate functions, that provides a 48 // Common base for WebrtcAudioPrivate functions, that provides a
50 // couple of optionally-used common implementations. 49 // couple of optionally-used common implementations.
51 class WebrtcAudioPrivateFunction : public ChromeAsyncExtensionFunction { 50 class WebrtcAudioPrivateFunction : public ChromeAsyncExtensionFunction {
52 protected: 51 protected:
53 WebrtcAudioPrivateFunction(); 52 WebrtcAudioPrivateFunction();
54 virtual ~WebrtcAudioPrivateFunction(); 53 ~WebrtcAudioPrivateFunction() override;
55 54
56 protected: 55 protected:
57 // Retrieves the list of output device names on the appropriate 56 // Retrieves the list of output device names on the appropriate
58 // thread. Call from UI thread, callback will occur on IO thread. 57 // thread. Call from UI thread, callback will occur on IO thread.
59 void GetOutputDeviceNames(); 58 void GetOutputDeviceNames();
60 59
61 // Must override this if you call GetOutputDeviceNames. Called on IO thread. 60 // Must override this if you call GetOutputDeviceNames. Called on IO thread.
62 virtual void OnOutputDeviceNames( 61 virtual void OnOutputDeviceNames(
63 scoped_ptr<media::AudioDeviceNames> device_names); 62 scoped_ptr<media::AudioDeviceNames> device_names);
64 63
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 content::ResourceContext* resource_context() const; 100 content::ResourceContext* resource_context() const;
102 101
103 private: 102 private:
104 content::ResourceContext* resource_context_; 103 content::ResourceContext* resource_context_;
105 104
106 DISALLOW_COPY_AND_ASSIGN(WebrtcAudioPrivateFunction); 105 DISALLOW_COPY_AND_ASSIGN(WebrtcAudioPrivateFunction);
107 }; 106 };
108 107
109 class WebrtcAudioPrivateGetSinksFunction : public WebrtcAudioPrivateFunction { 108 class WebrtcAudioPrivateGetSinksFunction : public WebrtcAudioPrivateFunction {
110 protected: 109 protected:
111 virtual ~WebrtcAudioPrivateGetSinksFunction() {} 110 ~WebrtcAudioPrivateGetSinksFunction() override {}
112 111
113 private: 112 private:
114 DECLARE_EXTENSION_FUNCTION("webrtcAudioPrivate.getSinks", 113 DECLARE_EXTENSION_FUNCTION("webrtcAudioPrivate.getSinks",
115 WEBRTC_AUDIO_PRIVATE_GET_SINKS); 114 WEBRTC_AUDIO_PRIVATE_GET_SINKS);
116 115
117 // Sequence of events is that we query the list of sinks on the 116 // Sequence of events is that we query the list of sinks on the
118 // AudioManager's thread, then calculate HMACs on the IO thread, 117 // AudioManager's thread, then calculate HMACs on the IO thread,
119 // then finish on the UI thread. 118 // then finish on the UI thread.
120 virtual bool RunAsync() override; 119 bool RunAsync() override;
121 void DoQuery(); 120 void DoQuery();
122 virtual void OnOutputDeviceNames( 121 void OnOutputDeviceNames(
123 scoped_ptr<media::AudioDeviceNames> raw_ids) override; 122 scoped_ptr<media::AudioDeviceNames> raw_ids) override;
124 void DoneOnUIThread(); 123 void DoneOnUIThread();
125 }; 124 };
126 125
127 class WebrtcAudioPrivateGetActiveSinkFunction 126 class WebrtcAudioPrivateGetActiveSinkFunction
128 : public WebrtcAudioPrivateFunction { 127 : public WebrtcAudioPrivateFunction {
129 protected: 128 protected:
130 virtual ~WebrtcAudioPrivateGetActiveSinkFunction() {} 129 ~WebrtcAudioPrivateGetActiveSinkFunction() override {}
131 130
132 private: 131 private:
133 DECLARE_EXTENSION_FUNCTION("webrtcAudioPrivate.getActiveSink", 132 DECLARE_EXTENSION_FUNCTION("webrtcAudioPrivate.getActiveSink",
134 WEBRTC_AUDIO_PRIVATE_GET_ACTIVE_SINK); 133 WEBRTC_AUDIO_PRIVATE_GET_ACTIVE_SINK);
135 134
136 virtual bool RunAsync() override; 135 bool RunAsync() override;
137 virtual void OnControllerList( 136 void OnControllerList(
138 const content::RenderViewHost::AudioOutputControllerList& 137 const content::RenderViewHost::AudioOutputControllerList& controllers)
139 controllers) override; 138 override;
140 virtual void OnHMACCalculated(const std::string& hmac) override; 139 void OnHMACCalculated(const std::string& hmac) override;
141 }; 140 };
142 141
143 class WebrtcAudioPrivateSetActiveSinkFunction 142 class WebrtcAudioPrivateSetActiveSinkFunction
144 : public WebrtcAudioPrivateFunction { 143 : public WebrtcAudioPrivateFunction {
145 public: 144 public:
146 WebrtcAudioPrivateSetActiveSinkFunction(); 145 WebrtcAudioPrivateSetActiveSinkFunction();
147 146
148 protected: 147 protected:
149 virtual ~WebrtcAudioPrivateSetActiveSinkFunction(); 148 ~WebrtcAudioPrivateSetActiveSinkFunction() override;
150 149
151 private: 150 private:
152 DECLARE_EXTENSION_FUNCTION("webrtcAudioPrivate.setActiveSink", 151 DECLARE_EXTENSION_FUNCTION("webrtcAudioPrivate.setActiveSink",
153 WEBRTC_AUDIO_PRIVATE_SET_ACTIVE_SINK); 152 WEBRTC_AUDIO_PRIVATE_SET_ACTIVE_SINK);
154 153
155 virtual bool RunAsync() override; 154 bool RunAsync() override;
156 virtual void OnControllerList( 155 void OnControllerList(
157 const content::RenderViewHost::AudioOutputControllerList& 156 const content::RenderViewHost::AudioOutputControllerList& controllers)
158 controllers) override; 157 override;
159 virtual void OnOutputDeviceNames( 158 void OnOutputDeviceNames(
160 scoped_ptr<media::AudioDeviceNames> device_names) override; 159 scoped_ptr<media::AudioDeviceNames> device_names) override;
161 void SwitchDone(); 160 void SwitchDone();
162 void DoneOnUIThread(); 161 void DoneOnUIThread();
163 162
164 int tab_id_; 163 int tab_id_;
165 std::string sink_id_; 164 std::string sink_id_;
166 165
167 // Filled in by OnControllerList. 166 // Filled in by OnControllerList.
168 content::RenderViewHost::AudioOutputControllerList controllers_; 167 content::RenderViewHost::AudioOutputControllerList controllers_;
169 168
170 // Number of sink IDs we are still waiting for. Can become greater 169 // Number of sink IDs we are still waiting for. Can become greater
171 // than 0 in OnControllerList, decreases on every OnSinkId call. 170 // than 0 in OnControllerList, decreases on every OnSinkId call.
172 size_t num_remaining_sink_ids_; 171 size_t num_remaining_sink_ids_;
173 }; 172 };
174 173
175 class WebrtcAudioPrivateGetAssociatedSinkFunction 174 class WebrtcAudioPrivateGetAssociatedSinkFunction
176 : public WebrtcAudioPrivateFunction { 175 : public WebrtcAudioPrivateFunction {
177 public: 176 public:
178 WebrtcAudioPrivateGetAssociatedSinkFunction(); 177 WebrtcAudioPrivateGetAssociatedSinkFunction();
179 178
180 protected: 179 protected:
181 virtual ~WebrtcAudioPrivateGetAssociatedSinkFunction(); 180 ~WebrtcAudioPrivateGetAssociatedSinkFunction() override;
182 181
183 private: 182 private:
184 DECLARE_EXTENSION_FUNCTION("webrtcAudioPrivate.getAssociatedSink", 183 DECLARE_EXTENSION_FUNCTION("webrtcAudioPrivate.getAssociatedSink",
185 WEBRTC_AUDIO_PRIVATE_GET_ASSOCIATED_SINK); 184 WEBRTC_AUDIO_PRIVATE_GET_ASSOCIATED_SINK);
186 185
187 virtual bool RunAsync() override; 186 bool RunAsync() override;
188 187
189 // This implementation is slightly complicated because of different 188 // This implementation is slightly complicated because of different
190 // thread requirements for the various functions we need to invoke. 189 // thread requirements for the various functions we need to invoke.
191 // 190 //
192 // Each worker function will post a task to the appropriate thread 191 // Each worker function will post a task to the appropriate thread
193 // for the next one. 192 // for the next one.
194 // 193 //
195 // The sequence of events is: 194 // The sequence of events is:
196 // 1. Get the list of source devices on the device thread. 195 // 1. Get the list of source devices on the device thread.
197 // 2. Given a source ID for an origin and that security origin, find 196 // 2. Given a source ID for an origin and that security origin, find
(...skipping 10 matching lines...) Expand all
208 void GetDevicesOnDeviceThread(); 207 void GetDevicesOnDeviceThread();
209 208
210 // Takes the parameters of the function, retrieves the raw source 209 // Takes the parameters of the function, retrieves the raw source
211 // device ID, or the empty string if none. 210 // device ID, or the empty string if none.
212 void GetRawSourceIDOnIOThread(); 211 void GetRawSourceIDOnIOThread();
213 212
214 // Gets the raw sink ID for a raw source ID. Sends it to |CalculateHMAC|. 213 // Gets the raw sink ID for a raw source ID. Sends it to |CalculateHMAC|.
215 void GetAssociatedSinkOnDeviceThread(const std::string& raw_source_id); 214 void GetAssociatedSinkOnDeviceThread(const std::string& raw_source_id);
216 215
217 // Receives the associated sink ID after its HMAC is calculated. 216 // Receives the associated sink ID after its HMAC is calculated.
218 virtual void OnHMACCalculated(const std::string& hmac) override; 217 void OnHMACCalculated(const std::string& hmac) override;
219 218
220 // Accessed from UI thread and device thread, but only on one at a 219 // Accessed from UI thread and device thread, but only on one at a
221 // time, no locking needed. 220 // time, no locking needed.
222 scoped_ptr<api::webrtc_audio_private::GetAssociatedSink::Params> params_; 221 scoped_ptr<api::webrtc_audio_private::GetAssociatedSink::Params> params_;
223 222
224 // Audio sources (input devices). Filled in by DoWorkOnDeviceThread. 223 // Audio sources (input devices). Filled in by DoWorkOnDeviceThread.
225 media::AudioDeviceNames source_devices_; 224 media::AudioDeviceNames source_devices_;
226 }; 225 };
227 226
228 } // namespace extensions 227 } // namespace extensions
229 228
230 #endif // CHROME_BROWSER_EXTENSIONS_API_WEBRTC_AUDIO_PRIVATE_WEBRTC_AUDIO_PRIVA TE_API_H_ 229 #endif // CHROME_BROWSER_EXTENSIONS_API_WEBRTC_AUDIO_PRIVATE_WEBRTC_AUDIO_PRIVA TE_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698