Chromium Code Reviews| Index: chrome/browser/ui/webui/media_router/cast_modes_with_media_sources.cc |
| diff --git a/chrome/browser/ui/webui/media_router/cast_modes_with_media_sources.cc b/chrome/browser/ui/webui/media_router/cast_modes_with_media_sources.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..77d10b81c34b7fc8f3881c05e2f0e066364b83ab |
| --- /dev/null |
| +++ b/chrome/browser/ui/webui/media_router/cast_modes_with_media_sources.cc |
| @@ -0,0 +1,46 @@ |
| +// Copyright 2016 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/ui/webui/media_router/cast_modes_with_media_sources.h" |
| + |
| +namespace media_router { |
| + |
| +CastModesWithMediaSources::CastModesWithMediaSources() {} |
| +CastModesWithMediaSources::CastModesWithMediaSources( |
| + const CastModesWithMediaSources& other) = default; |
| +CastModesWithMediaSources::~CastModesWithMediaSources() {} |
| + |
| +void CastModesWithMediaSources::AddSource( |
| + const MediaSource& source, MediaCastMode cast_mode) { |
| + cast_modes_[cast_mode].insert(source); |
| +} |
| + |
| +void CastModesWithMediaSources::RemoveSource( |
| + const MediaSource& source, MediaCastMode cast_mode) { |
| + cast_modes_[cast_mode].erase(source); |
| + if (cast_modes_[cast_mode].empty()) |
| + cast_modes_.erase(cast_mode); |
| +} |
| + |
| +bool CastModesWithMediaSources::HasSource( |
| + const MediaSource& source, MediaCastMode cast_mode) const { |
| + auto it = cast_modes_.find(cast_mode); |
| + if (it == cast_modes_.end()) |
| + return false; |
| + const auto& sources_for_cast_mode = it->second; |
|
mark a. foltz
2016/09/02 23:00:37
base::ContainsKey?
takumif
2016/09/06 21:53:20
Done.
|
| + return sources_for_cast_mode.find(source) != sources_for_cast_mode.end(); |
| +} |
| + |
| +CastModeSet CastModesWithMediaSources::GetCastModes() const { |
| + CastModeSet cast_mode_set; |
| + for (const auto& cast_mode_pair : cast_modes_) |
| + cast_mode_set.insert(cast_mode_pair.first); |
| + return cast_mode_set; |
| +} |
| + |
| +bool CastModesWithMediaSources::IsEmpty() const { |
| + return cast_modes_.empty(); |
| +} |
| + |
| +} // namespace media_router |