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

Unified Diff: chrome/browser/media/router/media_route.h

Issue 949293004: Add media router common classes and unittests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More typedef=>using conversions. 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_route.h
diff --git a/chrome/browser/media/router/media_route.h b/chrome/browser/media/router/media_route.h
new file mode 100644
index 0000000000000000000000000000000000000000..bcaa3b7668a5e97fa046751ce2262ad0a8efc390
--- /dev/null
+++ b/chrome/browser/media/router/media_route.h
@@ -0,0 +1,93 @@
+// Copyright 2015 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.
+
+#ifndef CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTE_H_
+#define CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTE_H_
+
+#include <string>
+
+#include "base/gtest_prod_util.h"
+#include "base/logging.h"
+#include "base/values.h"
+#include "chrome/browser/media/router/media_route_id.h"
+#include "chrome/browser/media/router/media_sink.h"
+#include "chrome/browser/media/router/media_source.h"
+#include "url/gurl.h"
+
+namespace media_router {
+
+using RouteRequestId = int64;
+
+extern const RouteRequestId kInvalidRouteRequestId;
+
+class MediaRouteFactory;
+
+// For now, a simple transition graph: NEW -> CONNECTED -> CLOSED.
+enum MediaRouteState {
+ // The route is new and not yet connected to a sink.
+ MEDIA_ROUTE_STATE_NEW,
+ // The route is active and connected to a sink.
+ MEDIA_ROUTE_STATE_CONNECTED,
+ // The route has been disconnected.
+ MEDIA_ROUTE_STATE_CLOSED
+};
+
+// A MediaRoute encapsulates an application's means of routing media from a
+// source to a sink.
+class MediaRoute {
+ public:
+ ~MediaRoute();
+
+ // The media route identifier.
+ const MediaRouteId& media_route_id() const { return media_route_id_; }
+
+ // The state of the media route.
+ MediaRouteState state() const { return state_; }
+
+ // The media source being routed.
+ const MediaSource& media_source() const { return media_source_; }
imcheng 2015/03/03 22:53:09 It's not hard to misuse a getter that returns by r
Kevin M 2015/03/03 23:28:05 I think returning field const references is widesp
+
+ // The ID of the sink being routed to.
+ const MediaSinkId& sink_id() const { return sink_id_; }
+
+ // The description of the media route activity, for example
+ // "Playing Foo Bar Music All Access."
+ // TODO(kmarshall): Does this need to be localized?
mark a. foltz 2015/03/04 06:22:59 Per discussion, the browser is not responsible for
Kevin M 2015/03/04 23:33:32 I hadn't considered the bidi aspect. OK, TODO adde
+ const std::string& description() const { return description_; }
+
+ // Returns |true| if the route is created locally (versus diescovered
mark a. foltz 2015/03/04 06:22:59 discovered
Kevin M 2015/03/04 23:33:32 Done.
+ // by a media route provider.)
+ bool is_local() const { return is_local_; }
+
+ bool operator==(const MediaRoute& other) const;
+ bool operator!=(const MediaRoute& other) const;
+
+ private:
+ friend class MediaRouteFactory;
+ FRIEND_TEST_ALL_PREFIXES(MediaRouteTest, Equals);
+
+ // |media_route_id|: Uniquely identifies the route among active
+ // instances for this media source.
+ // |type|: Type of media route.
+ // |media_source|: Description of source of the route.
+ // |sink_id|: ID of the MediaSink of the route.
+ // |description|: Description of the route to be displayed.
+ // |is_local|: true if the route was created from this browser.
+ MediaRoute(const MediaRouteId& media_route_id,
+ const MediaSource& media_source,
+ const MediaSinkId& sink_id,
+ const std::string& description,
+ bool is_local);
+
+ const MediaRouteId media_route_id_;
+ const MediaSource media_source_;
+ const MediaSinkId sink_id_;
+ const std::string description_;
+ const bool is_local_;
+ const MediaRouteState state_;
+};
+
+} // namespace media_router
+
+#endif // CHROME_BROWSER_MEDIA_ROUTER_MEDIA_ROUTE_H_

Powered by Google App Engine
This is Rietveld 408576698