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

Unified Diff: chrome/browser/media/router/presentation_service_delegate_impl.cc

Issue 2477573002: [Presentation API] (3rd) (1-UA) Split PresentationServiceDelegateImpl(PSDImpl) (Closed)
Patch Set: fix windows compile error Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/media/router/presentation_service_delegate_impl.cc
diff --git a/chrome/browser/media/router/presentation_service_delegate_impl.cc b/chrome/browser/media/router/presentation_service_delegate_impl.cc
index 156a9bb5c7f38ac59025fd616d19b39ba11a0e42..59e441a9ffb9a75dd0ddd9d2672d7bee415f6a40 100644
--- a/chrome/browser/media/router/presentation_service_delegate_impl.cc
+++ b/chrome/browser/media/router/presentation_service_delegate_impl.cc
@@ -20,6 +20,8 @@
#include "chrome/browser/media/router/media_router_factory.h"
#include "chrome/browser/media/router/media_sink.h"
#include "chrome/browser/media/router/media_source_helper.h"
+#include "chrome/browser/media/router/offscreen_presentation_manager.h"
+#include "chrome/browser/media/router/offscreen_presentation_manager_factory.h"
#include "chrome/browser/media/router/presentation_media_sinks_observer.h"
#include "chrome/browser/media/router/route_message.h"
#include "chrome/browser/media/router/route_message_observer.h"
@@ -30,6 +32,7 @@
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/common/presentation_session.h"
+#include "url/gurl.h"
#if !defined(OS_ANDROID)
#include "chrome/browser/profiles/profile.h"
@@ -193,8 +196,7 @@ PresentationFrame::PresentationFrame(
MediaRouter* router)
: render_frame_host_id_(render_frame_host_id),
web_contents_(web_contents),
- router_(router),
- delegate_observer_(nullptr) {
+ router_(router) {
DCHECK(web_contents_);
DCHECK(router_);
}
@@ -202,11 +204,6 @@ PresentationFrame::PresentationFrame(
PresentationFrame::~PresentationFrame() {
}
-void PresentationFrame::OnPresentationServiceDelegateDestroyed() const {
- if (delegate_observer_)
- delegate_observer_->OnDelegateDestroyed();
-}
-
void PresentationFrame::OnPresentationSessionStarted(
const content::PresentationSessionInfo& session,
const MediaRoute& route) {
@@ -458,10 +455,7 @@ PresentationFrameManager::PresentationFrameManager(
DCHECK(router_);
}
-PresentationFrameManager::~PresentationFrameManager() {
- for (auto& frame : presentation_frames_)
- frame.second->OnPresentationServiceDelegateDestroyed();
-}
+PresentationFrameManager::~PresentationFrameManager() {}
void PresentationFrameManager::OnPresentationSessionStarted(
const RenderFrameHostId& render_frame_host_id,
@@ -568,22 +562,6 @@ void PresentationFrameManager::SetDefaultPresentationUrls(
}
}
-void PresentationFrameManager::AddDelegateObserver(
- const RenderFrameHostId& render_frame_host_id,
- DelegateObserver* observer) {
- auto* presentation_frame = GetOrAddPresentationFrame(render_frame_host_id);
- presentation_frame->set_delegate_observer(observer);
-}
-
-void PresentationFrameManager::RemoveDelegateObserver(
- const RenderFrameHostId& render_frame_host_id) {
- const auto it = presentation_frames_.find(render_frame_host_id);
- if (it != presentation_frames_.end()) {
- it->second->set_delegate_observer(nullptr);
- presentation_frames_.erase(it);
- }
-}
-
void PresentationFrameManager::AddDefaultPresentationRequestObserver(
PresentationServiceDelegateImpl::DefaultPresentationRequestObserver*
observer) {
@@ -688,14 +666,12 @@ void PresentationServiceDelegateImpl::AddObserver(int render_process_id,
int render_frame_id,
DelegateObserver* observer) {
DCHECK(observer);
- frame_manager_->AddDelegateObserver(
- RenderFrameHostId(render_process_id, render_frame_id), observer);
+ observers_.AddObserver(render_process_id, render_frame_id, observer);
}
void PresentationServiceDelegateImpl::RemoveObserver(int render_process_id,
int render_frame_id) {
- frame_manager_->RemoveDelegateObserver(
- RenderFrameHostId(render_process_id, render_frame_id));
+ observers_.RemoveObserver(render_process_id, render_frame_id);
}
bool PresentationServiceDelegateImpl::AddScreenAvailabilityListener(
@@ -935,6 +911,22 @@ void PresentationServiceDelegateImpl::ListenForConnectionStateChange(
state_changed_cb);
}
+void PresentationServiceDelegateImpl::ConnectToOffscreenPresentation(
+ int render_process_id,
+ int render_frame_id,
+ const content::PresentationSessionInfo& session,
+ content::PresentationConnectionPtr controller_connection_ptr,
+ content::PresentationConnectionRequest receiver_connection_request) {
+ RenderFrameHostId render_frame_host_id(render_process_id, render_frame_id);
+ auto* const offscreen_presentation_manager =
+ OffscreenPresentationManagerFactory::GetOrCreateForWebContents(
+ web_contents_);
+ offscreen_presentation_manager->RegisterOffscreenPresentationController(
+ session.presentation_id, session.presentation_url, render_frame_host_id,
+ std::move(controller_connection_ptr),
+ std::move(receiver_connection_request));
+}
+
void PresentationServiceDelegateImpl::OnRouteResponse(
const PresentationRequest& presentation_request,
const RouteRequestResult& result) {

Powered by Google App Engine
This is Rietveld 408576698