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

Unified 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: Create CastModesWithMediaSources Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
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..c2107d876becc91c1553d438bdbcae3ab28bcb0c
--- /dev/null
+++ b/chrome/browser/ui/webui/media_router/cast_modes_with_media_sources.cc
@@ -0,0 +1,49 @@
+// 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(
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
+ 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())
+ RemoveCastMode(cast_mode);
+}
+
+bool CastModesWithMediaSources::HasSource(
+ const MediaSource& source, MediaCastMode cast_mode) const {
+ 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.
+ return false;
+ return cast_modes_.at(cast_mode).find(source) !=
+ cast_modes_.at(cast_mode).end();
+}
+
+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.
+ cast_modes_.erase(cast_mode);
+}
+
+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

Powered by Google App Engine
This is Rietveld 408576698