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

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

Issue 364123002: [Cross-Site Isolation] Migrate entire MediaStream verticals to be per-RenderFrame. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
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_MEDIA_DESKTOP_STREAMS_REGISTRY_H_ 5 #ifndef CHROME_BROWSER_MEDIA_DESKTOP_STREAMS_REGISTRY_H_
6 #define CHROME_BROWSER_MEDIA_DESKTOP_STREAMS_REGISTRY_H_ 6 #define CHROME_BROWSER_MEDIA_DESKTOP_STREAMS_REGISTRY_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "chrome/browser/media/desktop_media_list.h" 11 #include "chrome/browser/media/desktop_media_list.h"
12 #include "url/gurl.h" 12 #include "url/gurl.h"
13 13
14 namespace content {
15 class WebContents;
16 }
17
14 // DesktopStreamsRegistry is used to store accepted desktop media streams for 18 // DesktopStreamsRegistry is used to store accepted desktop media streams for
15 // Desktop Capture API. Single instance of this class is created per browser in 19 // Desktop Capture API. Single instance of this class is created per browser in
16 // MediaCaptureDevicesDispatcher. 20 // MediaCaptureDevicesDispatcher.
17 class DesktopStreamsRegistry { 21 class DesktopStreamsRegistry {
18 public: 22 public:
19 DesktopStreamsRegistry(); 23 DesktopStreamsRegistry();
20 ~DesktopStreamsRegistry(); 24 ~DesktopStreamsRegistry();
21 25
22 // Adds new stream to the registry. Called by the implementation of 26 // Adds new stream to the registry. Called by the implementation of
23 // desktopCapture.chooseDesktopMedia() API after user has approved access to 27 // desktopCapture.chooseDesktopMedia() API after user has approved access to
24 // |source| for the |origin|. Returns identifier of the new stream. 28 // |source| for the |origin|. Returns identifier of the new stream.
25 std::string RegisterStream(int render_process_id, 29 // Note: |web_contents| refers to the WebContents requesting the stream. The
26 int render_view_id, 30 // |web_contents| pointer is only used for verification, and will never be
31 // dereferenced.
32 std::string RegisterStream(const content::WebContents* web_contents,
ncarter (slow) 2014/07/10 01:17:51 My expectation of which types to use where goes so
27 const GURL& origin, 33 const GURL& origin,
28 const content::DesktopMediaID& source, 34 const content::DesktopMediaID& source,
29 const std::string& extension_name); 35 const std::string& extension_name);
30 36
31 // Validates stream identifier specified in getUserMedia(). Returns null 37 // Validates stream identifier specified in getUserMedia(). Returns null
32 // DesktopMediaID if the specified |id| is invalid, i.e. wasn't generated 38 // DesktopMediaID if the specified |id| is invalid, i.e. wasn't generated
33 // using RegisterStream() or if it was generated for a different origin. 39 // using RegisterStream() or if it was generated for a different
34 // Otherwise returns ID of the source and removes it from the registry. 40 // web_contents/origin. Otherwise returns ID of the source and removes it from
35 content::DesktopMediaID RequestMediaForStreamId(const std::string& id, 41 // the registry.
36 int render_process_id, 42 content::DesktopMediaID RequestMediaForStreamId(
37 int render_view_id, 43 const std::string& id,
38 const GURL& origin, 44 const content::WebContents* web_contents,
39 std::string* extension_name); 45 const GURL& origin,
46 std::string* extension_name);
40 47
41 private: 48 private:
42 // Type used to store list of accepted desktop media streams. 49 // Type used to store list of accepted desktop media streams.
43 struct ApprovedDesktopMediaStream { 50 struct ApprovedDesktopMediaStream {
44 ApprovedDesktopMediaStream(); 51 ApprovedDesktopMediaStream();
45 52
46 int render_process_id; 53 const content::WebContents* web_contents; // Never dereference this!
ncarter (slow) 2014/07/10 01:17:51 Because of the possibility of address reuse, point
miu 2014/07/10 22:16:12 Good insight. Fixed.
47 int render_view_id;
48 GURL origin; 54 GURL origin;
49 content::DesktopMediaID source; 55 content::DesktopMediaID source;
50 std::string extension_name; 56 std::string extension_name;
51 }; 57 };
52 typedef std::map<std::string, ApprovedDesktopMediaStream> StreamsMap; 58 typedef std::map<std::string, ApprovedDesktopMediaStream> StreamsMap;
53 59
54 // Helper function that removes an expired stream from the registry. 60 // Helper function that removes an expired stream from the registry.
55 void CleanupStream(const std::string& id); 61 void CleanupStream(const std::string& id);
56 62
57 StreamsMap approved_streams_; 63 StreamsMap approved_streams_;
58 64
59 DISALLOW_COPY_AND_ASSIGN(DesktopStreamsRegistry); 65 DISALLOW_COPY_AND_ASSIGN(DesktopStreamsRegistry);
60 }; 66 };
61 67
62 #endif // CHROME_BROWSER_MEDIA_DESKTOP_STREAMS_REGISTRY_H_ 68 #endif // CHROME_BROWSER_MEDIA_DESKTOP_STREAMS_REGISTRY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698