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

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

Issue 1202963004: Gets presentation ID from route ID upon route creation, and overrides previous presentation ID with… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
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/media/router/presentation_service_delegate_impl.h" 5 #include "chrome/browser/media/router/presentation_service_delegate_impl.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/containers/scoped_ptr_hash_map.h" 9 #include "base/containers/scoped_ptr_hash_map.h"
10 #include "base/containers/small_map.h" 10 #include "base/containers/small_map.h"
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 DVLOG(1) << "No active route for: " << presentation_id; 616 DVLOG(1) << "No active route for: " << presentation_id;
617 return; 617 return;
618 } 618 }
619 router_->CloseRoute(route_id); 619 router_->CloseRoute(route_id);
620 } 620 }
621 621
622 void PresentationServiceDelegateImpl::ListenForSessionMessages( 622 void PresentationServiceDelegateImpl::ListenForSessionMessages(
623 int render_process_id, 623 int render_process_id,
624 int render_frame_id, 624 int render_frame_id,
625 const PresentationSessionMessageCallback& message_cb) { 625 const PresentationSessionMessageCallback& message_cb) {
626 // BUG=464205 626 const std::vector<MediaRoute::Id>& route_ids = frame_manager_->GetRouteIds(
627 NOTIMPLEMENTED(); 627 RenderFrameHostId(render_process_id, render_frame_id));
628 if (route_ids.empty()) {
629 DVLOG(1) << "No media routes found";
630 message_cb.Run(
631 scoped_ptr<ScopedVector<content::PresentationSessionMessage>>());
632 return;
633 }
634
635 router_->ListenForRouteMessages(route_ids, message_cb);
628 } 636 }
629 637
630 void PresentationServiceDelegateImpl::SendMessage( 638 void PresentationServiceDelegateImpl::SendMessage(
631 int render_process_id, 639 int render_process_id,
632 int render_frame_id, 640 int render_frame_id,
633 scoped_ptr<content::PresentationSessionMessage> message_request, 641 scoped_ptr<content::PresentationSessionMessage> message_request,
634 const SendMessageCallback& send_message_cb) { 642 const SendMessageCallback& send_message_cb) {
635 // BUG=464205 643 if (message_request->is_binary()) {
636 NOTIMPLEMENTED(); 644 NOTIMPLEMENTED();
645 send_message_cb.Run(false);
646 return;
647 }
648 const MediaRoute::Id& route_id = frame_manager_->GetRouteId(
649 RenderFrameHostId(render_process_id, render_frame_id),
650 message_request->presentation_id);
651 if (route_id.empty()) {
652 DVLOG(1) << "No active route for " << message_request->presentation_id;
653 send_message_cb.Run(false);
654 return;
655 }
656 router_->SendRouteMessage(route_id, *(message_request->message),
657 send_message_cb);
637 } 658 }
638 659
639 void PresentationServiceDelegateImpl::OnRouteCreated(const MediaRoute& route) { 660 void PresentationServiceDelegateImpl::OnRouteCreated(const MediaRoute& route) {
640 const MediaSource& source = route.media_source(); 661 const MediaSource& source = route.media_source();
641 DCHECK(!source.Empty()); 662 DCHECK(!source.Empty());
642 if (!default_source_.Equals(source)) 663 if (!default_source_.Equals(source))
643 return; 664 return;
644 RenderFrameHost* main_frame = web_contents_->GetMainFrame(); 665 RenderFrameHost* main_frame = web_contents_->GetMainFrame();
645 if (!main_frame) 666 if (!main_frame)
646 return; 667 return;
647 RenderFrameHostId render_frame_host_id(GetRenderFrameHostId(main_frame)); 668 RenderFrameHostId render_frame_host_id(GetRenderFrameHostId(main_frame));
648 // TODO(imcheng): Pass in valid default presentation ID once it is 669 std::string presentation_id =
649 // available from MediaRoute URN. BUG=493365 670 GetPresentationIdAndUrl(route.media_route_id()).first;
650 std::string presentation_id;
651 frame_manager_->OnPresentationSessionStarted( 671 frame_manager_->OnPresentationSessionStarted(
652 render_frame_host_id, true, 672 render_frame_host_id, true,
653 content::PresentationSessionInfo(PresentationUrlFromMediaSource(source), 673 content::PresentationSessionInfo(PresentationUrlFromMediaSource(source),
654 presentation_id), 674 presentation_id),
655 route.media_route_id()); 675 route.media_route_id());
656 } 676 }
657 677
658 void PresentationServiceDelegateImpl::AddDefaultMediaSourceObserver( 678 void PresentationServiceDelegateImpl::AddDefaultMediaSourceObserver(
659 DefaultMediaSourceObserver* observer) { 679 DefaultMediaSourceObserver* observer) {
660 default_media_source_observers_.AddObserver(observer); 680 default_media_source_observers_.AddObserver(observer);
(...skipping 18 matching lines...) Expand all
679 bool PresentationServiceDelegateImpl::HasScreenAvailabilityListenerForTest( 699 bool PresentationServiceDelegateImpl::HasScreenAvailabilityListenerForTest(
680 int render_process_id, 700 int render_process_id,
681 int render_frame_id, 701 int render_frame_id,
682 const MediaSource::Id& source_id) const { 702 const MediaSource::Id& source_id) const {
683 RenderFrameHostId render_frame_host_id(render_process_id, render_frame_id); 703 RenderFrameHostId render_frame_host_id(render_process_id, render_frame_id);
684 return frame_manager_->HasScreenAvailabilityListenerForTest( 704 return frame_manager_->HasScreenAvailabilityListenerForTest(
685 render_frame_host_id, source_id); 705 render_frame_host_id, source_id);
686 } 706 }
687 707
688 } // namespace media_router 708 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698