Chromium Code Reviews| Index: chrome/browser/ui/webui/media_router/media_router_ui.cc |
| diff --git a/chrome/browser/ui/webui/media_router/media_router_ui.cc b/chrome/browser/ui/webui/media_router/media_router_ui.cc |
| index 4d05a519aebd76df1736f5ceaba1458dc1516142..f4fab98eab9a8bacbb43f4cf6d4ab1c6401a8e18 100644 |
| --- a/chrome/browser/ui/webui/media_router/media_router_ui.cc |
| +++ b/chrome/browser/ui/webui/media_router/media_router_ui.cc |
| @@ -334,6 +334,57 @@ bool MediaRouterUI::CreateRoute(const MediaSink::Id& sink_id, |
| return true; |
| } |
| +bool MediaRouterUI::JoinRoute(const MediaSink::Id& sink_id, |
| + const MediaRoute::Id& route_id) { |
| + DCHECK(query_result_manager_.get()); |
| + DCHECK(initiator_); |
| + |
| + current_route_request_id_ = ++route_request_counter_; |
| + GURL origin = frame_url_.GetOrigin(); |
| + |
| + MediaSource source = |
| + query_result_manager_->GetSourceForCastMode(MediaCastMode::DEFAULT); |
| + |
| + if (source.Empty()) { |
| + LOG(ERROR) << "No MediaSource to join"; |
| + return false; |
| + } |
| + |
| + DCHECK(origin.is_valid()); |
| + |
| + // There are 3 cases. In all cases the MediaRouterUI will need to be notified. |
|
mark a. foltz
2015/11/09 19:12:31
This comment block needs to be rewritten to discus
|
| + // (1) Non-presentation route request (e.g., mirroring). No additional |
| + // notification necessary. |
| + // (2) Presentation route request for a Presentation API startSession call. |
| + // The startSession (CreatePresentationSessionRequest) will need to be |
| + // answered with the |
| + // route response. |
| + // (3) Browser-initiated presentation route request. If successful, |
| + // PresentationServiceDelegateImpl will have to be notified. Note that we |
| + // treat subsequent route requests from a Presentation API-initiated dialogs |
| + // as browser-initiated. |
| + std::vector<MediaRouteResponseCallback> route_response_callbacks; |
| + route_response_callbacks.push_back(base::Bind( |
| + &MediaRouterUI::OnRouteResponseReceived, weak_factory_.GetWeakPtr(), |
| + current_route_request_id_, sink_id)); |
| + |
| + if (presentation_service_delegate_) { |
| + route_response_callbacks.push_back( |
| + base::Bind(&PresentationServiceDelegateImpl::OnRouteResponse, |
| + presentation_service_delegate_)); |
| + } |
| + |
| + // Start the timer. |
| + route_creation_timer_.Start( |
| + FROM_HERE, base::TimeDelta::FromSeconds(kCreateRouteTimeoutSeconds), this, |
| + &MediaRouterUI::RouteCreationTimeout); |
| + std::string presentation_id("non-local-join_"); |
|
mark a. foltz
2015/11/09 19:12:31
I don't think the UI should be manufacturing prese
matt.boetger
2015/11/09 19:24:35
If the router is to create the presentation Id, I
imcheng
2015/11/09 22:23:15
I can see 2 ways to make that work:
1) Add a JoinR
|
| + presentation_id += route_id; |
|
mark a. foltz
2015/11/09 19:12:31
What if there are simultaneous requests to join th
|
| + router_->JoinRoute(source.id(), presentation_id, origin, |
| + initiator_, route_response_callbacks); |
| + return true; |
| +} |
| + |
| void MediaRouterUI::CloseRoute(const MediaRoute::Id& route_id) { |
| router_->CloseRoute(route_id); |
| } |