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

Side by Side Diff: chrome/browser/media/media_capture_devices_dispatcher.h

Issue 1095393004: Refactor: Make MediaCaptureDevicesDispatcher have pluggable handlers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_ 5 #ifndef CHROME_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_
6 #define CHROME_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_ 6 #define CHROME_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <list> 9 #include <list>
10 #include <map> 10 #include <map>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/singleton.h" 14 #include "base/memory/singleton.h"
15 #include "base/observer_list.h" 15 #include "base/observer_list.h"
16 #include "chrome/browser/media/media_access_handler.h"
16 #include "content/public/browser/media_observer.h" 17 #include "content/public/browser/media_observer.h"
17 #include "content/public/browser/notification_observer.h" 18 #include "content/public/browser/notification_observer.h"
18 #include "content/public/browser/notification_registrar.h" 19 #include "content/public/browser/notification_registrar.h"
19 #include "content/public/browser/web_contents_delegate.h" 20 #include "content/public/browser/web_contents_delegate.h"
20 #include "content/public/common/media_stream_request.h" 21 #include "content/public/common/media_stream_request.h"
21 22
22 class DesktopStreamsRegistry; 23 class DesktopStreamsRegistry;
23 class MediaStreamCaptureIndicator; 24 class MediaStreamCaptureIndicator;
24 class Profile; 25 class Profile;
25 26
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 150
150 bool IsDesktopCaptureInProgress(); 151 bool IsDesktopCaptureInProgress();
151 152
152 // Only for testing. 153 // Only for testing.
153 void SetTestAudioCaptureDevices(const content::MediaStreamDevices& devices); 154 void SetTestAudioCaptureDevices(const content::MediaStreamDevices& devices);
154 void SetTestVideoCaptureDevices(const content::MediaStreamDevices& devices); 155 void SetTestVideoCaptureDevices(const content::MediaStreamDevices& devices);
155 156
156 private: 157 private:
157 friend struct DefaultSingletonTraits<MediaCaptureDevicesDispatcher>; 158 friend struct DefaultSingletonTraits<MediaCaptureDevicesDispatcher>;
158 159
159 struct PendingAccessRequest {
160 PendingAccessRequest(const content::MediaStreamRequest& request,
161 const content::MediaResponseCallback& callback);
162 ~PendingAccessRequest();
163
164 // TODO(gbillock): make the MediaStreamDevicesController owned by
165 // this object when we're using bubbles.
166 content::MediaStreamRequest request;
167 content::MediaResponseCallback callback;
168 };
169 typedef std::deque<PendingAccessRequest> RequestsQueue;
170 typedef std::map<content::WebContents*, RequestsQueue> RequestsQueues;
171
172 MediaCaptureDevicesDispatcher(); 160 MediaCaptureDevicesDispatcher();
173 ~MediaCaptureDevicesDispatcher() override; 161 ~MediaCaptureDevicesDispatcher() override;
174 162
175 // content::NotificationObserver implementation. 163 // content::NotificationObserver implementation.
176 void Observe(int type, 164 void Observe(int type,
177 const content::NotificationSource& source, 165 const content::NotificationSource& source,
178 const content::NotificationDetails& details) override; 166 const content::NotificationDetails& details) override;
179 167
180 // Helpers for ProcessMediaAccessRequest().
181 void ProcessDesktopCaptureAccessRequest(
182 content::WebContents* web_contents,
183 const content::MediaStreamRequest& request,
184 const content::MediaResponseCallback& callback,
185 const extensions::Extension* extension);
186 void ProcessScreenCaptureAccessRequest(
187 content::WebContents* web_contents,
188 const content::MediaStreamRequest& request,
189 const content::MediaResponseCallback& callback,
190 const extensions::Extension* extension);
191 void ProcessTabCaptureAccessRequest(
192 content::WebContents* web_contents,
193 const content::MediaStreamRequest& request,
194 const content::MediaResponseCallback& callback,
195 const extensions::Extension* extension);
196 #if defined(ENABLE_EXTENSIONS)
197 void ProcessMediaAccessRequestFromPlatformAppOrExtension(
198 content::WebContents* web_contents,
199 const content::MediaStreamRequest& request,
200 const content::MediaResponseCallback& callback,
201 const extensions::Extension* extension);
202 #endif
203 void ProcessRegularMediaAccessRequest(
204 content::WebContents* web_contents,
205 const content::MediaStreamRequest& request,
206 const content::MediaResponseCallback& callback);
207 void ProcessQueuedAccessRequest(content::WebContents* web_contents);
208 void OnAccessRequestResponse(content::WebContents* web_contents,
209 const content::MediaStreamDevices& devices,
210 content::MediaStreamRequestResult result,
211 scoped_ptr<content::MediaStreamUI> ui);
212
213 // Called by the MediaObserver() functions, executed on UI thread. 168 // Called by the MediaObserver() functions, executed on UI thread.
214 void NotifyAudioDevicesChangedOnUIThread(); 169 void NotifyAudioDevicesChangedOnUIThread();
215 void NotifyVideoDevicesChangedOnUIThread(); 170 void NotifyVideoDevicesChangedOnUIThread();
216 void UpdateMediaRequestStateOnUIThread( 171 void UpdateMediaRequestStateOnUIThread(
217 int render_process_id, 172 int render_process_id,
218 int render_frame_id, 173 int render_frame_id,
219 int page_request_id, 174 int page_request_id,
220 const GURL& security_origin, 175 const GURL& security_origin,
221 content::MediaStreamType stream_type, 176 content::MediaStreamType stream_type,
222 content::MediaRequestState state); 177 content::MediaRequestState state);
(...skipping 24 matching lines...) Expand all
247 // MEDIA_REQUEST_STATE_DONE state. Sessions are remove when 202 // MEDIA_REQUEST_STATE_DONE state. Sessions are remove when
248 // MEDIA_REQUEST_STATE_CLOSING is encountered. 203 // MEDIA_REQUEST_STATE_CLOSING is encountered.
249 struct DesktopCaptureSession { 204 struct DesktopCaptureSession {
250 int render_process_id; 205 int render_process_id;
251 int render_frame_id; 206 int render_frame_id;
252 int page_request_id; 207 int page_request_id;
253 }; 208 };
254 typedef std::list<DesktopCaptureSession> DesktopCaptureSessions; 209 typedef std::list<DesktopCaptureSession> DesktopCaptureSessions;
255 DesktopCaptureSessions desktop_capture_sessions_; 210 DesktopCaptureSessions desktop_capture_sessions_;
256 211
212 // Handler for processing media access request.
213 scoped_ptr<MediaAccessHandler> media_access_handler_;
214
257 DISALLOW_COPY_AND_ASSIGN(MediaCaptureDevicesDispatcher); 215 DISALLOW_COPY_AND_ASSIGN(MediaCaptureDevicesDispatcher);
258 }; 216 };
259 217
260 #endif // CHROME_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_ 218 #endif // CHROME_BROWSER_MEDIA_MEDIA_CAPTURE_DEVICES_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698