Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(378)

Side by Side Diff: chrome/browser/ui/webui/media_router/cast_modes_with_media_sources.cc

Issue 2264153002: [Presentation API] Add support for multiple URLs in PresentationRequest on Media Router UI side (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Modify MediaRouterDialogControllerAndroid, format Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 "base/stl_util.h"
6 #include "chrome/browser/ui/webui/media_router/cast_modes_with_media_sources.h"
7
8 namespace media_router {
9
10 CastModesWithMediaSources::CastModesWithMediaSources() {}
11 CastModesWithMediaSources::CastModesWithMediaSources(
12 CastModesWithMediaSources&& other) = default;
13 CastModesWithMediaSources::~CastModesWithMediaSources() {}
14
15 void CastModesWithMediaSources::AddSource(MediaCastMode cast_mode,
16 const MediaSource& source) {
17 cast_modes_[cast_mode].insert(source);
18 }
19
20 void CastModesWithMediaSources::RemoveSource(MediaCastMode cast_mode,
21 const MediaSource& source) {
22 const auto& cast_mode_it = cast_modes_.find(cast_mode);
23 if (cast_mode_it != cast_modes_.end()) {
24 auto& sources_for_cast_mode = cast_mode_it->second;
25 sources_for_cast_mode.erase(source);
26 if (sources_for_cast_mode.empty())
27 cast_modes_.erase(cast_mode);
28 }
29 }
30
31 bool CastModesWithMediaSources::HasSource(MediaCastMode cast_mode,
32 const MediaSource& source) const {
33 return base::ContainsKey(cast_modes_, cast_mode)
34 ? base::ContainsKey(cast_modes_.at(cast_mode), source)
35 : false;
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698