Chromium Code Reviews| Index: chrome/browser/media/router/typed_media_sink.cc |
| diff --git a/chrome/browser/media/router/typed_media_sink.cc b/chrome/browser/media/router/typed_media_sink.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..71b49a50e4f9623a0ccf1f873bd4a078b8911142 |
| --- /dev/null |
| +++ b/chrome/browser/media/router/typed_media_sink.cc |
| @@ -0,0 +1,65 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/media/router/typed_media_sink.h" |
| + |
| +#include "base/logging.h" |
| + |
| +namespace media_router { |
| + |
| +TypedMediaSink::TypedMediaSink(const MediaSink::Id& sink_id, |
| + const std::string& name, |
| + const MediaSink::IconType icon_type) |
| + : TypedMediaSink() { |
| + sink_ = MediaSink(sink_id, name, icon_type); |
| +} |
| + |
| +TypedMediaSink::TypedMediaSink() |
| + : 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
|
| + |
| +TypedMediaSink::~TypedMediaSink() {} |
| + |
| +TypedMediaSink& TypedMediaSink::operator=(const TypedMediaSink& other) { |
| + sink_ = other.sink_; |
| + ip_address_ = other.ip_address_; |
| + model_name_ = other.model_name_; |
| + type_ = other.type_; |
| + |
| + if (other.is_dial_sink()) |
| + dial_sink_extra_data_ = other.dial_sink_extra_data_; |
| + if (other.is_cast_sink()) |
| + cast_sink_extra_data_ = other.cast_sink_extra_data_; |
| + |
| + return *this; |
| +} |
| + |
| +void TypedMediaSink::set_dial_sink_extra_data( |
| + const DialSinkExtraData& dial_sink_extra_data) { |
| + 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.
|
| + type_ = SinkType::DIAL; |
| + dial_sink_extra_data_ = dial_sink_extra_data; |
| +} |
| + |
| +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.
|
| + if (!is_dial_sink()) |
| + return nullptr; |
| + |
| + return &dial_sink_extra_data_; |
| +} |
| + |
| +void TypedMediaSink::set_cast_sink_extra_data( |
| + const CastSinkExtraData& cast_sink_extra_data) { |
| + DCHECK_EQ(type_, SinkType::UNKNOWN); |
| + type_ = SinkType::CAST; |
| + cast_sink_extra_data_ = cast_sink_extra_data; |
| +} |
| + |
| +const CastSinkExtraData* TypedMediaSink::cast_sink_extra_data() const { |
| + if (!is_cast_sink()) |
| + return nullptr; |
| + |
| + return &cast_sink_extra_data_; |
| +} |
| + |
| +} // namespace media_router |