| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/media/cast_remoting_connector.h" | 5 #include "chrome/browser/media/cast_remoting_connector.h" |
| 6 | 6 |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 void CastRemotingConnector::CreateRemoterFactory( | 227 void CastRemotingConnector::CreateRemoterFactory( |
| 228 content::RenderFrameHost* render_frame_host, | 228 content::RenderFrameHost* render_frame_host, |
| 229 media::mojom::RemoterFactoryRequest request) { | 229 media::mojom::RemoterFactoryRequest request) { |
| 230 mojo::MakeStrongBinding( | 230 mojo::MakeStrongBinding( |
| 231 base::MakeUnique<FrameRemoterFactory>(render_frame_host), | 231 base::MakeUnique<FrameRemoterFactory>(render_frame_host), |
| 232 std::move(request)); | 232 std::move(request)); |
| 233 } | 233 } |
| 234 | 234 |
| 235 CastRemotingConnector::CastRemotingConnector( | 235 CastRemotingConnector::CastRemotingConnector( |
| 236 media_router::MediaRouter* router, | 236 media_router::MediaRouter* router, |
| 237 const media_router::MediaSource::Id& route_source_id) | 237 const media_router::MediaSource::Id& media_source_id) |
| 238 : media_router::MediaRoutesObserver(router, route_source_id), | 238 : media_router::MediaRoutesObserver(router), |
| 239 media_source_id_(media_source_id), |
| 239 session_counter_(0), | 240 session_counter_(0), |
| 240 active_bridge_(nullptr), | 241 active_bridge_(nullptr), |
| 241 weak_factory_(this) {} | 242 weak_factory_(this) {} |
| 242 | 243 |
| 243 CastRemotingConnector::~CastRemotingConnector() { | 244 CastRemotingConnector::~CastRemotingConnector() { |
| 244 // Remoting should not be active at this point, and this instance is expected | 245 // Remoting should not be active at this point, and this instance is expected |
| 245 // to outlive all bridges. See comment in CreateBridge(). | 246 // to outlive all bridges. See comment in CreateBridge(). |
| 246 DCHECK(!active_bridge_); | 247 DCHECK(!active_bridge_); |
| 247 DCHECK(bridges_.empty()); | 248 DCHECK(bridges_.empty()); |
| 248 } | 249 } |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 notifyee->OnSinkGone(); | 542 notifyee->OnSinkGone(); |
| 542 } | 543 } |
| 543 | 544 |
| 544 // There shouldn't be an active RemotingBridge at this point, since there is | 545 // There shouldn't be an active RemotingBridge at this point, since there is |
| 545 // currently no known remoting route. | 546 // currently no known remoting route. |
| 546 DCHECK(!active_bridge_); | 547 DCHECK(!active_bridge_); |
| 547 | 548 |
| 548 // Scan |routes| for a new remoting route. If one is found, begin processing | 549 // Scan |routes| for a new remoting route. If one is found, begin processing |
| 549 // messages on the route, and notify the sources that remoting is now | 550 // messages on the route, and notify the sources that remoting is now |
| 550 // available. | 551 // available. |
| 551 if (!routes.empty()) { | 552 for (const media_router::MediaRoute& route : routes) { |
| 552 const media_router::MediaRoute& route = routes.front(); | 553 if (route.media_source().id() != media_source_id_) |
| 554 continue; |
| 553 message_observer_.reset(new MessageObserver( | 555 message_observer_.reset(new MessageObserver( |
| 554 media_router::MediaRoutesObserver::router(), route.media_route_id(), | 556 media_router::MediaRoutesObserver::router(), route.media_route_id(), |
| 555 this)); | 557 this)); |
| 556 // TODO(miu): In the future, scan the route ID for sink capabilities | 558 // TODO(miu): In the future, scan the route ID for sink capabilities |
| 557 // properties and pass these to the source in the OnSinkAvailable() | 559 // properties and pass these to the source in the OnSinkAvailable() |
| 558 // notification. | 560 // notification. |
| 559 for (RemotingBridge* notifyee : bridges_) | 561 for (RemotingBridge* notifyee : bridges_) |
| 560 notifyee->OnSinkAvailable(); | 562 notifyee->OnSinkAvailable(); |
| 563 break; |
| 561 } | 564 } |
| 562 } | 565 } |
| OLD | NEW |