Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 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/ui/webui/media_router/cast_modes_with_media_sources.h" | |
| 6 | |
| 7 namespace media_router { | |
| 8 | |
| 9 CastModesWithMediaSources::CastModesWithMediaSources() {} | |
| 10 CastModesWithMediaSources::CastModesWithMediaSources( | |
|
mark a. foltz
2016/08/31 05:18:54
Is the copy ctor necessary?
takumif
2016/09/01 21:09:25
We need it for using the [] operator on |all_sinks
| |
| 11 const CastModesWithMediaSources& other) = default; | |
| 12 CastModesWithMediaSources::~CastModesWithMediaSources() {} | |
| 13 | |
| 14 void CastModesWithMediaSources::AddSource( | |
| 15 const MediaSource& source, MediaCastMode cast_mode) { | |
| 16 cast_modes_[cast_mode].insert(source); | |
| 17 } | |
| 18 | |
| 19 void CastModesWithMediaSources::RemoveSource( | |
| 20 const MediaSource& source, MediaCastMode cast_mode) { | |
| 21 cast_modes_[cast_mode].erase(source); | |
| 22 if (cast_modes_[cast_mode].empty()) | |
| 23 RemoveCastMode(cast_mode); | |
| 24 } | |
| 25 | |
| 26 bool CastModesWithMediaSources::HasSource( | |
| 27 const MediaSource& source, MediaCastMode cast_mode) const { | |
| 28 if (cast_modes_.find(cast_mode) == cast_modes_.end()) | |
|
mark a. foltz
2016/08/31 05:18:54
Assign cast_modes_.find(cast_mode) to a local vari
takumif
2016/09/01 21:09:25
Done.
| |
| 29 return false; | |
| 30 return cast_modes_.at(cast_mode).find(source) != | |
| 31 cast_modes_.at(cast_mode).end(); | |
| 32 } | |
| 33 | |
| 34 void CastModesWithMediaSources::RemoveCastMode(MediaCastMode cast_mode) { | |
|
mark a. foltz
2016/08/31 05:18:54
It seems like this should only be done if the set
takumif
2016/09/01 21:09:25
No, this is no longer necessary. Removing.
| |
| 35 cast_modes_.erase(cast_mode); | |
| 36 } | |
| 37 | |
| 38 CastModeSet CastModesWithMediaSources::GetCastModes() const { | |
| 39 CastModeSet cast_mode_set; | |
| 40 for (const auto& cast_mode_pair : cast_modes_) | |
| 41 cast_mode_set.insert(cast_mode_pair.first); | |
| 42 return cast_mode_set; | |
| 43 } | |
| 44 | |
| 45 bool CastModesWithMediaSources::IsEmpty() const { | |
| 46 return cast_modes_.empty(); | |
| 47 } | |
| 48 | |
| 49 } // namespace media_router | |
| OLD | NEW |