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

Side by Side Diff: chrome/browser/ui/webui/media_router/media_router_ui.cc

Issue 1415103006: Non-Local Join for Media Router and Presentation API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Auto-Formatting Fixes Created 5 years, 1 month 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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/ui/webui/media_router/media_router_ui.h" 5 #include "chrome/browser/ui/webui/media_router/media_router_ui.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/guid.h" 9 #include "base/guid.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 route_creation_timer_.Start( 327 route_creation_timer_.Start(
328 FROM_HERE, base::TimeDelta::FromSeconds(kCreateRouteTimeoutSeconds), 328 FROM_HERE, base::TimeDelta::FromSeconds(kCreateRouteTimeoutSeconds),
329 this, &MediaRouterUI::RouteCreationTimeout); 329 this, &MediaRouterUI::RouteCreationTimeout);
330 330
331 router_->CreateRoute(source.id(), sink_id, origin, 331 router_->CreateRoute(source.id(), sink_id, origin,
332 initiator_, 332 initiator_,
333 route_response_callbacks); 333 route_response_callbacks);
334 return true; 334 return true;
335 } 335 }
336 336
337 bool MediaRouterUI::JoinRoute(const MediaSink::Id& sink_id,
338 const MediaRoute::Id& route_id) {
339 DCHECK(query_result_manager_.get());
340 DCHECK(initiator_);
341
342 current_route_request_id_ = ++route_request_counter_;
343 GURL origin = frame_url_.GetOrigin();
344
345 MediaSource source =
346 query_result_manager_->GetSourceForCastMode(MediaCastMode::DEFAULT);
347
348 if (source.Empty()) {
349 LOG(ERROR) << "No MediaSource to join";
350 return false;
351 }
352
353 DCHECK(origin.is_valid());
354
355 // 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
356 // (1) Non-presentation route request (e.g., mirroring). No additional
357 // notification necessary.
358 // (2) Presentation route request for a Presentation API startSession call.
359 // The startSession (CreatePresentationSessionRequest) will need to be
360 // answered with the
361 // route response.
362 // (3) Browser-initiated presentation route request. If successful,
363 // PresentationServiceDelegateImpl will have to be notified. Note that we
364 // treat subsequent route requests from a Presentation API-initiated dialogs
365 // as browser-initiated.
366 std::vector<MediaRouteResponseCallback> route_response_callbacks;
367 route_response_callbacks.push_back(base::Bind(
368 &MediaRouterUI::OnRouteResponseReceived, weak_factory_.GetWeakPtr(),
369 current_route_request_id_, sink_id));
370
371 if (presentation_service_delegate_) {
372 route_response_callbacks.push_back(
373 base::Bind(&PresentationServiceDelegateImpl::OnRouteResponse,
374 presentation_service_delegate_));
375 }
376
377 // Start the timer.
378 route_creation_timer_.Start(
379 FROM_HERE, base::TimeDelta::FromSeconds(kCreateRouteTimeoutSeconds), this,
380 &MediaRouterUI::RouteCreationTimeout);
381 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
382 presentation_id += route_id;
mark a. foltz 2015/11/09 19:12:31 What if there are simultaneous requests to join th
383 router_->JoinRoute(source.id(), presentation_id, origin,
384 initiator_, route_response_callbacks);
385 return true;
386 }
387
337 void MediaRouterUI::CloseRoute(const MediaRoute::Id& route_id) { 388 void MediaRouterUI::CloseRoute(const MediaRoute::Id& route_id) {
338 router_->CloseRoute(route_id); 389 router_->CloseRoute(route_id);
339 } 390 }
340 391
341 void MediaRouterUI::AddIssue(const Issue& issue) { 392 void MediaRouterUI::AddIssue(const Issue& issue) {
342 router_->AddIssue(issue); 393 router_->AddIssue(issue);
343 } 394 }
344 395
345 void MediaRouterUI::ClearIssue(const std::string& issue_id) { 396 void MediaRouterUI::ClearIssue(const std::string& issue_id) {
346 router_->ClearIssue(issue_id); 397 router_->ClearIssue(issue_id);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 460
410 std::string MediaRouterUI::GetFrameURLHost() const { 461 std::string MediaRouterUI::GetFrameURLHost() const {
411 return GetHostFromURL(frame_url_); 462 return GetHostFromURL(frame_url_);
412 } 463 }
413 464
414 const std::string& MediaRouterUI::GetRouteProviderExtensionId() const { 465 const std::string& MediaRouterUI::GetRouteProviderExtensionId() const {
415 return router_->media_route_provider_extension_id(); 466 return router_->media_route_provider_extension_id();
416 } 467 }
417 468
418 } // namespace media_router 469 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698