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 "base/optional.h" |
11 #include "third_party/icu/source/common/unicode/uversion.h" | 11 #include "third_party/icu/source/common/unicode/uversion.h" |
12 | 12 |
13 namespace U_ICU_NAMESPACE { | 13 namespace U_ICU_NAMESPACE { |
14 class Collator; | 14 class Collator; |
15 } // namespace U_ICU_NAMESPACE | 15 } // namespace U_ICU_NAMESPACE |
16 | 16 |
17 namespace media_router { | 17 namespace media_router { |
18 | 18 |
19 // Represents a sink to which media can be routed. | 19 // Represents a sink to which media can be routed. |
| 20 // TODO(zhaobin): convert MediaSink into a struct. |
20 class MediaSink { | 21 class MediaSink { |
21 public: | 22 public: |
22 using Id = std::string; | 23 using Id = std::string; |
23 | 24 |
24 // IconTypes are listed in the order in which sinks should be sorted. | 25 // IconTypes are listed in the order in which sinks should be sorted. |
25 // The order must stay in sync with | 26 // The order must stay in sync with |
26 // chrome/browser/resources/media_router/media_router_data.js. | 27 // chrome/browser/resources/media_router/media_router_data.js. |
27 enum IconType { | 28 enum IconType { |
28 CAST, | 29 CAST, |
29 CAST_AUDIO_GROUP, | 30 CAST_AUDIO_GROUP, |
(...skipping 22 matching lines...) Expand all Loading... |
52 const base::Optional<std::string>& description() const { | 53 const base::Optional<std::string>& description() const { |
53 return description_; | 54 return description_; |
54 } | 55 } |
55 | 56 |
56 void set_domain(const std::string& domain) { domain_ = domain; } | 57 void set_domain(const std::string& domain) { domain_ = domain; } |
57 const base::Optional<std::string>& domain() const { return domain_; } | 58 const base::Optional<std::string>& domain() const { return domain_; } |
58 | 59 |
59 void set_icon_type(IconType icon_type) { icon_type_ = icon_type; } | 60 void set_icon_type(IconType icon_type) { icon_type_ = icon_type; } |
60 IconType icon_type() const { return icon_type_; } | 61 IconType icon_type() const { return icon_type_; } |
61 | 62 |
| 63 // This method only compares IDs. |
62 bool Equals(const MediaSink& other) const; | 64 bool Equals(const MediaSink& other) const; |
63 | 65 |
64 // Compares |this| to |other| first by their icon types, then their names | 66 // Compares |this| to |other| first by their icon types, then their names |
65 // using |collator|, and finally their IDs. | 67 // using |collator|, and finally their IDs. |
66 bool CompareUsingCollator(const MediaSink& other, | 68 bool CompareUsingCollator(const MediaSink& other, |
67 const icu::Collator* collator) const; | 69 const icu::Collator* collator) const; |
68 | 70 |
69 // For storing in sets and in maps as keys. | 71 // For storing in sets and in maps as keys. |
70 struct Compare { | 72 struct Compare { |
71 bool operator()(const MediaSink& sink1, const MediaSink& sink2) const { | 73 bool operator()(const MediaSink& sink1, const MediaSink& sink2) const { |
(...skipping 14 matching lines...) Expand all Loading... |
86 // Optional domain of the MediaSink. | 88 // Optional domain of the MediaSink. |
87 base::Optional<std::string> domain_; | 89 base::Optional<std::string> domain_; |
88 | 90 |
89 // The type of icon that corresponds with the MediaSink. | 91 // The type of icon that corresponds with the MediaSink. |
90 IconType icon_type_ = IconType::GENERIC; | 92 IconType icon_type_ = IconType::GENERIC; |
91 }; | 93 }; |
92 | 94 |
93 } // namespace media_router | 95 } // namespace media_router |
94 | 96 |
95 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINK_H_ | 97 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINK_H_ |
OLD | NEW |