OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_ROUTER_MEDIA_SINK_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINK_H_ |
6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINK_H_ | 6 #define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINK_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/optional.h" | |
10 #include "third_party/icu/source/common/unicode/uversion.h" | 11 #include "third_party/icu/source/common/unicode/uversion.h" |
11 | 12 |
12 namespace U_ICU_NAMESPACE { | 13 namespace U_ICU_NAMESPACE { |
13 class Collator; | 14 class Collator; |
14 } // namespace U_ICU_NAMESPACE | 15 } // namespace U_ICU_NAMESPACE |
15 | 16 |
16 namespace media_router { | 17 namespace media_router { |
17 | 18 |
18 // Represents a sink to which media can be routed. | 19 // Represents a sink to which media can be routed. |
19 class MediaSink { | 20 class MediaSink { |
20 public: | 21 public: |
21 using Id = std::string; | 22 using Id = std::string; |
22 | 23 |
23 // IconTypes are listed in the order in which sinks should be sorted. | 24 // IconTypes are listed in the order in which sinks should be sorted. |
24 // The order must stay in sync with | 25 // The order must stay in sync with |
mark a. foltz
2017/02/09 22:53:51
Add a comment here about also updating struct_trai
| |
25 // chrome/browser/resources/media_router/media_router_data.js. | 26 // chrome/browser/resources/media_router/media_router_data.js. |
26 enum IconType { | 27 enum IconType { |
27 CAST, | 28 CAST, |
28 CAST_AUDIO_GROUP, | 29 CAST_AUDIO_GROUP, |
29 CAST_AUDIO, | 30 CAST_AUDIO, |
30 HANGOUT, | 31 HANGOUT, |
31 GENERIC | 32 GENERIC |
32 }; | 33 }; |
33 | 34 |
34 MediaSink(const MediaSink::Id& sink_id, | 35 MediaSink(const MediaSink::Id& sink_id, |
35 const std::string& name, | 36 const std::string& name, |
36 const IconType icon_type); | 37 const IconType icon_type); |
37 | |
38 MediaSink(const MediaSink& other); | 38 MediaSink(const MediaSink& other); |
39 MediaSink(); | |
39 | 40 |
40 ~MediaSink(); | 41 ~MediaSink(); |
41 | 42 |
43 void set_sink_id(const MediaSink::Id& sink_id) { sink_id_ = sink_id; } | |
42 const MediaSink::Id& id() const { return sink_id_; } | 44 const MediaSink::Id& id() const { return sink_id_; } |
45 | |
46 void set_name(const std::string& name) { name_ = name; } | |
43 const std::string& name() const { return name_; } | 47 const std::string& name() const { return name_; } |
48 | |
44 void set_description(const std::string& description) { | 49 void set_description(const std::string& description) { |
45 description_ = description; | 50 description_ = description; |
46 } | 51 } |
47 const std::string& description() const { return description_; } | 52 const base::Optional<std::string>& description() const { |
53 return description_; | |
54 } | |
55 | |
48 void set_domain(const std::string& domain) { domain_ = domain; } | 56 void set_domain(const std::string& domain) { domain_ = domain; } |
49 const std::string& domain() const { return domain_; } | 57 const base::Optional<std::string>& domain() const { return domain_; } |
58 | |
59 void set_icon_type(IconType icon_type) { icon_type_ = icon_type; } | |
50 IconType icon_type() const { return icon_type_; } | 60 IconType icon_type() const { return icon_type_; } |
51 | 61 |
52 bool Equals(const MediaSink& other) const; | 62 bool Equals(const MediaSink& other) const; |
53 | 63 |
54 // Compares |this| to |other| first by their icon types, then their names | 64 // Compares |this| to |other| first by their icon types, then their names |
55 // using |collator|, and finally their IDs. | 65 // using |collator|, and finally their IDs. |
56 bool CompareUsingCollator(const MediaSink& other, | 66 bool CompareUsingCollator(const MediaSink& other, |
57 const icu::Collator* collator) const; | 67 const icu::Collator* collator) const; |
58 | 68 |
59 // For storing in sets and in maps as keys. | 69 // For storing in sets and in maps as keys. |
60 struct Compare { | 70 struct Compare { |
61 bool operator()(const MediaSink& sink1, const MediaSink& sink2) const { | 71 bool operator()(const MediaSink& sink1, const MediaSink& sink2) const { |
62 return sink1.id() < sink2.id(); | 72 return sink1.id() < sink2.id(); |
63 } | 73 } |
64 }; | 74 }; |
65 | 75 |
66 private: | 76 private: |
67 // Unique identifier for the MediaSink. | 77 // Unique identifier for the MediaSink. |
68 MediaSink::Id sink_id_; | 78 MediaSink::Id sink_id_; |
69 | 79 |
70 // Descriptive name of the MediaSink. | 80 // Descriptive name of the MediaSink. |
71 std::string name_; | 81 std::string name_; |
72 | 82 |
73 // Optional description of the MediaSink. | 83 // Optional description of the MediaSink. |
74 std::string description_; | 84 base::Optional<std::string> description_; |
75 | 85 |
76 // Optional domain of the MediaSink. | 86 // Optional domain of the MediaSink. |
77 std::string domain_; | 87 base::Optional<std::string> domain_; |
78 | 88 |
79 // The type of icon that corresponds with the MediaSink. | 89 // The type of icon that corresponds with the MediaSink. |
80 IconType icon_type_; | 90 IconType icon_type_ = IconType::GENERIC; |
81 }; | 91 }; |
82 | 92 |
83 } // namespace media_router | 93 } // namespace media_router |
84 | 94 |
85 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINK_H_ | 95 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINK_H_ |
OLD | NEW |