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

Side by Side Diff: chrome/browser/media/router/media_route.cc

Issue 949293004: Add media router common classes and unittests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resync with latest changes Created 5 years, 9 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 2015 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 "chrome/browser/media/router/media_route.h"
6
7 #include "base/logging.h"
8 #include "chrome/browser/media/router/media_source.h"
9
10 namespace media_router {
11
12 const int64 kInvalidRouteRequestId = -1;
mark a. foltz 2015/03/02 21:40:08 s/int64/RouteRequestId/
Kevin M 2015/03/03 21:53:18 Done.
13
14 MediaRoute::MediaRoute(const MediaRouteId& media_route_id,
15 const MediaSource& media_source,
16 const MediaSinkId& sink_id,
17 const std::string& description,
18 bool is_local)
19 : media_route_id_(media_route_id),
20 media_source_(media_source),
21 sink_id_(sink_id),
22 description_(description),
23 is_local_(is_local),
24 state_(MEDIA_ROUTE_STATE_NEW) {
mark a. foltz 2015/03/02 21:40:08 description_ and state_ would seem to be mutable o
Kevin M 2015/03/03 21:53:18 The Media Route object is used to communicate the
mark a. foltz 2015/03/04 06:22:58 (1) This semantic should be documented in the head
Kevin M 2015/03/04 23:33:32 1. See the new comment for MediaRoute. 2. Also see
25 }
26
27 MediaRoute::~MediaRoute() {
28 }
29
30 bool MediaRoute::operator==(const MediaRoute& other) const {
31 return media_route_id_ == other.media_route_id_ &&
mark a. foltz 2015/03/02 21:40:08 The declaration states that route_ids are unique a
Kevin M 2015/03/03 21:53:18 Done.
32 media_source_ == other.media_source_ &&
33 sink_id_ == sink_id_ &&
34 description_ == other.description_ &&
35 is_local_ == other.is_local_ &&
36 state_ == other.state_;
37 }
38
39 bool MediaRoute::operator!=(const MediaRoute& other) const {
40 return !(*this == other);
41 }
42
43 // static
44 scoped_ptr<MediaRouteResponse> MediaRouteResponse::Success(
45 const RouteRequestId& request_id, const MediaRoute& route) {
46 return make_scoped_ptr(new MediaRouteResponse(request_id, route));
47 }
48
49 // static
50 scoped_ptr<MediaRouteResponse> MediaRouteResponse::Error(
51 const RouteRequestId& request_id, const std::string& error) {
52 return make_scoped_ptr(new MediaRouteResponse(request_id, error));
53 }
54
55 MediaRouteResponse::~MediaRouteResponse() {
56 }
57
58 MediaRouteResponse::MediaRouteResponse(
59 const RouteRequestId& request_id, const MediaRoute& route)
60 : request_id_(request_id), route_(new MediaRoute(route)) {
61 }
62
63 MediaRouteResponse::MediaRouteResponse(
64 const RouteRequestId& request_id, const std::string& error)
65 : request_id_(request_id), error_(error) {
66 }
67
68 MediaRouteResponse::MediaRouteResponse(const MediaRouteResponse& other)
69 : request_id_(other.request_id_), error_(other.error_) {
70 if (other.route_.get())
71 route_.reset(new MediaRoute(*other.route_));
72 }
73
74 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698