Commit f23b896e authored by imcheng's avatar imcheng Committed by Commit Bot

[MediaRouter] PresentationServiceDelegateImpl cleanup.

- Removed method declarations that are not defined.
- Removed PresentationFrameManager. There is not much reason to keep
  it since most of the logic is just delegating from PSDImpl.
- Push the URL validity check for screen availability to PSImpl.

BUG=736557

Review-Url: https://codereview.chromium.org/2958663002
Cr-Commit-Position: refs/heads/master@{#485437}
parent 2f6a4c5b
......@@ -38,7 +38,7 @@ class Origin;
namespace media_router {
class MediaRoute;
class PresentationFrameManager;
class PresentationFrame;
class RouteRequestResult;
// Implementation of PresentationServiceDelegate that interfaces an instance of
......@@ -147,7 +147,7 @@ class PresentationServiceDelegateImpl
void RemoveDefaultPresentationRequestObserver(
DefaultPresentationRequestObserver* observer);
// Gets the default presentation request for the owning tab WebContents. It
// Gets the default presentation request for the owning WebContents. It
// is an error to call this method if the default presentation request does
// not exist.
PresentationRequest GetDefaultPresentationRequest() const;
......@@ -186,10 +186,8 @@ class PresentationServiceDelegateImpl
explicit PresentationServiceDelegateImpl(content::WebContents* web_contents);
// Returns |listener|'s presentation URL as a MediaSource. If |listener| does
// not have a persentation URL, returns the tab mirroring MediaSource.
MediaSource GetMediaSourceFromListener(
content::PresentationScreenAvailabilityListener* listener);
PresentationFrame* GetOrAddPresentationFrame(
const RenderFrameHostId& render_frame_host_id);
void OnJoinRouteResponse(
int render_process_id,
......@@ -207,6 +205,39 @@ class PresentationServiceDelegateImpl
const content::PresentationInfo& new_presentation_info,
const MediaRoute& route);
// Notifies the PresentationFrame of |render_frame_host_id| that a
// presentation and its corresponding MediaRoute has been created.
// The PresentationFrame will be created if it does not already exist.
// This must be called before |ConnectToPresentation()|.
void AddPresentation(const RenderFrameHostId& render_frame_host_id,
const content::PresentationInfo& presentation_info,
const MediaRoute& route);
// Notifies the PresentationFrame of |render_frame_host_id| that a
// presentation and its corresponding MediaRoute has been removed.
void RemovePresentation(const RenderFrameHostId& render_frame_host_id,
const std::string& presentation_id);
// Sets the default presentation request for the owning WebContents and
// notifies observers of changes.
void SetDefaultPresentationRequest(
const PresentationRequest& default_presentation_request);
// Clears the default presentation request for the owning WebContents and
// notifies observers of changes. Also resets
// |default_presentation_started_callback_|.
void ClearDefaultPresentationRequest();
// Returns |true| if the given frame is the main frame of the associated
// WebContents.
// NOTE: This method will be removed in an upcoming patch.
bool IsMainFrame(const RenderFrameHostId& render_frame_host_id) const;
// Returns the ID of the route corresponding to |presentation_id| in the given
// frame, or empty if no such route exist.
MediaRoute::Id GetRouteId(const RenderFrameHostId& render_frame_host_id,
const std::string& presentation_id) const;
#if !defined(OS_ANDROID)
// Returns true if auto-join requests should be cancelled for |origin|.
bool ShouldCancelAutoJoinForOrigin(const url::Origin& origin) const;
......@@ -217,7 +248,25 @@ class PresentationServiceDelegateImpl
content::WebContents* const web_contents_;
MediaRouter* router_;
std::unique_ptr<PresentationFrameManager> frame_manager_;
// References to the observers listening for changes to the default
// presentation of the associated WebContents.
base::ObserverList<DefaultPresentationRequestObserver>
default_presentation_request_observers_;
// Default presentation request for the owning WebContents.
std::unique_ptr<PresentationRequest> default_presentation_request_;
// Callback to invoke when the default presentation has started.
content::DefaultPresentationConnectionCallback
default_presentation_started_callback_;
// Maps a frame identifier to a PresentationFrame object for frames
// that are using Presentation API.
std::unordered_map<RenderFrameHostId,
std::unique_ptr<PresentationFrame>,
RenderFrameHostIdHasher>
presentation_frames_;
PresentationServiceDelegateObservers observers_;
base::WeakPtrFactory<PresentationServiceDelegateImpl> weak_factory_;
......
......@@ -125,7 +125,7 @@ void PresentationServiceImpl::SetClient(
void PresentationServiceImpl::ListenForScreenAvailability(const GURL& url) {
DVLOG(2) << "ListenForScreenAvailability " << url.spec();
if (!controller_delegate_) {
if (!controller_delegate_ || !url.is_valid()) {
client_->OnScreenAvailabilityUpdated(
url, blink::mojom::ScreenAvailability::UNAVAILABLE);
return;
......@@ -464,13 +464,13 @@ PresentationServiceImpl::ScreenAvailabilityListenerImpl::
ScreenAvailabilityListenerImpl(const GURL& availability_url,
PresentationServiceImpl* service)
: availability_url_(availability_url), service_(service) {
DCHECK(availability_url_.is_valid());
DCHECK(service_);
DCHECK(service_->client_.get());
}
PresentationServiceImpl::ScreenAvailabilityListenerImpl::
~ScreenAvailabilityListenerImpl() {
}
~ScreenAvailabilityListenerImpl() = default;
GURL PresentationServiceImpl::ScreenAvailabilityListenerImpl::
GetAvailabilityUrl() const {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment