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 #ifndef CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_CAST_MODES_WITH_MEDIA_SOURCES_H_ | |
| 6 #define CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_CAST_MODES_WITH_MEDIA_SOURCES_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 #include <unordered_set> | |
| 10 | |
| 11 #include "chrome/browser/media/router/media_source.h" | |
| 12 #include "chrome/browser/ui/webui/media_router/media_cast_mode.h" | |
| 13 | |
| 14 namespace media_router { | |
| 15 | |
| 16 // Contains information on cast modes and the sources associated with them. | |
| 17 // Each cast mode contained has at least one source. | |
| 18 class CastModesWithMediaSources { | |
| 19 public: | |
| 20 CastModesWithMediaSources(); | |
| 21 CastModesWithMediaSources(const CastModesWithMediaSources& other); | |
| 22 ~CastModesWithMediaSources(); | |
| 23 | |
| 24 // Add a source for the cast mode. | |
| 25 void AddSource(const MediaSource& source, MediaCastMode cast_mode); | |
|
mark a. foltz
2016/09/02 23:00:37
Nit: the mapping is from cast mode to source(s).
takumif
2016/09/06 21:53:20
Done.
| |
| 26 | |
| 27 // Remove a source from the cast mode. The cast mode will also get removed if | |
| 28 // it has no other sources. This is a no-op if the source is not found. | |
| 29 void RemoveSource(const MediaSource& source, MediaCastMode cast_mode); | |
| 30 | |
| 31 // Returns true if the source for the cast mode is contained. | |
| 32 bool HasSource(const MediaSource& source, MediaCastMode cast_mode) const; | |
| 33 | |
| 34 // Returns a set of all the cast modes contained. | |
| 35 CastModeSet GetCastModes() const; | |
| 36 | |
| 37 // Returns true if there are no cast modes contained. | |
|
mark a. foltz
2016/09/02 23:00:37
Not sure this adds much versus GetCastModes().empt
takumif
2016/09/06 21:53:20
It's more obvious than GetCastModes().empty(), and
| |
| 38 bool IsEmpty() const; | |
| 39 | |
| 40 private: | |
| 41 std::map<MediaCastMode, std::unordered_set<MediaSource, MediaSource::Hash>> | |
|
mark a. foltz
2016/09/02 23:00:37
A std::multimap may be simpler but would not inher
takumif
2016/09/06 21:53:20
Yeah, it's nice not having to check for duplicates
| |
| 42 cast_modes_; | |
| 43 }; | |
| 44 | |
| 45 } // namespace media_router | |
| 46 | |
| 47 #endif // CHROME_BROWSER_UI_WEBUI_MEDIA_ROUTER_CAST_MODES_WITH_MEDIA_SOURCES_H_ | |
| OLD | NEW |