Chromium Code Reviews| 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 { |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 37 | 38 |
| 38 MediaSink(const MediaSink& other); | 39 MediaSink(const MediaSink& other); |
| 39 | 40 |
| 40 ~MediaSink(); | 41 ~MediaSink(); |
| 41 | 42 |
| 42 const MediaSink::Id& id() const { return sink_id_; } | 43 const MediaSink::Id& id() const { return sink_id_; } |
| 43 const std::string& name() const { return name_; } | 44 const std::string& name() const { return name_; } |
| 44 void set_description(const std::string& description) { | 45 void set_description(const std::string& description) { |
| 45 description_ = description; | 46 description_ = description; |
| 46 } | 47 } |
| 47 const std::string& description() const { return description_; } | 48 const base::Optional<std::string>& description() const { |
| 49 return description_; | |
| 50 } | |
| 48 void set_domain(const std::string& domain) { domain_ = domain; } | 51 void set_domain(const std::string& domain) { domain_ = domain; } |
| 49 const std::string& domain() const { return domain_; } | 52 const base::Optional<std::string>& domain() const { return domain_; } |
| 50 IconType icon_type() const { return icon_type_; } | 53 IconType icon_type() const { return icon_type_; } |
| 51 | 54 |
| 52 bool Equals(const MediaSink& other) const; | 55 bool Equals(const MediaSink& other) const; |
| 53 | 56 |
| 54 // Compares |this| to |other| first by their icon types, then their names | 57 // Compares |this| to |other| first by their icon types, then their names |
| 55 // using |collator|, and finally their IDs. | 58 // using |collator|, and finally their IDs. |
| 56 bool CompareUsingCollator(const MediaSink& other, | 59 bool CompareUsingCollator(const MediaSink& other, |
| 57 const icu::Collator* collator) const; | 60 const icu::Collator* collator) const; |
| 58 | 61 |
| 59 // For storing in sets and in maps as keys. | 62 // For storing in sets and in maps as keys. |
| 60 struct Compare { | 63 struct Compare { |
| 61 bool operator()(const MediaSink& sink1, const MediaSink& sink2) const { | 64 bool operator()(const MediaSink& sink1, const MediaSink& sink2) const { |
| 62 return sink1.id() < sink2.id(); | 65 return sink1.id() < sink2.id(); |
| 63 } | 66 } |
| 64 }; | 67 }; |
| 65 | 68 |
| 69 // Used by Mojo. | |
| 70 MediaSink(); | |
|
mark a. foltz
2017/02/07 00:57:43
Declare with other ctors?
imcheng
2017/02/07 01:36:04
Done.
| |
| 71 void set_sink_id(const MediaSink::Id& sink_id) { sink_id_ = sink_id; } | |
| 72 void set_name(const std::string& name) { name_ = name; } | |
| 73 void set_icon_type(IconType icon_type) { icon_type_ = icon_type; } | |
| 74 | |
| 66 private: | 75 private: |
| 67 // Unique identifier for the MediaSink. | 76 // Unique identifier for the MediaSink. |
| 68 MediaSink::Id sink_id_; | 77 MediaSink::Id sink_id_; |
| 69 | 78 |
| 70 // Descriptive name of the MediaSink. | 79 // Descriptive name of the MediaSink. |
| 71 std::string name_; | 80 std::string name_; |
| 72 | 81 |
| 73 // Optional description of the MediaSink. | 82 // Optional description of the MediaSink. |
| 74 std::string description_; | 83 base::Optional<std::string> description_; |
| 75 | 84 |
| 76 // Optional domain of the MediaSink. | 85 // Optional domain of the MediaSink. |
| 77 std::string domain_; | 86 base::Optional<std::string> domain_; |
| 78 | 87 |
| 79 // The type of icon that corresponds with the MediaSink. | 88 // The type of icon that corresponds with the MediaSink. |
| 80 IconType icon_type_; | 89 IconType icon_type_ = IconType::GENERIC; |
| 81 }; | 90 }; |
| 82 | 91 |
| 83 } // namespace media_router | 92 } // namespace media_router |
| 84 | 93 |
| 85 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINK_H_ | 94 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINK_H_ |
| OLD | NEW |