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 { |
|
imcheng
2017/02/08 01:28:09
Could you add a TODO to convert this into a struct
zhaobin
2017/02/09 00:13:52
Done.
| |
| 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 |
| 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 |
| 35 // SinkType indicates if sink is discovered by DIAL / CAST / other (e.g. | |
| 36 // cloud) media sink services. Used by mojo. | |
|
imcheng
2017/02/08 01:28:09
1) Remove "Used by mojo."
2) I would point out tha
zhaobin
2017/02/09 00:13:52
Done.
| |
| 37 enum class SinkType { DIAL, CAST, GENERAL }; | |
|
imcheng
2017/02/08 01:28:09
s/GENERAL/GENERIC
zhaobin
2017/02/09 00:13:52
Done.
| |
| 38 | |
| 34 MediaSink(const MediaSink::Id& sink_id, | 39 MediaSink(const MediaSink::Id& sink_id, |
| 35 const std::string& name, | 40 const std::string& name, |
| 36 const IconType icon_type); | 41 const IconType icon_type); |
| 37 | 42 |
| 38 MediaSink(const MediaSink& other); | 43 MediaSink(const MediaSink& other); |
| 39 | 44 |
| 40 ~MediaSink(); | 45 ~MediaSink(); |
|
imcheng
2017/02/08 01:28:09
This needs to be virtual now.
dcheng
2017/02/08 03:01:05
Hmm. Our compiler is supposed to warn on this. zha
zhaobin
2017/02/09 00:13:52
# Build arguments go here. Examples:
# is_compon
zhaobin
2017/02/09 00:13:52
Done.
dcheng
2017/02/09 00:33:23
Ah doh.... this is a known bug =(
https://llvm.org
imcheng
2017/02/09 02:19:57
Wouldn't stack allocated objects (which I am prett
| |
| 41 | 46 |
| 47 SinkType type() const { return type_; } | |
| 42 const MediaSink::Id& id() const { return sink_id_; } | 48 const MediaSink::Id& id() const { return sink_id_; } |
| 43 const std::string& name() const { return name_; } | 49 const std::string& name() const { return name_; } |
| 44 void set_description(const std::string& description) { | 50 void set_description(const std::string& description) { |
| 45 description_ = description; | 51 description_ = description; |
| 46 } | 52 } |
| 47 const std::string& description() const { return description_; } | 53 const base::Optional<std::string>& description() const { |
| 54 return description_; | |
| 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_; } |
| 50 IconType icon_type() const { return icon_type_; } | 58 IconType icon_type() const { return icon_type_; } |
| 59 void set_model_name(const std::string& model_name) { | |
| 60 model_name_ = model_name; | |
| 61 } | |
| 62 const base::Optional<std::string>& model_name() const { return model_name_; } | |
| 51 | 63 |
| 52 bool Equals(const MediaSink& other) const; | 64 bool Equals(const MediaSink& other) const; |
|
imcheng
2017/02/08 01:28:09
I would add a note here that this method only comp
zhaobin
2017/02/09 00:13:52
Done.
| |
| 53 | 65 |
| 54 // 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 |
| 55 // using |collator|, and finally their IDs. | 67 // using |collator|, and finally their IDs. |
| 56 bool CompareUsingCollator(const MediaSink& other, | 68 bool CompareUsingCollator(const MediaSink& other, |
| 57 const icu::Collator* collator) const; | 69 const icu::Collator* collator) const; |
| 58 | 70 |
| 59 // For storing in sets and in maps as keys. | 71 // For storing in sets and in maps as keys. |
| 60 struct Compare { | 72 struct Compare { |
| 61 bool operator()(const MediaSink& sink1, const MediaSink& sink2) const { | 73 bool operator()(const MediaSink& sink1, const MediaSink& sink2) const { |
| 62 return sink1.id() < sink2.id(); | 74 return sink1.id() < sink2.id(); |
| 63 } | 75 } |
| 64 }; | 76 }; |
| 65 | 77 |
| 78 protected: | |
| 79 // Type of the MediaSink. | |
| 80 SinkType type_; | |
| 81 | |
| 66 private: | 82 private: |
| 67 // Unique identifier for the MediaSink. | 83 // Unique identifier for the MediaSink. |
| 68 MediaSink::Id sink_id_; | 84 MediaSink::Id sink_id_; |
| 69 | 85 |
| 70 // Descriptive name of the MediaSink. | 86 // Descriptive name of the MediaSink. |
| 71 std::string name_; | 87 std::string name_; |
| 72 | 88 |
| 73 // Optional description of the MediaSink. | 89 // Optional description of the MediaSink. |
|
imcheng
2017/02/08 01:28:09
This comment doesn't add much - remove?
zhaobin
2017/02/09 00:13:52
Done.
| |
| 74 std::string description_; | 90 base::Optional<std::string> description_; |
| 75 | 91 |
| 76 // Optional domain of the MediaSink. | 92 // Optional domain of the MediaSink. |
|
imcheng
2017/02/08 01:28:09
ditto
zhaobin
2017/02/09 00:13:52
Done.
| |
| 77 std::string domain_; | 93 base::Optional<std::string> domain_; |
| 78 | 94 |
| 79 // The type of icon that corresponds with the MediaSink. | 95 // The type of icon that corresponds with the MediaSink. |
| 80 IconType icon_type_; | 96 IconType icon_type_; |
| 97 | |
| 98 // Optional model name of the MediaSink. | |
|
imcheng
2017/02/08 01:28:09
ditto, or "Model name of the sink, if it represent
zhaobin
2017/02/09 00:13:52
Done.
| |
| 99 base::Optional<std::string> model_name_; | |
| 81 }; | 100 }; |
| 82 | 101 |
| 83 } // namespace media_router | 102 } // namespace media_router |
| 84 | 103 |
| 85 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINK_H_ | 104 #endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_SINK_H_ |
| OLD | NEW |