| 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 |
| 66 // This method compares all fields. |
| 67 bool operator==(const MediaSink& other) const; |
| 68 bool operator!=(const MediaSink& other) const; |
| 69 |
| 64 // Compares |this| to |other| first by their icon types, then their names | 70 // Compares |this| to |other| first by their icon types, then their names |
| 65 // using |collator|, and finally their IDs. | 71 // using |collator|, and finally their IDs. |
| 66 bool CompareUsingCollator(const MediaSink& other, | 72 bool CompareUsingCollator(const MediaSink& other, |
| 67 const icu::Collator* collator) const; | 73 const icu::Collator* collator) const; |
| 68 | 74 |
| 69 // For storing in sets and in maps as keys. | 75 // For storing in sets and in maps as keys. |
| 70 struct Compare { | 76 struct Compare { |
| 71 bool operator()(const MediaSink& sink1, const MediaSink& sink2) const { | 77 bool operator()(const MediaSink& sink1, const MediaSink& sink2) const { |
| 72 return sink1.id() < sink2.id(); | 78 return sink1.id() < sink2.id(); |
| 73 } | 79 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 86 // Optional domain of the MediaSink. | 92 // Optional domain of the MediaSink. |
| 87 base::Optional<std::string> domain_; | 93 base::Optional<std::string> domain_; |
| 88 | 94 |
| 89 // The type of icon that corresponds with the MediaSink. | 95 // The type of icon that corresponds with the MediaSink. |
| 90 IconType icon_type_ = IconType::GENERIC; | 96 IconType icon_type_ = IconType::GENERIC; |
| 91 }; | 97 }; |
| 92 | 98 |
| 93 } // namespace media_router | 99 } // namespace media_router |
| 94 | 100 |
| 95 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINK_H_ | 101 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINK_H_ |
| OLD | NEW |