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

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

Issue 2477573002: [Presentation API] (3rd) (1-UA) Split PresentationServiceDelegateImpl(PSDImpl) (Closed)
Patch Set: Created 4 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/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
44 using DelegateObserver = content::PresentationServiceDelegate::Observer; 47 using DelegateObserver = content::PresentationServiceDelegateBase::Observer;
45 48
46 // Returns the unique identifier for the supplied RenderFrameHost. 49 // Returns the unique identifier for the supplied RenderFrameHost.
47 RenderFrameHostId GetRenderFrameHostId(RenderFrameHost* render_frame_host) { 50 RenderFrameHostId GetRenderFrameHostId(RenderFrameHost* render_frame_host) {
48 int render_process_id = render_frame_host->GetProcess()->GetID(); 51 int render_process_id = render_frame_host->GetProcess()->GetID();
49 int render_frame_id = render_frame_host->GetRoutingID(); 52 int render_frame_id = render_frame_host->GetRoutingID();
50 return RenderFrameHostId(render_process_id, render_frame_id); 53 return RenderFrameHostId(render_process_id, render_frame_id);
51 } 54 }
52 55
53 // Gets the last committed URL for the render frame specified by 56 // Gets the last committed URL for the render frame specified by
54 // |render_frame_host_id|. 57 // |render_frame_host_id|.
(...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 int render_process_id, 913 int render_process_id,
911 int render_frame_id, 914 int render_frame_id,
912 const content::PresentationSessionInfo& connection, 915 const content::PresentationSessionInfo& connection,
913 const content::PresentationConnectionStateChangedCallback& 916 const content::PresentationConnectionStateChangedCallback&
914 state_changed_cb) { 917 state_changed_cb) {
915 frame_manager_->ListenForConnectionStateChange( 918 frame_manager_->ListenForConnectionStateChange(
916 RenderFrameHostId(render_process_id, render_frame_id), connection, 919 RenderFrameHostId(render_process_id, render_frame_id), connection,
917 state_changed_cb); 920 state_changed_cb);
918 } 921 }
919 922
923 void PresentationServiceDelegateImpl::ConnectToOffscreenPresentation(
924 int render_process_id,
925 int render_frame_id,
926 const content::PresentationSessionInfo& session,
927 content::PresentationConnectionPtr connection) {
928 RenderFrameHostId render_frame_host_id(render_process_id, render_frame_id);
929 auto offscreen_presentation_manager = OffscreenPresentationManagerFactory::
mark a. foltz 2016/11/08 23:40:51 Slight preference for auto offscreen_presentation_
zhaobin 2016/11/10 04:14:00 Done.
930 GetOrCreateForControllerBrowserContext(web_contents_);
931 offscreen_presentation_manager->RegisterOffscreenPresentationController(
932 session.presentation_id, GURL(session.presentation_url),
mark a. foltz 2016/11/08 23:40:51 session.presentation_url is already a GURL.
zhaobin 2016/11/10 04:13:59 Done.
933 render_frame_host_id, std::move(connection));
934 }
935
920 void PresentationServiceDelegateImpl::OnRouteResponse( 936 void PresentationServiceDelegateImpl::OnRouteResponse(
921 const PresentationRequest& presentation_request, 937 const PresentationRequest& presentation_request,
922 const RouteRequestResult& result) { 938 const RouteRequestResult& result) {
923 if (!result.route()) 939 if (!result.route())
924 return; 940 return;
925 941
926 content::PresentationSessionInfo session_info( 942 content::PresentationSessionInfo session_info(
927 presentation_request.presentation_url(), result.presentation_id()); 943 presentation_request.presentation_url(), result.presentation_id());
928 frame_manager_->OnDefaultPresentationSessionStarted( 944 frame_manager_->OnDefaultPresentationSessionStarted(
929 presentation_request, session_info, result.route()->media_route_id()); 945 presentation_request, session_info, result.route()->media_route_id());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 bool PresentationServiceDelegateImpl::HasScreenAvailabilityListenerForTest( 979 bool PresentationServiceDelegateImpl::HasScreenAvailabilityListenerForTest(
964 int render_process_id, 980 int render_process_id,
965 int render_frame_id, 981 int render_frame_id,
966 const MediaSource::Id& source_id) const { 982 const MediaSource::Id& source_id) const {
967 RenderFrameHostId render_frame_host_id(render_process_id, render_frame_id); 983 RenderFrameHostId render_frame_host_id(render_process_id, render_frame_id);
968 return frame_manager_->HasScreenAvailabilityListenerForTest( 984 return frame_manager_->HasScreenAvailabilityListenerForTest(
969 render_frame_host_id, source_id); 985 render_frame_host_id, source_id);
970 } 986 }
971 987
972 } // namespace media_router 988 } // namespace media_router
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698