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

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

Issue 2379703002: [Presentation API] (alternative) 1-UA: send message between controller and receiver page (Closed)
Patch Set: resolve code review comments from Mark Created 4 years, 2 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 #include <unordered_map> 8 #include <unordered_map>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/containers/small_map.h" 12 #include "base/containers/small_map.h"
13 #include "base/guid.h" 13 #include "base/guid.h"
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
17 #include "chrome/browser/media/router/create_presentation_connection_request.h" 17 #include "chrome/browser/media/router/create_presentation_connection_request.h"
18 #include "chrome/browser/media/router/media_route.h" 18 #include "chrome/browser/media/router/media_route.h"
19 #include "chrome/browser/media/router/media_router.h" 19 #include "chrome/browser/media/router/media_router.h"
20 #include "chrome/browser/media/router/media_router_dialog_controller.h" 20 #include "chrome/browser/media/router/media_router_dialog_controller.h"
21 #include "chrome/browser/media/router/media_router_factory.h" 21 #include "chrome/browser/media/router/media_router_factory.h"
22 #include "chrome/browser/media/router/media_sink.h" 22 #include "chrome/browser/media/router/media_sink.h"
23 #include "chrome/browser/media/router/media_source_helper.h" 23 #include "chrome/browser/media/router/media_source_helper.h"
24 #include "chrome/browser/media/router/offscreen_presentation_manager.h"
25 #include "chrome/browser/media/router/offscreen_presentation_manager_factory.h"
24 #include "chrome/browser/media/router/presentation_media_sinks_observer.h" 26 #include "chrome/browser/media/router/presentation_media_sinks_observer.h"
25 #include "chrome/browser/media/router/route_message.h" 27 #include "chrome/browser/media/router/route_message.h"
26 #include "chrome/browser/media/router/route_message_observer.h" 28 #include "chrome/browser/media/router/route_message_observer.h"
27 #include "chrome/browser/media/router/route_request_result.h" 29 #include "chrome/browser/media/router/route_request_result.h"
28 #include "chrome/browser/sessions/session_tab_helper.h" 30 #include "chrome/browser/sessions/session_tab_helper.h"
29 #include "content/public/browser/browser_context.h" 31 #include "content/public/browser/browser_context.h"
30 #include "content/public/browser/presentation_screen_availability_listener.h" 32 #include "content/public/browser/presentation_screen_availability_listener.h"
31 #include "content/public/browser/presentation_session.h" 33 #include "content/public/browser/presentation_session.h"
32 #include "content/public/browser/render_frame_host.h" 34 #include "content/public/browser/render_frame_host.h"
33 #include "content/public/browser/render_process_host.h" 35 #include "content/public/browser/render_process_host.h"
36 #include "url/gurl.h"
34 37
35 DEFINE_WEB_CONTENTS_USER_DATA_KEY( 38 DEFINE_WEB_CONTENTS_USER_DATA_KEY(
36 media_router::PresentationServiceDelegateImpl); 39 media_router::PresentationServiceDelegateImpl);
37 40
38 using content::RenderFrameHost; 41 using content::RenderFrameHost;
39 42
40 namespace media_router { 43 namespace media_router {
41 44
42 namespace { 45 namespace {
43 46
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 PresentationServiceDelegateImpl::CreateForWebContents(web_contents); 662 PresentationServiceDelegateImpl::CreateForWebContents(web_contents);
660 return PresentationServiceDelegateImpl::FromWebContents(web_contents); 663 return PresentationServiceDelegateImpl::FromWebContents(web_contents);
661 } 664 }
662 665
663 PresentationServiceDelegateImpl::PresentationServiceDelegateImpl( 666 PresentationServiceDelegateImpl::PresentationServiceDelegateImpl(
664 content::WebContents* web_contents) 667 content::WebContents* web_contents)
665 : web_contents_(web_contents), 668 : web_contents_(web_contents),
666 router_(MediaRouterFactory::GetApiForBrowserContext( 669 router_(MediaRouterFactory::GetApiForBrowserContext(
667 web_contents_->GetBrowserContext())), 670 web_contents_->GetBrowserContext())),
668 frame_manager_(new PresentationFrameManager(web_contents, router_)), 671 frame_manager_(new PresentationFrameManager(web_contents, router_)),
672 offscreen_presentation_manager_(
673 OffscreenPresentationManagerFactory::GetOrCreateForBrowserContext(
mark a. foltz 2016/10/08 00:33:41 Maybe there could be a OffscreenPresentationManage
zhaobin 2016/10/12 02:27:33 Done.
674 web_contents_->GetBrowserContext())),
669 weak_factory_(this) { 675 weak_factory_(this) {
670 DCHECK(web_contents_); 676 DCHECK(web_contents_);
671 DCHECK(router_); 677 DCHECK(router_);
672 } 678 }
673 679
674 PresentationServiceDelegateImpl::~PresentationServiceDelegateImpl() { 680 PresentationServiceDelegateImpl::~PresentationServiceDelegateImpl() {
675 } 681 }
676 682
677 void PresentationServiceDelegateImpl::AddObserver(int render_process_id, 683 void PresentationServiceDelegateImpl::AddObserver(int render_process_id,
678 int render_frame_id, 684 int render_frame_id,
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 int render_process_id, 913 int render_process_id,
908 int render_frame_id, 914 int render_frame_id,
909 const content::PresentationSessionInfo& connection, 915 const content::PresentationSessionInfo& connection,
910 const content::PresentationConnectionStateChangedCallback& 916 const content::PresentationConnectionStateChangedCallback&
911 state_changed_cb) { 917 state_changed_cb) {
912 frame_manager_->ListenForConnectionStateChange( 918 frame_manager_->ListenForConnectionStateChange(
913 RenderFrameHostId(render_process_id, render_frame_id), connection, 919 RenderFrameHostId(render_process_id, render_frame_id), connection,
914 state_changed_cb); 920 state_changed_cb);
915 } 921 }
916 922
923 void PresentationServiceDelegateImpl::RegisterReceiverAvailableCallback(
924 const content::ReceiverConnectionAvailableCallback&
925 receiver_available_callback) {}
mark a. foltz 2016/10/08 00:33:41 This is not implemented for the controller's PSImp
zhaobin 2016/10/12 02:27:33 Done.
926
927 void PresentationServiceDelegateImpl::RegisterOffscreenPresentationConnection(
928 int render_process_id,
929 int render_frame_id,
930 const content::PresentationSessionInfo& session,
931 content::PresentationConnectionPtr connection) {
932 RenderFrameHostId render_frame_host_id(render_process_id, render_frame_id);
933 offscreen_presentation_manager_->RegisterOffscreenPresentationController(
934 session.presentation_id, GURL(session.presentation_url),
935 render_frame_host_id, std::move(connection));
936 }
937
917 void PresentationServiceDelegateImpl::OnRouteResponse( 938 void PresentationServiceDelegateImpl::OnRouteResponse(
918 const PresentationRequest& presentation_request, 939 const PresentationRequest& presentation_request,
919 const RouteRequestResult& result) { 940 const RouteRequestResult& result) {
920 if (!result.route()) 941 if (!result.route())
921 return; 942 return;
922 943
923 content::PresentationSessionInfo session_info( 944 content::PresentationSessionInfo session_info(
924 presentation_request.presentation_url(), result.presentation_id()); 945 presentation_request.presentation_url(), result.presentation_id());
925 frame_manager_->OnDefaultPresentationSessionStarted( 946 frame_manager_->OnDefaultPresentationSessionStarted(
926 presentation_request, session_info, result.route()->media_route_id()); 947 presentation_request, session_info, result.route()->media_route_id());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 bool PresentationServiceDelegateImpl::HasScreenAvailabilityListenerForTest( 981 bool PresentationServiceDelegateImpl::HasScreenAvailabilityListenerForTest(
961 int render_process_id, 982 int render_process_id,
962 int render_frame_id, 983 int render_frame_id,
963 const MediaSource::Id& source_id) const { 984 const MediaSource::Id& source_id) const {
964 RenderFrameHostId render_frame_host_id(render_process_id, render_frame_id); 985 RenderFrameHostId render_frame_host_id(render_process_id, render_frame_id);
965 return frame_manager_->HasScreenAvailabilityListenerForTest( 986 return frame_manager_->HasScreenAvailabilityListenerForTest(
966 render_frame_host_id, source_id); 987 render_frame_host_id, source_id);
967 } 988 }
968 989
969 } // namespace media_router 990 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698