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

Unified Diff: chrome/browser/media/router/media_sink.cc

Issue 949293004: Add media router common classes and unittests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Chunkier CL Created 5 years, 10 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/media/router/media_sink.cc
diff --git a/chrome/browser/media/router/media_sink.cc b/chrome/browser/media/router/media_sink.cc
new file mode 100644
index 0000000000000000000000000000000000000000..baad5ffebb889cca74d23d9a639e457e3e25beef
--- /dev/null
+++ b/chrome/browser/media/router/media_sink.cc
@@ -0,0 +1,55 @@
+// Copyright 2014 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/media/router/media_sink.h"
+
+#include "base/logging.h"
+
+namespace media_router {
+
+MediaSink::MediaSink(const MediaSinkId& sink_id,
+ const std::string& name,
+ const MediaRouteId& route_id,
+ Status status)
+ : sink_id_(sink_id), name_(name), route_id_(route_id), status_(status) {
+ if (status == Status::ACTIVE) {
+ DCHECK(!route_id_.empty()) << "Inactive sink cannot have route ID";
+ } else {
+ DCHECK(route_id_.empty()) << "Active sinks have must route ID";
+ }
+}
+
+MediaSink::~MediaSink() {
+}
+
+std::string MediaSink::StatusAsString() const {
+ switch (status_) {
+ case MediaSink::IDLE:
+ return "IDLE";
+ case MediaSink::ACTIVE:
+ return "ACTIVE";
+ case MediaSink::REQUEST_PENDING:
+ return "REQUEST_PENDING";
+ default:
+ NOTREACHED();
+ return "";
+ }
+}
+
+bool MediaSink::HasRoute() const {
+ return !route_id_.empty();
+}
+
+bool MediaSink::operator==(const MediaSink& other) const {
+ return sink_id_ == other.sink_id_ &&
+ name_ == other.name_ &&
+ status_ == other.status_ &&
+ route_id_ == other.route_id_;
+}
+
+bool MediaSink::operator!=(const MediaSink& other) const {
+ return !(*this == other);
+}
+
+} // namespace media_router

Powered by Google App Engine
This is Rietveld 408576698