Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/media/router/typed_media_sink.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 | |
| 9 namespace media_router { | |
| 10 | |
| 11 TypedMediaSink::TypedMediaSink(const MediaSink::Id& sink_id, | |
| 12 const std::string& name, | |
| 13 const MediaSink::IconType icon_type) | |
| 14 : TypedMediaSink() { | |
| 15 sink_ = MediaSink(sink_id, name, icon_type); | |
| 16 } | |
| 17 | |
| 18 TypedMediaSink::TypedMediaSink() | |
| 19 : type_(SinkType::UNKNOWN), dial_sink_extra_data_(DialSinkExtraData()) {} | |
|
imcheng
2017/02/11 01:00:22
Did you need to initialize dial_sink_extra_data_ h
zhaobin
2017/02/14 02:08:49
Unit test crashes if we do not init DialSinkExtraD
| |
| 20 | |
| 21 TypedMediaSink::~TypedMediaSink() {} | |
| 22 | |
| 23 TypedMediaSink& TypedMediaSink::operator=(const TypedMediaSink& other) { | |
| 24 sink_ = other.sink_; | |
| 25 ip_address_ = other.ip_address_; | |
| 26 model_name_ = other.model_name_; | |
| 27 type_ = other.type_; | |
| 28 | |
| 29 if (other.is_dial_sink()) | |
| 30 dial_sink_extra_data_ = other.dial_sink_extra_data_; | |
| 31 if (other.is_cast_sink()) | |
| 32 cast_sink_extra_data_ = other.cast_sink_extra_data_; | |
| 33 | |
| 34 return *this; | |
| 35 } | |
| 36 | |
| 37 void TypedMediaSink::set_dial_sink_extra_data( | |
| 38 const DialSinkExtraData& dial_sink_extra_data) { | |
| 39 DCHECK_EQ(type_, SinkType::UNKNOWN); | |
|
imcheng
2017/02/11 01:00:22
Why do we need these DCHECKs? It seems perfectly l
zhaobin
2017/02/14 02:08:49
Done.
| |
| 40 type_ = SinkType::DIAL; | |
| 41 dial_sink_extra_data_ = dial_sink_extra_data; | |
| 42 } | |
| 43 | |
| 44 const DialSinkExtraData* TypedMediaSink::dial_sink_extra_data() const { | |
|
imcheng
2017/02/11 01:00:22
Suggest making these return const ref, and turn th
zhaobin
2017/02/14 02:08:49
Done.
| |
| 45 if (!is_dial_sink()) | |
| 46 return nullptr; | |
| 47 | |
| 48 return &dial_sink_extra_data_; | |
| 49 } | |
| 50 | |
| 51 void TypedMediaSink::set_cast_sink_extra_data( | |
| 52 const CastSinkExtraData& cast_sink_extra_data) { | |
| 53 DCHECK_EQ(type_, SinkType::UNKNOWN); | |
| 54 type_ = SinkType::CAST; | |
| 55 cast_sink_extra_data_ = cast_sink_extra_data; | |
| 56 } | |
| 57 | |
| 58 const CastSinkExtraData* TypedMediaSink::cast_sink_extra_data() const { | |
| 59 if (!is_cast_sink()) | |
| 60 return nullptr; | |
| 61 | |
| 62 return &cast_sink_extra_data_; | |
| 63 } | |
| 64 | |
| 65 } // namespace media_router | |
| OLD | NEW |