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

Side by Side Diff: content/public/browser/desktop_media_id.h

Issue 1503563004: Desktop chrome tab capture-chooseDesktopMedia() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 CONTENT_PUBLIC_BROWSER_DESKTOP_MEDIA_ID_H_ 5 #ifndef CONTENT_PUBLIC_BROWSER_DESKTOP_MEDIA_ID_H_
6 #define CONTENT_PUBLIC_BROWSER_DESKTOP_MEDIA_ID_H_ 6 #define CONTENT_PUBLIC_BROWSER_DESKTOP_MEDIA_ID_H_
7 7
8 #include <string> 8 #include <string>
9 #include <tuple> 9 #include <tuple>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "content/common/content_export.h" 12 #include "content/common/content_export.h"
13 13
14 #if defined(USE_AURA) 14 #if defined(USE_AURA)
15 namespace aura { 15 namespace aura {
16 class Window; 16 class Window;
17 } // namespace aura 17 } // namespace aura
18 #endif // defined(USE_AURA) 18 #endif // defined(USE_AURA)
19 19
20 namespace content { 20 namespace content {
21 21
22 // Type used to identify desktop media sources. It's converted to string and 22 // Type used to identify desktop media sources. It's converted to string and
23 // stored in MediaStreamRequest::requested_video_device_id. 23 // stored in MediaStreamRequest::requested_video_device_id.
24 struct CONTENT_EXPORT DesktopMediaID { 24 struct CONTENT_EXPORT DesktopMediaID {
25 public: 25 public:
26 enum Type { 26 enum Type { TYPE_NONE, TYPE_SCREEN, TYPE_WINDOW, TYPE_TAB };
27 TYPE_NONE,
28 TYPE_SCREEN,
29 TYPE_WINDOW,
30 };
31 27
32 typedef intptr_t Id; 28 typedef intptr_t Id;
33 29
34 // Represents an "unset" value for either |id| or |aura_id|. 30 // Represents an "unset" value for either |id| or |aura_id|.
35 static const Id kNullId = 0; 31 static const Id kNullId = 0;
32 static const int kINVALIDID = -1;
qiangchen 2015/12/07 22:45:56 Any reason kNullId isn't sufficient to use?
miu 2015/12/08 01:54:38 style: kInvalidId
GeorgeZ 2015/12/09 19:36:38 This is to make the code safe. render_processor_id
GeorgeZ 2015/12/09 19:36:38 Done.
36 33
37 #if defined(USE_AURA) 34 #if defined(USE_AURA)
38 // Assigns integer identifier to the |window| and returns its DesktopMediaID. 35 // Assigns integer identifier to the |window| and returns its DesktopMediaID.
39 static DesktopMediaID RegisterAuraWindow(Type type, aura::Window* window); 36 static DesktopMediaID RegisterAuraWindow(Type type, aura::Window* window);
40 37
41 // Returns the Window that was previously registered using 38 // Returns the Window that was previously registered using
42 // RegisterAuraWindow(), else nullptr. 39 // RegisterAuraWindow(), else nullptr.
43 static aura::Window* GetAuraWindowById(const DesktopMediaID& id); 40 static aura::Window* GetAuraWindowById(const DesktopMediaID& id);
44 #endif // defined(USE_AURA) 41 #endif // defined(USE_AURA)
45 42
46 static DesktopMediaID Parse(const std::string& str); 43 static DesktopMediaID Parse(const std::string& str);
47 44
48 DesktopMediaID() = default; 45 DesktopMediaID() = default;
49 46
50 DesktopMediaID(Type type, Id id) 47 DesktopMediaID(Type type, Id id)
51 : type(type), 48 : type(type),
52 id(id) { 49 id(id) {
53 } 50 }
54 51
55 // Operators so that DesktopMediaID can be used with STL containers. 52 // Operators so that DesktopMediaID can be used with STL containers.
56 bool operator<(const DesktopMediaID& other) const { 53 bool operator<(const DesktopMediaID& other) const {
57 #if defined(USE_AURA) 54 #if defined(USE_AURA)
58 return std::tie(type, id, aura_id) < 55 return std::tie(type, id, aura_id, main_render_frame_id,
59 std::tie(other.type, other.id, other.aura_id); 56 render_process_id) <
57 std::tie(other.type, other.id, other.aura_id,
58 other.main_render_frame_id, other.render_process_id);
60 #else 59 #else
61 return std::tie(type, id) < std::tie(other.type, other.id); 60 return std::tie(type, id, main_render_frame_id, render_process_id) <
61 std::tie(other.type, other.id, other.main_render_frame_id,
62 other.render_process_id);
62 #endif 63 #endif
63 } 64 }
65
64 bool operator==(const DesktopMediaID& other) const { 66 bool operator==(const DesktopMediaID& other) const {
65 #if defined(USE_AURA) 67 #if defined(USE_AURA)
66 return type == other.type && id == other.id && aura_id == other.aura_id; 68 return type == other.type && id == other.id && aura_id == other.aura_id &&
69 render_process_id == other.render_process_id &&
70 main_render_frame_id == other.main_render_frame_id;
67 #else 71 #else
68 return type == other.type && id == other.id; 72 return type == other.type && id == other.id &&
73 render_process_id == other.render_process_id &&
74 main_render_frame_id == other.main_render_frame_id;
69 #endif 75 #endif
70 } 76 }
71 77
72 bool is_null() { return type == TYPE_NONE; } 78 bool is_null() { return type == TYPE_NONE; }
73 79
74 std::string ToString(); 80 std::string ToString() const;
75 81
76 Type type = TYPE_NONE; 82 Type type = TYPE_NONE;
77 83
78 // The IDs referring to the target native screen or window. |id| will be 84 // The IDs referring to the target native screen or window. |id| will be
79 // non-null if and only if it refers to a native screen/window. |aura_id| 85 // non-null if and only if it refers to a native screen/window. |aura_id|
80 // will be non-null if and only if it refers to an Aura window. Note that is 86 // will be non-null if and only if it refers to an Aura window. Note that is
81 // it possible for both of these to be non-null, which means both IDs are 87 // it possible for both of these to be non-null, which means both IDs are
82 // referring to the same logical window. 88 // referring to the same logical window.
83 Id id = kNullId; 89 Id id = kNullId;
84 #if defined(USE_AURA) 90 #if defined(USE_AURA)
85 // TODO(miu): Make this an int, after clean-up for http://crbug.com/513490. 91 // TODO(miu): Make this an int, after clean-up for http://crbug.com/513490.
86 Id aura_id = kNullId; 92 Id aura_id = kNullId;
87 #endif 93 #endif
94
95 // Tab video and audio capture need render process id and render frame id.
96 int render_process_id = kINVALIDID;
97 int main_render_frame_id = kINVALIDID;
88 }; 98 };
89 99
90 } // namespace content 100 } // namespace content
91 101
92 #endif // CONTENT_PUBLIC_BROWSER_DESKTOP_MEDIA_ID_H_ 102 #endif // CONTENT_PUBLIC_BROWSER_DESKTOP_MEDIA_ID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698