Chromium Code Reviews| Index: chrome/browser/media/router/media_route.cc |
| diff --git a/chrome/browser/media/router/media_route.cc b/chrome/browser/media/router/media_route.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5b0c93d95669a5705fdceb6a33697d00c79d6cd3 |
| --- /dev/null |
| +++ b/chrome/browser/media/router/media_route.cc |
| @@ -0,0 +1,74 @@ |
| +// 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. |
| + |
| +#include "chrome/browser/media/router/media_route.h" |
| + |
| +#include "base/logging.h" |
| +#include "chrome/browser/media/router/media_source.h" |
| + |
| +namespace media_router { |
| + |
| +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.
|
| + |
| +MediaRoute::MediaRoute(const MediaRouteId& media_route_id, |
| + const MediaSource& media_source, |
| + const MediaSinkId& sink_id, |
| + const std::string& description, |
| + bool is_local) |
| + : media_route_id_(media_route_id), |
| + media_source_(media_source), |
| + sink_id_(sink_id), |
| + description_(description), |
| + is_local_(is_local), |
| + 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
|
| +} |
| + |
| +MediaRoute::~MediaRoute() { |
| +} |
| + |
| +bool MediaRoute::operator==(const MediaRoute& other) const { |
| + 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.
|
| + media_source_ == other.media_source_ && |
| + sink_id_ == sink_id_ && |
| + description_ == other.description_ && |
| + is_local_ == other.is_local_ && |
| + state_ == other.state_; |
| +} |
| + |
| +bool MediaRoute::operator!=(const MediaRoute& other) const { |
| + return !(*this == other); |
| +} |
| + |
| +// static |
| +scoped_ptr<MediaRouteResponse> MediaRouteResponse::Success( |
| + const RouteRequestId& request_id, const MediaRoute& route) { |
| + return make_scoped_ptr(new MediaRouteResponse(request_id, route)); |
| +} |
| + |
| +// static |
| +scoped_ptr<MediaRouteResponse> MediaRouteResponse::Error( |
| + const RouteRequestId& request_id, const std::string& error) { |
| + return make_scoped_ptr(new MediaRouteResponse(request_id, error)); |
| +} |
| + |
| +MediaRouteResponse::~MediaRouteResponse() { |
| +} |
| + |
| +MediaRouteResponse::MediaRouteResponse( |
| + const RouteRequestId& request_id, const MediaRoute& route) |
| + : request_id_(request_id), route_(new MediaRoute(route)) { |
| +} |
| + |
| +MediaRouteResponse::MediaRouteResponse( |
| + const RouteRequestId& request_id, const std::string& error) |
| + : request_id_(request_id), error_(error) { |
| +} |
| + |
| +MediaRouteResponse::MediaRouteResponse(const MediaRouteResponse& other) |
| + : request_id_(other.request_id_), error_(other.error_) { |
| + if (other.route_.get()) |
| + route_.reset(new MediaRoute(*other.route_)); |
| +} |
| + |
| +} // namespace media_router |