OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #include "chrome/browser/media/router/discovery/media_sink_internal.h" | 5 #include "chrome/browser/media/router/discovery/media_sink_internal.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 | 9 |
10 namespace media_router { | 10 namespace media_router { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 case SinkType::DIAL: | 59 case SinkType::DIAL: |
60 return *dial_data_ == *(other.dial_data_); | 60 return *dial_data_ == *(other.dial_data_); |
61 case SinkType::CAST: | 61 case SinkType::CAST: |
62 return *cast_data_ == *(other.cast_data_); | 62 return *cast_data_ == *(other.cast_data_); |
63 case SinkType::GENERIC: | 63 case SinkType::GENERIC: |
64 return true; | 64 return true; |
65 } | 65 } |
66 NOTREACHED(); | 66 NOTREACHED(); |
67 } | 67 } |
68 | 68 |
| 69 bool MediaSinkInternal::operator!=(const MediaSinkInternal& other) const { |
| 70 return !operator==(other); |
| 71 } |
| 72 |
69 void MediaSinkInternal::set_sink(const MediaSink& sink) { | 73 void MediaSinkInternal::set_sink(const MediaSink& sink) { |
70 sink_ = sink; | 74 sink_ = sink; |
71 } | 75 } |
72 | 76 |
73 void MediaSinkInternal::set_dial_data(const DialSinkExtraData& dial_data) { | 77 void MediaSinkInternal::set_dial_data(const DialSinkExtraData& dial_data) { |
74 InternalCleanup(); | 78 InternalCleanup(); |
75 | 79 |
76 sink_type_ = SinkType::DIAL; | 80 sink_type_ = SinkType::DIAL; |
77 dial_data_.Init(dial_data); | 81 dial_data_.Init(dial_data); |
78 } | 82 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 case SinkType::CAST: | 151 case SinkType::CAST: |
148 cast_data_.Destroy(); | 152 cast_data_.Destroy(); |
149 return; | 153 return; |
150 case SinkType::GENERIC: | 154 case SinkType::GENERIC: |
151 return; | 155 return; |
152 } | 156 } |
153 NOTREACHED(); | 157 NOTREACHED(); |
154 } | 158 } |
155 | 159 |
156 DialSinkExtraData::DialSinkExtraData() = default; | 160 DialSinkExtraData::DialSinkExtraData() = default; |
| 161 DialSinkExtraData::DialSinkExtraData(const std::string& ip_address, |
| 162 const std::string& model_name, |
| 163 const std::string& app_url) |
| 164 : model_name(model_name), app_url(GURL(app_url)) { |
| 165 DCHECK(this->ip_address.AssignFromIPLiteral(ip_address)); |
| 166 } |
| 167 |
157 DialSinkExtraData::DialSinkExtraData(const DialSinkExtraData& other) = default; | 168 DialSinkExtraData::DialSinkExtraData(const DialSinkExtraData& other) = default; |
158 DialSinkExtraData::~DialSinkExtraData() = default; | 169 DialSinkExtraData::~DialSinkExtraData() = default; |
159 | 170 |
160 bool DialSinkExtraData::operator==(const DialSinkExtraData& other) const { | 171 bool DialSinkExtraData::operator==(const DialSinkExtraData& other) const { |
161 return ip_address == other.ip_address && model_name == other.model_name && | 172 return ip_address == other.ip_address && model_name == other.model_name && |
162 app_url == other.app_url; | 173 app_url == other.app_url; |
163 } | 174 } |
164 | 175 |
165 CastSinkExtraData::CastSinkExtraData() = default; | 176 CastSinkExtraData::CastSinkExtraData() = default; |
166 CastSinkExtraData::CastSinkExtraData(const CastSinkExtraData& other) = default; | 177 CastSinkExtraData::CastSinkExtraData(const CastSinkExtraData& other) = default; |
167 CastSinkExtraData::~CastSinkExtraData() = default; | 178 CastSinkExtraData::~CastSinkExtraData() = default; |
168 | 179 |
169 bool CastSinkExtraData::operator==(const CastSinkExtraData& other) const { | 180 bool CastSinkExtraData::operator==(const CastSinkExtraData& other) const { |
170 return ip_address == other.ip_address && model_name == other.model_name && | 181 return ip_address == other.ip_address && model_name == other.model_name && |
171 capabilities == other.capabilities && | 182 capabilities == other.capabilities && |
172 cast_channel_id == other.cast_channel_id; | 183 cast_channel_id == other.cast_channel_id; |
173 } | 184 } |
174 | 185 |
175 } // namespace media_router | 186 } // namespace media_router |
OLD | NEW |