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

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

Issue 2657613007: [Media Router] Erase PresentationFrame entry when corresponding RenderFrameHost is gone (Closed)
Patch Set: resolve code review comments from Derek 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 59e441a9ffb9a75dd0ddd9d2672d7bee415f6a40..e938d757883b27bf872c800695bdb5cb58167398 100644
--- a/chrome/browser/media/router/presentation_service_delegate_impl.cc
+++ b/chrome/browser/media/router/presentation_service_delegate_impl.cc
@@ -122,9 +122,13 @@ class PresentationSessionMessagesObserver : public RouteMessageObserver {
// Used by PresentationServiceDelegateImpl to manage
// listeners and default presentation info in a render frame.
// Its lifetime:
-// * PresentationFrameManager AddDelegateObserver
-// * Reset 0+ times.
-// * PresentationFrameManager.RemoveDelegateObserver.
+// * Create an instance with |render_frame_host_id_| if no instance with the
+// same |render_frame_host_id_| exists in:
+// PresentationFrameManager::OnPresentationSessionStarted
+// PresentationFrameManager::OnDefaultPresentationSessionStarted
+// PresentationFrameManager::SetScreenAvailabilityListener
+// * Destroy the instance in:
+// PresentationFrameManager::Reset
class PresentationFrame {
public:
PresentationFrame(const RenderFrameHostId& render_frame_host_id,
@@ -160,10 +164,6 @@ class PresentationFrame {
const MediaRoute& route);
void OnPresentationServiceDelegateDestroyed() const;
- void set_delegate_observer(DelegateObserver* observer) {
- delegate_observer_ = observer;
- }
-
private:
MediaSource GetMediaSourceFromListener(
content::PresentationScreenAvailabilityListener* listener) const;
@@ -186,8 +186,6 @@ class PresentationFrame {
// References to the owning WebContents, and the corresponding MediaRouter.
content::WebContents* web_contents_;
MediaRouter* router_;
-
- DelegateObserver* delegate_observer_;
};
PresentationFrame::PresentationFrame(
@@ -469,9 +467,7 @@ void PresentationFrameManager::OnDefaultPresentationSessionStarted(
const PresentationRequest& request,
const content::PresentationSessionInfo& session,
const MediaRoute& route) {
- const auto it = presentation_frames_.find(request.render_frame_host_id());
- if (it != presentation_frames_.end())
- it->second->OnPresentationSessionStarted(session, route);
+ OnPresentationSessionStarted(request.render_frame_host_id(), session, route);
if (default_presentation_request_ &&
default_presentation_request_->Equals(request)) {
@@ -577,8 +573,10 @@ void PresentationFrameManager::RemoveDefaultPresentationRequestObserver(
void PresentationFrameManager::Reset(
const RenderFrameHostId& render_frame_host_id) {
const auto it = presentation_frames_.find(render_frame_host_id);
- if (it != presentation_frames_.end())
+ if (it != presentation_frames_.end()) {
it->second->Reset();
+ presentation_frames_.erase(it);
+ }
if (default_presentation_request_ &&
render_frame_host_id ==
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698